-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·174 lines (145 loc) · 4.62 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
173
174
# Nom
NAME = 42sh
PROJECT = 42sh
# Détection de l'OS
OS = $(shell uname -s)
# Options de compilation
CC = @gcc
CFLAGS = -Wall -Werror -Wextra
ifeq ($(OS), Linux)
CFLAGSUP = -Wno-sign-compare -Wno-empty-body
else
CFLAGSUP = -Wno-sign-compare
endif
CPPFLAGS = -I $(INC_PATH) -I $(LIB_INC) -I $(LIBSUP_INC) -I $(ENV_INC) \
-I $(LINE_INC) -I $(CMP_INC) -I $(LIBSUP2_INC) -I $(ERROR_INC) -I $(PARSER_INC) -I $(HIST_INC) -I $(EXEC_INC) -I $(BUILT_INC) -I $(HERE_INC)
CLIB = -L $(EXEC) -lexec -L $(HEREDOC) -lheredoc -L $(LINE) -llinput -L $(CMP) -lcomplete -L $(PARSER) -lparser\
-L $(BUILT) -luiltins -L $(HIST) -lstory -L $(ENV) -lenv -L $(ERROR) -lerror\
-L $(LIBSUP2) -lsup2 -L $(LIBSUP) -lsup -L $(LIBFT) -lft -ltermcap
# Fichiers d'en-tête
INC_PATH = includes/
INC_FILE = sh.h
INC = $(addprefix $(INC_PATH), $(INC_FILE))
SH = SH_INC=../../$(INC_PATH)
# Fichiers sources
SRC_PATH = src/
SRC_FILE = builtin.c env.c history.c line.c local.c quotes.c sh.c signal.c tools.c ft_expand_exclam.c ft_expand_dollar.c\
ft_expand_index.c ft_expand_is.c
SRC = $(addprefix $(SRC_PATH), $(SRC_FILE))
OBJ = $(SRC:.c=.o)
# Fichiers des bibliothèques
LIBFT = libft/
LIB_INC = $(LIBFT)includes/
LIB_FT = $(LIBFT)libft.a
FT = LIBFT_INC=../../libft/includes
LIBSUP = modules/libsup/
LIBSUP_INC = $(LIBSUP)includes/
LIB_SUP = $(LIBSUP)libsup.a
SUP = LIBSUP_INC=../libsup/includes
LIBSUP2 = modules/libsup2/
LIBSUP2_INC = $(LIBSUP2)includes/
LIB_SUP2 = $(LIBSUP2)libsup2.a
SUP2 = LIBSUP2_INC=../libsup2/includes
ERROR = modules/error/
ERROR_INC = $(ERROR)/includes/
LIB_ERROR = $(ERROR)/liberror.a
ERR = ERROR_INC=../error/includes
ENV = modules/environment/
ENV_INC = $(ENV)includes/
LIB_ENV = $(ENV)libenv.a
ENVI = ENV_INC=../environment/includes
LINE = modules/line_input/
LINE_INC = $(LINE)includes/
LIB_LINE = $(LINE)liblinput.a
LIN = LINE_INC=../line_input/includes
CMP = modules/completion/
CMP_INC = $(CMP)includes/
LIB_CMP = $(CMP)libcomplete.a
COMP = CMP_INC=../completion/includes
HIST = modules/history/
HIST_INC = $(HIST)includes/
LIB_HIST = $(HIST)libstory.a
HST = HIST_INC=../history/includes
PARSER = modules/parser/
PARSER_INC = $(PARSER)/includes/
LIB_PARSER = $(PARSER)libparser.a
PARS = PARSER_INC=../parser/includes
EXEC = modules/execution/
EXEC_INC = $(EXEC)/includes/
LIB_EXEC = $(EXEC)libexec.a
XC = EXEC_INC=../execution/includes
BUILT = modules/builtins/
BUILT_INC = $(BUILT)includes/
LIB_BUILT = $(BUILT)libuiltins.a
BLT = BUILT_INC=../builtins/includes
HEREDOC = modules/heredocs/
HERE_INC = $(HEREDOC)includes/
LIB_HERE = $(HEREDOC)libheredoc.a
HRD = HERE_INC=../heredocs/includes
# Règles de compilation
all: lib $(NAME)
$(NAME): Makefile $(LIB_FT) $(LIB_SUP) $(LIB_SUP2) $(LIB_ERROR) $(LIB_ENV) $(LIB_HIST) \
$(LIB_LINE) $(LIB_CMP) $(LIB_PARSER) $(LIB_EXEC) $(LIB_BUILT) $(LIB_HERE) $(OBJ)
@echo "$(CYAN)Compilation de $(NAME)$(RESET)"
@$(CC) $(CFLAGS) $(CPPFLAGS) $(CFLAGSUP) $(OBJ) $(CLIB) -o $(NAME)
@rm -rf $(NAME).dSYM
$(OBJ): $(INC)
lib:
@echo "$(VERT)Compilation...$(RESET)"
@make -C $(LIBFT) all
@make -C $(LIBSUP) $(FT) all
@make -C $(LIBSUP2) $(FT) all
@make -C $(ERROR) $(FT) all
@make -C $(ENV) $(FT) $(SUP) $(ERR) all
@make -C $(CMP) $(FT) $(SUP) $(ERR) all
@make -C $(HIST) $(FT) $(SUP) $(ERR) all
@make -C $(PARSER) $(FT) $(SUP2) $(ERR) all
@make -C $(EXEC) $(SUP) $(FT) $(PARS) $(SUP2) $(ERR) $(ENVI) $(BLT) $(HST) $(HRD) all
@make -C $(LINE) $(FT) $(SUP) $(ENVI) $(COMP) $(ERR) $(HRD) all
@make -C $(HEREDOC) $(FT) $(SUP) $(HST) $(ENVI) $(LIN) $(COMP) $(ERR) all
@make -C $(BUILT) $(FT) $(SUP) $(ENVI) $(HST) $(ERR) $(XC) $(PARS) $(SUP2) $(SH) all
clean: cleanproj
@make -C $(LIBFT) clean
@make -C $(LIBSUP) clean
@make -C $(LIBSUP2) clean
@make -C $(ERROR) clean
@make -C $(ENV) clean
@make -C $(CMP) clean
@make -C $(HIST) clean
@make -C $(PARSER) clean
@make -C $(EXEC) clean
@make -C $(LINE) clean
@make -C $(BUILT) clean
@make -C $(HEREDOC) clean
fclean: fcleanproj
@make -C $(LIBFT) fclean
@make -C $(LIBSUP) fclean
@make -C $(LIBSUP2) fclean
@make -C $(ERROR) fclean
@make -C $(ENV) fclean
@make -C $(CMP) fclean
@make -C $(HIST) fclean
@make -C $(PARSER) fclean
@make -C $(EXEC) fclean
@make -C $(LINE) fclean
@make -C $(BUILT) fclean
@make -C $(HEREDOC) fclean
re: fclean all
cleanproj:
@echo "$(ROUGEC)Suppression des fichiers objets de $(NAME)$(RESET)"
@rm -f $(OBJ)
fcleanproj: cleanproj
@echo "$(ROUGEC)Suppression de l'exécutable $(NAME)$(RESET)"
@rm -f $(NAME)
# Couleurs
RESET = \033[0m
BLANC = \033[37m
BLEU = \033[34m
CYAN = \033[36m
JAUNE = \033[33m
MAGEN = \033[35m
NOIR = \033[30m
ROUGE = \033[31m
ROUGEC = \033[1;31m
VERT = \033[32m
.PHONY: all lib clean fclean re doxygen cleandoxy