-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
249 lines (212 loc) · 9.13 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
247
248
249
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: sadoming <sadoming@student.42barcel> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/09/27 17:07:32 by sadoming #+# #+# #
# Updated: 2024/02/08 19:52:45 by sadoming ### ########.fr #
# #
# **************************************************************************** #
NAME = so_long
BONUS = so_long_bonus
MAP = ./maps/sadoming_map.ber
# ------------------ #
# Flags:
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g -I mlx
FML = -framework OpenGL -framework AppKit
# ------------------ #
# Directories:
DIR = ./src
DIRB = ./bonus
TEST = ./Tests
LIBFT = ./Libft
MLX = ./mlx
# ------------------- #
# Sorces:
MAK = Makefile
ARL = $(LIBFT)/libft.a
ARML = $(MLX)/libmlx.a
LIB = so_long.h so_long_structs.h
SRC = so_long_main ft_check_file ft_check_map_sol ft_man_struc\
ft_print_map_t ft_start ft_paint_map ft_game ft_exitgame
LIBB = so_long_bonus.h so_long_structs_bonus.h
SRCB = so_long_main_bonus ft_check_file_bonus ft_check_map_sol_bonus ft_man_struc_bonus\
ft_start_bonus ft_print_map_t_bonus ft_paint_map_bonus ft_paint_act_map_bonus\
ft_start_enemy_bonus ft_game_bonus ft_text_bonus ft_anim_keys_bonus\
ft_anim_player_bonus ft_anim_enemy_bonus ft_animate_bonus\
ft_move_enemys_bonus ft_lose_game_bonus ft_win_game_bonus ft_exitgame_bonus
OBJ = $(addprefix $(DIR)/, $(addsuffix .o, $(SRC)))
OBJB = $(addprefix $(DIRB)/, $(addsuffix .o, $(SRCB)))
# ******************************************************************************* #
#-------------------------------------------------------------#
all: $(NAME)
bonus: $(BONUS)
#-------------------------------------------------------------#
#-------------------------------------------------------------#
help:
@echo "\033[1;37m\n ~ Posible comands:\n"
@echo "\t~ all \t\t #-> Make $(NAME)\n"
@echo "\t~ bonus \t #-> Make $(BONUS)\n"
@echo "\t~ clean \t #-> Clean *.o\n"
@echo "\t~ fclean \t #-> Clean all\n"
@echo "\t~ clear \t #-> Clean all & clear\n"
@echo "\t~ norm \t\t #-> Run norminette\n"
@echo "\t~ trueall \t #-> Make norm + make so_long & so_long_bonus + make run + make run_bonus\n"
@echo "\t~ leaks \t #-> Run so_long with LEAKS & $(MAP)\n"
@echo "\t~ leaks_bonus \t #-> Run so_long_bonus with LEAKS & $(MAP)\n"
@echo "\t~ run \t\t #-> Run so_long with $(MAP)\n"
@echo "\t~ run_bonus \t #-> Run so_long_bonus with $(MAP)\n"
@echo "\t~ test \t\t #-> Test so_long with LEAKS & error_maps\n"
@echo "\t~ test_bonus \t #-> Test so_long_bonus with LEAKS & error_maps\n"
@echo "\t~ re \t\t #-> Redo so_long\n"
@echo "\t~ re_bonus \t #-> Redo bonus\n"
@echo "\t~ re_trueall \t #-> Redo & make trueall\n"
@echo "\n~ Extra comands:\n"
@echo "\t~ debug \t #-> Ejecutes lldb $(NAME) $(MAP)\n"
@echo "\t~ debug_bonus \t #-> Ejecutes lldb $(BONUS) $(MAP)\n"
@echo "\t~ leaks \t #-> Ejecutes leaks $(NAME) $(MAP)\n"
@echo "\t~ leaks_bonus \t #-> Ejecutes leaks $(BONUS) $(MAP)\n"
@echo "\t~ val \t\t #-> Run Valgrind $(NAME) $(MAP)\n"
@echo "\t~ val_bonus \t #-> Run valgrind $(BONUS) $(MAP)\n"
@make -s author
#-------------------------------------------------------------#
#-------------------------------------------------------------#
author:
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo "\n ~ \t Made by Sadoming \t ~\n"
@echo "\n~ **************************************** ~\n\n"
#-------------------------------------------------------------#
#-------------------------------------------------------------#
trueall:
@make -s norm
@echo "\033[0;37m\n~ **************************************** ~\n"
@make -s $(NAME)
@make -s $(BONUS)
@make -s run
@make -s run_bonus
#-------------------------------------------------------------#
norm:
@make -s norm -C $(LIBFT)
@echo "\n\033[1;93m~ Norminette:"
@norminette $(DIR)
@norminette -R CheckForbiddenSourceHeader $(DIR)
@echo "\033[1;32m\n ~ Norminette:\t~ OK"
@echo "\n\033[1;93m~ Norminette bonus:"
@norminette $(DIRB)
@norminette -R CheckForbiddenSourceHeader $(DIRB)
@echo "\033[1;32m\n ~ Norminette bonus:\t~ OK"
#-------------------------------------------------------------#
#-------------------------------------------------------------#
run: $(NAME)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(NAME) $(MAP)"
@echo "\n~ **************************************** ~\n"
@./$(NAME) $(MAP)
#-------------------------------------------------------------#
run_bonus: $(BONUS)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(BONUS) $(MAP)"
@echo "\n~ **************************************** ~\n"
@./$(BONUS) $(MAP)
#-------------------------------------------------------------#
#-------------------------------------------------------------#
# Test Region:
test: $(NAME)
@make -s leaks -C $(TEST)
test_bonus: $(BONUS)
@make -s leaks_bonus -C $(TEST)
#-------------------------------------------------------------#
#-------------------------------------------------------------#
# ******************************************************************************* #
# Compiling Region:
$(ARML):
@echo "\033[1;93m\n * Compiling MiniLibX -->\033[1;97m\n"
@make -s -C $(MLX)
$(ARL):
@echo "\033[1;93m\n * Compiling Libft -->\033[1;97m\n"
@make -s -C $(LIBFT)
@echo "\033[1;37m\n~ **************************************** ~\n"
$(DIR)/%.o : $(DIR)/%.c ./src/$(LIB)
$(CC) $(CFLAGS) -c $< -o $@
#-------------------------------------------------------------#
$(NAME): $(MAK) $(ARML) $(ARL) $(OBJ)
@echo "\033[1;37m\n~ **************************************** ~\n"
@echo "\033[1;93m * Making so_long -->\033[1;97m\n"
@$(CC) $(ARML) $(ARL) $(OBJ) $(FML) -L mlx -l mlx -o $(NAME)
@echo "\033[1;35m\n~ **************************************** ~\n"
@echo " ~\t So_Long is ready!\t\t ~\n"
@echo "~ **************************************** ~\n"
#-------------------------------------------------------------#
# Bonus:
$(DIRB)/%.o : $(DIRB)/%.c $(DIRB)/$(LIBB)
$(CC) $(CFLAGS) -c $< -o $@
$(BONUS): $(MAK) $(ARML) $(ARL) $(OBJB)
@echo "\033[1;37m\n~ **************************************** ~\n"
@echo "\033[1;93m * Making so_long bonus -->\033[1;97m\n"
@$(CC) $(ARML) $(ARL) $(OBJB) $(FML) -L mlx -l mlx -o $(BONUS)
@echo "\033[1;35m\n~ **************************************** ~\n"
@echo " ~\t So_Long Bonus is ready!\t ~\n"
@echo "~ **************************************** ~\n"
#-------------------------------------------------------------#
# ******************************************************************************* #
# Debuging region:
debug: $(NAME)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(NAME) $(MAP)"
@echo "\n~ **************************************** ~\n"
@lldb $(NAME) $(MAP)
debug_bonus: $(BONUS)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(BONUS) $(MAP)"
@echo "\n~ **************************************** ~\n"
@lldb $(BONUS) $(MAP)
# ------------------
leaks: $(NAME)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(NAME) $(MAP)"
@echo "\n~ **************************************** ~\n"
@leaks -atExit -- ./$(NAME) $(MAP)
leaks_bonus: $(BONUS)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(BONUS) $(MAP)"
@echo "\n~ **************************************** ~\n"
@leaks -atExit -- ./$(BONUS) $(MAP)
# ------------------
val: $(NAME)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(NAME) $(MAP)"
@echo "\n~ **************************************** ~\n"
@valgrind ./$(NAME) $(MAP)
val_bonus: $(BONUS)
@echo "\033[1;34m\n~ **************************************** ~\n"
@echo " ~ Running ./$(BONUS) $(MAP)"
@echo "\n~ **************************************** ~\n"
@valgrind ./$(BONUS) $(MAP)
# ********************************************************************************* #
# Clean region
clean:
@make -s clean -C $(MLX)
@make -s clean -C $(LIBFT)
@/bin/rm -f $(OBJ)
@/bin/rm -f $(OBJB)
@find . -name ".DS_Store" -type f -delete
@echo "\033[1;34m\n All obj removed\033[1;97m\n"
fclean: clean
@make -s fclean -C $(LIBFT)
@/bin/rm -f $(NAME)
@/bin/rm -f $(BONUS)
@/bin/rm -frd so_long.dSYM
@/bin/rm -frd so_long_bonus.dSYM
@echo "\033[1;34m All cleaned succesfully\033[1;97m\n"
clear: fclean
@clear
re: fclean all
re_bonus: fclean bonus
re_trueall: clear trueall
# -------------------- #
.PHONY: all bonus clean clear fclean debug leaks norm re run val trueall
.PHONY: debug_bonus leaks_bonus re_bonus re_trueall val_bonus
# ********************************************************************************** #