-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
212 lines (162 loc) · 6.7 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tlegrand <tlegrand@student.42lyon.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/02/12 20:46:19 by tlegrand #+# #+# #
# Updated: 2023/10/03 15:00:50 by tlegrand ### ########.fr #
# #
# **************************************************************************** #
# /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ PROJECT VARIABLES /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ #
# ============================== NAMES ============================== #
NAME = cub3D
NAME_B = cub3D_bonus
# ============================== SOURCES ============================== #
DIR_SRCS_M = srcs_m/
LST_SRCS = algo.c clear.c color.c display.c event.c math.c main.c \
parser.c extract_texture.c extract_map.c parser_utils.c \
init_game.c init_mlx.c view_update.c utils.c
SRCS_M = ${addprefix ${DIR_SRCS_M}, ${LST_SRCS}}
DIR_SRCS_PARSE = parsing/
LST_SRCS_PARSE = parser_bonus.c extract_texture_bonus.c extract_map_bonus.c parser_doors_bonus.c parser_utils_bonus.c
SRCS_PARSE = ${addprefix ${DIR_SRCS_PARSE}, ${LST_SRCS_PARSE}}
DIR_SRCS_ALGO = algo/
LST_SRCS_ALGO = algo_switch_plan_bonus.c algo_utils_bonus.c thread_bonus.c job_bonus.c job_utils_bonus.c
SRCS_ALGO = ${addprefix ${DIR_SRCS_ALGO}, ${LST_SRCS_ALGO}}
DIR_SRCS_DISP = display/
LST_SRCS_DISP = color_bonus.c display_bonus.c display_utils_bonus.c draw_bonus.c blur_bonus.c image_bonus.c \
animation_bonus.c settings_bonus.c menu_bonus.c update_igs_bonus.c doors_bonus.c image_resize_bonus.c \
color_sprite_bonus.c
SRCS_DISP = ${addprefix ${DIR_SRCS_DISP}, ${LST_SRCS_DISP}}
DIR_SRCS_INIT = init/
LST_SRCS_INIT = init_game_bonus.c init_mlx_bonus.c init_igs_bonus.c init_img_utils_bonus.c init_img_bonus.c
SRCS_INIT = ${addprefix ${DIR_SRCS_INIT}, ${LST_SRCS_INIT}}
DIR_SRCS_EVENT = move/
LST_SRCS_EVENT = event_bonus.c event_settings.c event_press_bonus.c view_update_pos_bonus.c \
view_update_dir_bonus.c move_utils.c
SRCS_EVENT = ${addprefix ${DIR_SRCS_EVENT}, ${LST_SRCS_EVENT}}
DIR_SRCS_B = srcs_bonus/
LST_SRCS_B = main_bonus.c game_bonus.c clear_bonus.c better_mlx_bonus.c math_bonus.c utils_bonus.c fps_bonus.c \
${SRCS_PARSE} ${SRCS_ALGO} ${SRCS_DISP} ${SRCS_INIT} ${SRCS_EVENT}
SRCS_B = ${addprefix ${DIR_SRCS_B}, ${LST_SRCS_B}}
# ============================== OBJECTS ============================== #
DIR_OBJS = .objs/
LST_OBJS = ${LST_SRCS:.c=.o}
OBJS = ${addprefix ${DIR_OBJS}, ${LST_OBJS}}
LST_OBJS_B = ${LST_SRCS_B:.c=.o}
OBJS_B = ${addprefix ${DIR_OBJS}, ${LST_OBJS_B}}
DIR = ${DIR_SRCS_PARSE} ${DIR_SRCS_ALGO} ${DIR_SRCS_DISP} ${DIR_SRCS_INIT} ${DIR_SRCS_EVENT}
# ============================== HEADERS ============================== #
DIR_HEADER = include/
LST_HDR = ${NAME}.h
HEADER = ${addprefix ${DIR_HEADER}, ${LST_HDR}}
LST_HDR_B = ${NAME_B}.h struct.h
HEADER_B = ${addprefix ${DIR_HEADER}, ${LST_HDR_B}}
# ============================== LIBRARY ============================== #
DIR_LIBFT = libft/
LIBFT = $(addprefix $(DIR_LIBFT), libft.a)
DIR_LIBMLX = mlx-linux/
LIBMLX = $(addprefix $(DIR_LIBMLX), libmlx.a)
# ============================== COMMANDS ============================== #
CC = cc
MKDIR = mkdir -p
RM = rm -rf
MAKE = make -s
DEBUG = no
# ============================== FLAGS ============================== #
CFLAGS = -O3 -Wall -Wextra -Werror -pthread
FTFLAGS = -L${DIR_LIBFT} -lft
MLXFLAGS = -L${DIR_LIBMLX} -lmlx -lX11 -lXext -lXfixes
DFLAGS = -g3 -fsanitize=address -fsanitize=leak -fsanitize=pointer-subtract -fsanitize=pointer-compare -fsanitize=undefined
DFLAGS_TH = -g3 -fsanitize=thread
ifeq ($(DEBUG), base)
CFLAGS += $(DFLAGS)
endif
ifeq ($(DEBUG), thread)
CFLAGS += $(DFLAGS)
endif
# /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ RULES /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ #
.PHONY : all clean fclean re bonus FORCE nn
# ============================== BASIC ============================== #
all : ${NAME}
bonus : ${NAME_B}
clean :
@${RM} ${DIR_OBJS}
@$(MAKE) -C ${DIR_LIBFT} clean
fclean : clean
@${RM} ${NAME} ${NAME_B}
@$(MAKE) -C ${DIR_LIBFT} fclean
@${MAKE} -C ${DIR_LIBMLX} clean
@printf "$(GREEN)All clean !\n$(END)"
re : fclean
@${MAKE} all
# ============================== COMPILATION ============================== #
${NAME} : ${LIBFT} ${LIBMLX} ${DIR_OBJS} ${OBJS}
@${CC} -I${DIR_HEADER} ${CFLAGS} ${OBJS} ${FTFLAGS} ${MLXFLAGS} -o ${NAME} -lm
@printf "$(GREEN_LIGHT)$@ created !\n$(END)"
${NAME_B} : ${LIBFT} ${LIBMLX} ${DIR_OBJS} ${OBJS_B}
@${CC} -I${DIR_HEADER} ${CFLAGS} ${OBJS_B} ${FTFLAGS} ${MLXFLAGS} -o ${NAME_B} -lm
@printf "$(GREEN_LIGHT)$@ created !\n$(END)"
${DIR_OBJS}%.o : ${DIR_SRCS_M}%.c ${HEADER}
@printf "$(YELLOW)Making $@...\n$(END)"
@${CC} ${CFLAGS} -c $< -o $@
${DIR_OBJS}%.o : ${DIR_SRCS_B}%.c ${HEADER_B}
@printf "$(YELLOW)Making $@...\n$(END)"
@${CC} ${CFLAGS} -c $< -o $@
# ============================== UTILS/LIB ============================== #
reb : clean_p
@${MAKE} bonus
mdebug : clean_p
@${MAKE} DEBUG=base ${NAME}
bdebug : clean_p
@${MAKE} DEBUG=base ${NAME_B}
tdebug : clean_p
@${MAKE} DEBUG=thread ${NAME_B}
nn :
@norminette $(sort ${HEADER} ${DIR_SRCS_M} ${HEADER_B} ${DIR_SRCS_B})
${DIR_OBJS} :
@${MKDIR} ${DIR_OBJS} ${addprefix ${DIR_OBJS}, ${DIR}}
$(LIBFT) : FORCE
@$(MAKE) -C ${DIR_LIBFT}
${LIBMLX} : FORCE
@$(MAKE) -C ${DIR_LIBMLX}
clean_p :
@${RM} ${DIR_OBJS}
@${RM} ${NAME}
@${RM} ${NAME_B}
FORCE :
# /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ OPERATING VARIABLES /*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\/*\ #
# ============================== COLORS ============================== #
BLACK = \033[0;30m
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[0;33m
BLUE = \033[0;34m
PURPLE = \033[0;35m
CYAN = \033[0;36m
GRAY_LIGHT = \033[0;37m
GRAY_DARK = \033[1;30m
RED_LIGHT = \033[1;31m
GREEN_LIGHT = \033[1;32m
YELLOW = \033[1;33m
BLUE_LIGHT = \033[1;34m
VIOLET = \033[1;35m
CYAN = \033[1;36m
WHITE = \033[1;37m
END = \033[0m
BOLD = \033[1m
FAINT = \033[2m
ITALIC = \033[3m
UNDERLINE = \033[4m
BLINK_SLOW = \033[5m
BLINK_FAST = \033[6m
BLINK_OFF = \033[25m
REV_V = \033[7m
CONCEAL = \033[8m
CONCEAL_OFF = \033[28m
CROSS_OUT = \033[9m
CROSS_OUT_O = \033[29m
ERASE = \033[2K
RERASE = \r\033[2K