-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
172 lines (143 loc) · 5.89 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: zjamali <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/05/02 16:01:57 by mbari #+# #+# #
# Updated: 2022/03/04 08:27:53 by zjamali ### ########.fr #
# #
# **************************************************************************** #
# Name of the final executable
NAME = minishell
# Project's directories
SOURCEDIR := ./src
HEADERSDIR := ./headers
OBJECTSDIR := ./objects
EXEC_FOLDER = execution
LEX_FOLDER = lexer
PARS_FOLDER = parse
EXPA_FOLDER = expansion
READ_FOLDER = readline
LIBFT_HEADER = $(SOURCEDIR)/libft/libft.h
LIBFT_FOLDER = $(SOURCEDIR)/libft
# Name of variables
LIBFT_LIB = libft.a
LIBS = -lncurses
FLAGS = -Wall -Wextra -Werror
RED = \033[1;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
BLUE = \033[1;34m
RESET = \033[0m
# Execution files variable
EXEC_FILES = ft_cd.c \
ft_check_path.c \
ft_echo_pwd_env.c \
ft_execution.c \
ft_exit.c \
ft_export.c \
ft_init_env.c \
ft_linked_lists.c \
ft_linked_lists_rest.c \
ft_pipes.c \
ft_redirection.c \
ft_unset.c \
ft_utlis.c
# Lexer files variable
LEX_FILES = lexer_get_tokens_op.c \
lexer_get_tokens_word.c \
lexer_get_tokens.c \
lexer.c
# Parse files variable
PARS_FILES = check_syntax.c \
check_token_continue.c \
check_tokens.c \
check_word.c \
create_ast.c \
create_nodes.c \
destoy_nodes.c \
parser.c
# Readline files variable
READ_FILES = chars_list_rest.c \
chars_list.c \
get_input.c \
history.c \
line_nodes.c \
readline.c \
terminal_config.c
# Expansion files variable
EXPA_FILES = expand_args.c \
expand_command.c \
expand_dble_qoutes_word.c \
expand_non_qoutes_word.c \
expand_redirction.c \
expand_special_params_in_quotes.c \
expand_special_params.c \
expand_word.c \
expansion.c \
utils_continue.c \
utils.c
# Main file variable
MAIN_FILE = last_arg.c \
main.c \
minishell.c
# Define objects for all sources
OBJ_EXEC = $(addprefix $(OBJECTSDIR)/$(EXEC_FOLDER)/, $(EXEC_FILES:.c=.o))
OBJ_LEX = $(addprefix $(OBJECTSDIR)/$(LEX_FOLDER)/, $(LEX_FILES:.c=.o))
OBJ_EXPA = $(addprefix $(OBJECTSDIR)/$(EXPA_FOLDER)/, $(EXPA_FILES:.c=.o))
OBJ_PARS = $(addprefix $(OBJECTSDIR)/$(PARS_FOLDER)/, $(PARS_FILES:.c=.o))
OBJ_READ = $(addprefix $(OBJECTSDIR)/$(READ_FOLDER)/, $(READ_FILES:.c=.o))
OBJ_MAIN = $(addprefix $(OBJECTSDIR)/, $(MAIN_FILE:.c=.o))
OBJS := $(OBJ_EXEC) $(OBJ_LEX) $(OBJ_EXPA) $(OBJ_PARS) $(OBJ_READ) $(OBJ_MAIN)
LIBFT_FILE := $(LIBFT_FOLDER)/$(LIBFT_LIB)
# Name the compiler
CC = gcc
# OS specific part
RM = rm -rf
RMDIR = rm -rf
MKDIR = mkdir -p
MAKE = make -C
ECHO = /bin/echo
ERRIGNORE = 2>/dev/null
# Hide or not the calls depending of VERBOSE
ifeq ($(VERBOSE),T)
HIDE =
else
HIDE = @
endif
.PHONY: all fclean
all: credit $(NAME)
libft:
@echo "$(BLUE)█████████████████████████ Making LIBFT █████████████████████████$(RESET)"
@$(MAKE) $(LIBFT_FOLDER)
@echo "$(BLUE)███████████████████████ Making minishell ███████████████████████$(RESET)"
$(NAME): libft $(OBJS)
@$(CC) -I $(HEADERSDIR) -I $(LIBFT_FOLDER) $(OBJS) $(LIBFT_FOLDER)/$(LIBFT_LIB) $(LIBS) -o $@
@echo "$(BLUE)███████████████████████ Compiling is DONE ██████████████████████$(RESET)"
@echo " Made with love by : \033[1;91mzjamali\033[m and \033[1;91mmbari\033[m"
$(OBJECTSDIR)/%.o : $(SOURCEDIR)/%.c $(HEADERSDIR)/*.h
@$(MKDIR) $(dir $@)
@echo "$(BLUE)█ $(YELLOW)Compiling$(RESET) $<:\r\t\t\t\t\t\t\t$(GREEN){DONE}$(BLUE) █$(RESET)"
@$(CC) $(FLAGS) -I $(HEADERSDIR) -I $(LIBFT_HEADER) -o $@ -c $<
# Remove all objects, dependencies and executable files generated during the build
clean:
@echo "$(RED)deleting$(RESET): " $(OBJECTSDIR)
@$(RMDIR) $(OBJECTSDIR) $(ERRIGNORE)
@echo "$(RED)deleting$(RESET): " "libft objects"
@$(MAKE) $(LIBFT_FOLDER) clean
fclean: clean
@echo "$(RED)deleting$(RESET): " $(LIBFT_FOLDER)/$(LIBFT_LIB)
@$(RM) $(LIBFT_FOLDER)/$(LIBFT_LIB) $(ERRIGNORE)
@echo "$(RED)deleting$(RESET): " $(NAME)
@$(RM) $(NAME) $(ERRIGNORE)
re: fclean $(NAME)
credit:
@echo "███╗ ███╗██╗███╗ ██╗██╗███████╗██╗ ██╗███████╗██╗ ██╗ "
@echo "████╗ ████║██║████╗ ██║██║██╔════╝██║ ██║██╔════╝██║ ██║ "
@echo "██╔████╔██║██║██╔██╗ ██║██║███████╗███████║█████╗ ██║ ██║ "
@echo "██║╚██╔╝██║██║██║╚█f█╗██║██║╚════██║██╔══██║██╔══╝ ██║ ██║ "
@echo "██║ ╚═╝ ██║██║██║ ╚████║██║███████║██║ ██║███████╗███████╗███████╗"
@echo "╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝"
@echo " Made with love by : \033[1;91mzjamali\033[m and \033[1;91mmbari\033[m"