-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·246 lines (203 loc) · 8.07 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#*************************************************************************** #
# #
# ::: :::::::: #
# :+: :+: :+: #
# +:+ +:+ +:+ Makefile v2.0 #
# +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ By: troberts <troberts@student.42.fr> #
# #+# #+# #
# ### ########.fr #
# #
# **************************************************************************** #
# **************************************************************************** #
# VARIABLE REFERENCE #
# **************************************************************************** #
NAME= fdf
# CC= clang
CFLAGS= -Wall -Werror -Wextra -g3 $(INCLUDE) #-fsanitize=address
LDFLAGS= -L$(MLX_DIR) -L$(LIBFT_DIR) -lmlx -lXext -lX11 -lm #-fsanitize=address
DEPFLAGS= -MT $@ -MMD -MP -MF $(DEP_DIR)$*.d
INCLUDE = -I$(INCLUDE_DIR) -I$(MLX_DIR) -I$(LIBFT_DIR)
LIBFT_DIR= libft
LIBFT_LIB= $(LIBFT_DIR)/libft.a
MLX_DIR= mlx_linux
MLX_LIB= $(MLX_DIR)/libmlx_Linux.a
INCLUDE_DIR= include
OBJ_DIR= obj/
SRC_DIR= src/
DEP_DIR= dep/
# **************************************************************************** #
# .C & .H FILES #
# **************************************************************************** #
SRC_FILE= \
clean.c \
color_rgba.c \
color.c \
convert_3d.c \
draw_line.c \
draw_map.c \
error_main.c \
find_min_max.c \
handle.c \
handle2.c \
hook.c \
init.c \
main.c \
math.c \
menu.c \
parse_map_clean.c \
parse_map.c \
process_map.c \
render.c \
rotate.c \
utils.c \
utils2.c
SRC= $(addprefix $(SRC_DIR), $(SRC_FILE))
OBJ_FILE= $(SRC_FILE:.c=.o)
OBJ= $(addprefix $(OBJ_DIR), $(OBJ_FILE))
DEP_FILE= $(SRC_FILE:.c=.o)
DEP= $(addprefix $(DEP_DIR), $(DEP_FILE))
#OBJ= $(SRC:$(SRC_DIR)%.c=$(OBJ_DIR)%.o)
# **************************************************************************** #
# HEADER CONFIG #
# **************************************************************************** #
# # <-- start here | <-- middle # <-- stop here
HEADER_NAME = + FdF #
COLOR_RED = \033[0;31m
COLOR_GREEN = \033[0;32m
COLOR_YELLOW = \033[0;33m
COLOR_BLUE = \033[0;34m
COLOR_PURPLE = \033[0;35m
COLOR_CYAN = \033[0;36m
COLOR_WHITE = \033[0;37m
COLOR_END = \033[m
HEADER = @echo "${COLOR_CYAN}\
\n/* ************************************************************************** */\
\n/* */\
\n/* ::: :::::::: */\
\n/* :+: :+: :+: */\
\n/* +:+ +:+ +:${HEADER_NAME}*/\
\n/* +\#+ +:+ +\#+ */\
\n/* +\#+\#+\#+\#+\#+ +\#+ Thomas Robertson */\
\n/* \#+\# \#+\# <troberts@student.42.fr> */\
\n/* \#\#\# \#\#\#\#\#\#\#\#.fr */\
\n/* */\
\n/* ************************************************************************** */\
\n \
\n \
\n NAME: $(NAME) \
\n \
\n CC: $(CC) \
\n CFLAGS: $(CFLAGS) \
\n LDFLAGS: $(LDFLAGS) \
\n${COLOR_END}"
HEADER_COMPIL = @echo "${COLOR_YELLOW}\
\n/* ************************************************************************** */\
\n/* COMPILING... */\
\n/* ************************************************************************** */\n\
${COLOR_END}"
HEADER_CLEAN = @echo "${COLOR_RED}\
\n/* ************************************************************************** */\
\n/* CLEANING... */\
\n/* ************************************************************************** */\n\
${COLOR_END}"
HEADER_FCLEAN = @echo "${COLOR_RED}\
\n/* ************************************************************************** */\
\n/* FORCE CLEANING... */\
\n/* ************************************************************************** */\n\
${COLOR_END}"
HEADER_NORM = @echo "${COLOR_PURPLE}\
\n/* ************************************************************************** */\
\n/* CHECKING THE NORM... */\
\n/* ************************************************************************** */\n\
${COLOR_END}"
HEADER_ENTERLIB = @echo "${COLOR_GREEN}\
\n/* ************************************************************************** */\
\n/* ENTERING LIBFT */\
\n/* ************************************************************************** */\n\
${COLOR_END}"
HEADER_EXITLIB = @echo "${COLOR_GREEN}\
\n/* ************************************************************************** */\
\n/* EXITING LIB */\
\n/* ************************************************************************** */\n\
${COLOR_END}"
# **************************************************************************** #
# RULES #
# **************************************************************************** #
all: $(NAME)
$(NAME): $(LIBFT_LIB) $(MLX_LIB) $(OBJ)
$(HEADER)
$(HEADER_COMPIL)
$(CC) -o $@ $(OBJ) $(LDFLAGS) $(LIBFT_LIB)
malloc_test: $(LIBFT_LIB) $(MLX_LIB) $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -fsanitize=undefined -rdynamic -o $@ $(OBJ) $(LIBFT_LIB) $(MLX_LIB) -L. -lmallocator
bonus: $(NAME)
$(LIBFT_LIB): makelibf ;
makelibf :
$(HEADER_ENTERLIB)
@make -C $(LIBFT_DIR)
$(HEADER_EXITLIB)
$(MLX_LIB): makemlx ;
makemlx :
$(HEADER_ENTERLIB)
@make -C $(MLX_DIR)
$(HEADER_EXITLIB)
$(OBJ): | $(OBJ_DIR)
$(OBJ_DIR):
mkdir -p $@
$(OBJ): $(OBJ_DIR)%.o: $(SRC_DIR)%.c
$(CC) $(CFLAGS) -c $< -o $@
# $(DEP): | $(DEP_DIR)
#
# $(DEP_DIR):
# mkdir -p $@
#
# $(DEP): $(SRC_DIR)%.c
# $(CC) $(CFLAGS) -MM -MF $@ -MT $(OBJ_DIR)$*.o $<
#
header:
$(HEADER)
cleanobj:
${HEADER_CLEAN}
rm -f $(OBJ) $(OBJ_BONUS) $(OBJ_COMMON)
cleanobjdir: cleanobj
rm -rf $(OBJ_DIR)
clean: header cleanobjdir cleanlibft
cleanlibft:
make -C $(LIBFT_DIR) clean
make -C $(MLX_DIR) clean
fcleanlibft:
make -C $(LIBFT_DIR) fclean
fclean: header clean fcleanlibft
${HEADER_FCLEAN}
rm -f $(NAME) $(NAME_BONUS)
re: header fclean all
reobj: cleanobj
make -C .
norm: header
${HEADER_NORM}
@echo "$(COLOR_GREEN)"
-python3 -m norminette $(LIBFT_DIR) | awk "!/: OK!/"
@echo "$(COLOR_CYAN)"
-python3 -m norminette $(SRC_DIR)
@echo "$(COLOR_PURPLE)"
-python3 -m norminette $(INCLUDE_DIR)
@echo "$(COLOR_END)"
.PHONY: all clean fclean re reobj norm header makelibf cleanobj cleanobjdir fcleanlibft bonus
# include $(DEP)
# DEP_CFLAGS=-MM -MD
# ALL_CFLAGS=-I ./inc -Wall -Wextra -Werror
# src=$(wildcard *.c)
# dep=$(src:.c=.d)
#
# ... (other flags, other rules like all etc.)
#
# %.o:%.c
# $(CC) -c $< $(ALL_CFLAGS) -o $@
# %.d:%.c
# $(CC) $< $(DEP_FLAGS) $(ALL_CFLAGS) -o $@
#
# ... (other rules etc.)
#
# #This below has to be at the end of the Makefile, else it does not work
# -include $(dep)