-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
170 lines (119 loc) · 4.95 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: amouflet <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/01/24 09:55:07 by amouflet #+# #+# #
# Updated: 2023/02/02 14:38:54 by amouflet ### ########.fr #
# #
# **************************************************************************** #
NAME = so_long
################################################################################
# #
# #
# SOURCES #
# #
# #
################################################################################
MAP = map_tab.c \
map_lst.c \
map_utils.c \
map_check_format.c \
map_check_gameplay.c
INIT_END = open_window.c \
close_window.c
DISPLAY = image.c \
init_images.c
HOOK = manage_hook.c
M = mandatory.c
B = bonus.c
################################################################################
# #
# #
# VARIABLES #
# #
# #
################################################################################
SRC_DIR = srcs/
MAP_DIR = map/
DISPLAY_DIR = display/
INIT_END_DIR = init_end/
HOOK_DIR = hook/
M_DIR = mandatory/
B_DIR = bonus/
SRC = $(addprefix $(MAP_DIR), $(MAP))
SRC += $(addprefix $(INIT_END_DIR), $(INIT_END))
SRC += $(addprefix $(DISPLAY_DIR), $(DISPLAY))
SRC += $(addprefix $(HOOK_DIR), $(HOOK))
SRC_B = $(addprefix $(B_DIR), $(B))
SRC_M = $(addprefix $(M_DIR), $(M))
OBJ_M = $(addprefix $(BUILD), $(SRC_M:.c=.o))
OBJ_B = $(addprefix $(BUILD), $(SRC_B:.c=.o))
OBJ = $(addprefix $(BUILD), $(SRC:.c=.o))
DEPS = $(OBJ:.o=.d)
BUILD = .build/
CC = cc
CFLAGS = -Wall -Werror -Wextra -MMD -MP -g
LIB_MLX = minilibx-linux/libmlx.a
LIB_MLX += minilibx-linux/libmlx_Linux.a
LIBFT_A = libft/libft.a
LFT = -lft
LMLX = -lmlx
LMLX += -lmlx_Linux
L = -lXext -lX11 -lm -lz
INCL = -I./includes/
INCL += -I./libft/includes/
INCL += -I./minilibx-linux/
DIRS = $(addprefix $(BUILD), $(INIT_END_DIR))
DIRS += $(addprefix $(BUILD), $(MAP_DIR))
DIRS += $(addprefix $(BUILD), $(M_DIR))
DIRS += $(addprefix $(BUILD), $(B_DIR))
DIRS += $(addprefix $(BUILD), $(HOOK_DIR))
DIRS += $(addprefix $(BUILD), $(DISPLAY_DIR))
################################################################################
# #
# #
# RULES #
# #
# #
################################################################################
all: $(NAME)
$(BUILD):
@mkdir .build
$(addprefix $(BUILD), $(MAP_DIR)):
@mkdir $@
$(addprefix $(BUILD), $(INIT_END_DIR)):
@mkdir $@
$(addprefix $(BUILD), $(DISPLAY_DIR)):
@mkdir $@
$(addprefix $(BUILD), $(HOOK_DIR)):
@mkdir $@
$(addprefix $(BUILD), $(M_DIR)):
@mkdir $@
$(addprefix $(BUILD), $(B_DIR)):
@mkdir $@
$(BUILD)%.o: $(SRC_DIR)%.c
$(CC) $(CFLAGS) -c $< -o $@ $(INCL)
$(LIBFT_A): mlibft
mlibft:
@make -C libft/
$(LIB_MLX): mlibmlx
mlibmlx:
@make -C minilibx-linux/
$(NAME): Makefile $(BUILD) $(DIRS) $(OBJ) $(OBJ_M) $(LIBFT_A) $(LIB_MLX)
$(CC) $(OBJ) $(OBJ_M) -o $(NAME) $(L) -L./minilibx-linux/ $(LMLX) -L./libft/ $(LFT)
bonus: Makefile $(BUILD) $(DIRS) $(OBJ) $(OBJ_B) $(LIBFT_A) $(LIB_MLX)
$(CC) $(OBJ) $(OBJ_B) -o $(NAME) $(L) -L./minilibx-linux/ $(LMLX) -L./libft/ $(LFT)
clean:
@make clean -C minilibx-linux/
@make clean -C libft/
@rm -rf $(BUILD)
@rm -f $(LIBS)
fclean: clean
@make fclean -C libft/
rm -f $(NAME)
re: fclean all
.PHONY: all re clean fclean mlibft mlibmlx create_map_dir create_build
-include $(DEPS)