-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
194 lines (172 loc) · 4.47 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: ple-stra <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/01/29 15:36:23 by ple-stra #+# #+# #
# Updated: 2024/03/04 15:04:18 by ple-stra ### ########.fr #
# #
# **************************************************************************** #
NAME = miniRT
SRCS_DIR = srcs
SRCS = $(addsuffix .c, \
main \
$(addprefix common/, \
basic_utils \
clear_mrt \
errors \
print_progress \
) \
$(addprefix engine/, \
$(addprefix engine_helpers/, \
color_helpers \
cylinder_normal \
object_normal \
precompute_basics \
ray_helpers \
viewport_helpers \
) \
$(addprefix intersections/, \
intersections_cylinder_register \
intersections_cylinder \
intersections_plane \
intersections_sphere \
intersections \
) \
draw_frame \
draw_test_card_f \
lighting \
) \
$(addprefix parsing/, \
parsing \
parsing_helpers \
parsing_helpers_color \
parsing_helpers_vectors \
parse_bonus_args \
parse_light \
parse_camera \
parse_sphere \
parse_plane \
parse_cylinder \
) \
$(addprefix img_helpers/, \
img_garbage \
img_helpers \
) \
$(addprefix mlx_helpers/, \
basic_mlx_helpers \
open_window \
key_events \
mouse_events \
special_events \
) \
$(addprefix object_helpers/, \
camera_helpers \
object_getters \
object_helpers \
object_lists \
object_modifiers \
) \
$(addprefix math_helpers/, \
angle_helpers \
matrix_helpers \
quadratic \
vec3_basics \
vec3_products \
) \
)
BUILD_DIR = build
OBJ_DIR = $(BUILD_DIR)/objs
OBJ = $(addprefix $(OBJ_DIR)/, $(SRCS:.c=.o))
INC = -I./includes -I./$(LIBFT_DIR)/includes -I./$(MLX_DIR) -I./
LIBFT_DIR = libft
LIBFT = $(LIBFT_DIR)/build/libft.a
LIBFT_FLAGS = -L$(LIBFT_DIR)/build -lft
MLX_DIR = minilibx
ifeq ($(shell uname), Linux)
MLX = $(MLX_DIR)/libmlx_Linux.a
MLX_FLAGS = -L$(MLX_DIR) -lmlx_Linux \
-L/usr/lib -L/usr/X11/lib -lXext -lX11 -lm
else
MLX = $(MLX_DIR)/libmlx_Darwin.a
MLX_FLAGS = -L$(MLX_DIR) -lmlx_Darwin \
-L/usr/lib -L/usr/X11/lib -lXext -lX11 -lm
endif
CC = cc
CFLAGS = -Wall -Wextra
LFLAGS = $(LIBFT_FLAGS) $(MLX_FLAGS)
ifneq (bonus, $(filter bonus,$(MAKECMDGOALS)))
ifneq (rebonus, $(filter rebonus,$(MAKECMDGOALS)))
CFLAGS += -D IS_BONUS=0
endif
endif
ifneq (nWerror, $(filter nWerror,$(MAKECMDGOALS)))
CFLAGS += -Werror
endif
ifeq (sanitize, $(filter sanitize,$(MAKECMDGOALS)))
CFLAGS += -fsanitize=address
endif
ifeq (g3, $(filter g3,$(MAKECMDGOALS)))
CFLAGS += -g3
endif
ifeq (debug, $(filter debug,$(MAKECMDGOALS)))
CFLAGS += -D KDEBUG=1
endif
ifeq (O3, $(filter O3,$(MAKECMDGOALS)))
CFLAGS += -O3
endif
GIT_SUBM = $(shell \
sed -nE 's/path = +(.+)/\1\/.git/ p' .gitmodules | paste -s -)
RM = rm -rf
all : $(NAME)
bonus : all
$(OBJ_DIR)/%.o: $(SRCS_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(INC) -c $< -o $@
$(GIT_SUBM): %/.git: .gitmodules
@git submodule init
@git submodule update $*
$(LIBFT) :
ifeq (,$(wildcard $(LIBFT)))
@echo "building libft..."
@$(MAKE) -sC $(LIBFT_DIR) all
endif
rmlibft :
@echo "deleting libft build..."
@$(MAKE) -sC $(LIBFT_DIR) fclean
$(MLX) :
ifeq (,$(wildcard $(MLX)))
@echo "building mlx..."
@$(MAKE) -sC $(MLX_DIR) all
endif
rmmlx :
@echo "deleting mlx build..."
@$(MAKE) -sC $(MLX_DIR) clean
$(NAME) : $(GIT_SUBM) $(LIBFT) $(MLX) $(OBJ)
$(CC) $(CFLAGS) $(INC) -o $(NAME) $(OBJ) $(LFLAGS)
clean :
$(RM) $(OBJ_DIR)
$(RM) $(OBJBNS_DIR)
fclean :
$(RM) $(BUILD_DIR)
$(RM) $(NAME)
fcleanall : rmlibft rmmlx
$(RM) $(BUILD_DIR)
$(RM) $(NAME)
re : fclean all
rebonus : fclean bonus
nWerror :
@echo "WARN: Compiling without Werror flag!"
sanitize :
@echo "WARN: Compiling with fsanitize flag!"
g3 :
@echo "WARN: Compiling with g3 flag!"
debug :
@echo "WARN: debug is enabled"
O3 :
@echo "WARN: O3 is enabled"
.PHONY: \
all bonus clean fclean fcleanall re rmlibft rmmlx\
nWerror sanitize debug g3 O3