-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
283 lines (221 loc) · 7.42 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
#####################################################
# COMPILE ###########################################
#####################################################
CC = cc
CFLAGS = -Wall -Wextra -Werror -MMD -MP
ifdef WITH_LEAKS
CFLAGS += -D LEAKS
endif
ifdef WITH_SANITIZE
CFLAGS += -g -fsanitize=address
endif
#####################################################
# PROGRAM NAME ######################################
#####################################################
NAME = miniRT
#####################################################
# SRC FILE ##########################################
#####################################################
VPATH = $(SRC_DIR) $(MINIRT_INCLUDE)
SRC_DIR = srcs
SRC = main.c
SRCS = $(addprefix $(SRC_DIR)/, $(SRC))
#----------------------------------------------------
# COLOR
COLOR_DIR = srcs/calc_color
COLOR_SRC = calc_color.c \
color_handling.c
SRC += $(addprefix $(COLOR_DIR)/, $(COLOR_SRC))
#----------------------------------------------------
# VECTOR
VECTOR_DIR = srcs/calc_vector
VECTOR_SRC = arithmetic.c \
arithmetic_ret_vec.c \
calc_vec.c \
organize_vec.c \
organize_vec_2.c
SRC += $(addprefix $(VECTOR_DIR)/, $(VECTOR_SRC))
#----------------------------------------------------
# CONSTRUCTOR
CONSTRUCTOR_DIR = srcs/constructor
CONSTRUCTOR_SRC = parse/ft_strtod.c \
parse/ft_strtol.c \
parse/get_bonus_config_of_obj.c \
parse/get_config.c \
parse/get_config_of_ambient.c \
parse/get_config_of_camera.c \
parse/get_config_of_each_obj.c \
parse/get_config_of_lights.c \
parse/get_config_of_objects.c \
parse/get_image_data_from_ppm.c \
parse/get_image_texture.c \
parse/parsing_config.c \
parse/parsing_digits.c \
parse/parsing_helper.c \
parse/parsing_id_cnt.c \
parse/parsing_ppm.c \
parse/parsing_ppm_each_line.c \
update/update_camera_config.c \
update/update_scene_config.c \
update/update_scene_config_each_obj.c \
update/update_scene_config_light.c \
validate/validate_config.c \
validate/validate_config_color.c \
validate/validate_config_light.c \
validate/validate_config_shape.c \
validate/validate_filename.c \
validate/validate_is_num.c \
validate/validate_is_struct.c \
constructor.c
SRC += $(addprefix $(CONSTRUCTOR_DIR)/, $(CONSTRUCTOR_SRC))
#----------------------------------------------------
# DEBUG
DEBUG_DIR = srcs/debug
DEBUG_SRC = print_config.c \
print_config_helper.c
SRC += $(addprefix $(DEBUG_DIR)/, $(DEBUG_SRC))
#----------------------------------------------------
# DESTRUCTOR
DESTRUCTOR_DIR = srcs/destructor
DESTRUCTOR_SRC = destructor.c
SRC += $(addprefix $(DESTRUCTOR_DIR)/, $(DESTRUCTOR_SRC))
#----------------------------------------------------
# DRAW
DRAW_DIR = srcs/draw
DRAW_SRC = draw.c
SRC += $(addprefix $(DRAW_DIR)/, $(DRAW_SRC))
#----------------------------------------------------
# MATRIX
MATRIX_DIR = srcs/matrix
MATRIX_SRC = calc_matrix.c \
is_basis_equals.c \
matrix.c
SRC += $(addprefix $(MATRIX_DIR)/, $(MATRIX_SRC))
#----------------------------------------------------
# MLX_HELPER
MLX_HELPER = srcs/mlx_helper
MLX_HELPER_SRC = mlx_pixcel_put.c \
mlx_keyhooks.c \
mlx_put_image.c
SRC += $(addprefix $(MLX_HELPER)/, $(MLX_HELPER_SRC))
#----------------------------------------------------
# MLX_HELPER
PRE_CHECK = srcs/pre_check_conflict
PRE_CHECK_SRC = conflict_ch.c \
conflict_ch_obj.c
SRC += $(addprefix $(PRE_CHECK)/, $(PRE_CHECK_SRC))
#----------------------------------------------------
# RAYTRACE
RAYTRACE_DIR = srcs/raytrace
RAYTRACE_SRC = calc_intersection/calcratio_cylinder.c \
calc_intersection/calcratio_cylinder_helper.c \
calc_intersection/calcratio_plane.c \
calc_intersection/intersection_helper.c \
calc_intersection/intersection_with_corn.c \
calc_intersection/intersection_with_corn_calc_param.c \
calc_intersection/intersection_with_sphere.c \
calc_reflection/calc_ambient_reflection.c \
calc_reflection/calc_diffuse_reflection.c \
calc_reflection/calc_diffuse_reflection_param.c \
calc_reflection/calc_perfect_reflection.c \
calc_reflection/calc_rayvec.c \
calc_reflection/calc_specular_reflection.c \
calc_reflection/get_checker_ref_color.c \
calc_reflection/get_image_ref_color.c \
calc_reflection/get_tangent_coordinate_map.c \
calc_reflection/handle_normal.c \
calc_reflection/is_condition.c \
raytrace.c
SRC += $(addprefix $(RAYTRACE_DIR)/, $(RAYTRACE_SRC))
#----------------------------------------------------
# SYS
SYS_DIR = srcs/sys
SYS_SRC = x_free.c \
x_open.c \
x_close.c
SRC += $(addprefix $(SYS_DIR)/, $(SYS_SRC))
#####################################################
# OBJECT FILE #######################################
#####################################################
OBJ_DIR = objs
OBJ = $(SRC:%.c=%.o)
OBJS = $(addprefix $(OBJ_DIR)/, $(OBJ))
DEPS = $(OBJS:%.o=%.d)
#####################################################
# OS Check ##########################################
#####################################################
UNAME = $(shell uname)
#####################################################
# INCLUDE and LIBRARY FILE ##########################
#####################################################
# ---------------------------------------------------
# LIBFT
LIBFT_DIR = libs
LIBFT = $(LIBFT_DIR)/libft.a
LIBFT_INCLUDE = $(LIBFT_DIR)/include
# ---------------------------------------------------
# MLX
MLX_DIR = minilibx-linux
# ---------------------------------------------------
# X11
X11_DIR = /usr/X11
X11_LIB = /usr/X11/lib
X11_INCLUDE = /usr/X11/include
# ---------------------------------------------------
# LIBS, LIBS_DIR ####################################
LIB_DIRS = $(LIBFT_DIR) $(MLX_DIR) $(X11_DIR) $(X11_LIB)
ifeq ($(UNAME), Darwin)
LIB_DIRS += /usr/X11R6/lib
endif
LFLAGS = $(addprefix -L, $(LIB_DIRS))
ifeq ($(UNAME), Darwin)
LIBS = -lft -lmlx_Darwin -lXext -lX11 -lm -framework OpenGL -framework AppKit
# CFLAGS += -D LEAKS
else
LIBS = -lft -lmlx -lXext -lX11 -lm
endif
# ---------------------------------------------------
# INCLUDES ##########################################
MINIRT_INCLUDE = includes
INCLUDE_DIRS = $(MINIRT_INCLUDE) $(LIBFT_INCLUDE) $(MLX_DIR) $(X11_INCLUDE)
INCLUDES = $(addprefix -I, $(INCLUDE_DIRS))
#####################################################
# RULES #############################################
#####################################################
.PHONY : all
all : $(NAME)
$(NAME) : $(OBJS)
@make -C $(LIBFT_DIR)
@make -C $(MLX_DIR)
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LIBS) $(LFLAGS)
$(OBJ_DIR)/%.o : %.c
@mkdir -p $$(dirname $@)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
.PHONY : clean
clean :
rm -rf $(OBJ_DIR)
@make clean -C $(LIBFT_DIR)
@make clean -C $(MLX_DIR)
.PHONY : fclean
fclean : clean
rm -f $(NAME)
@make fclean -C $(LIBFT_DIR)
@#make fclean -C $(MLX_DIR)
.PHONY : re
re : fclean all
.PHONY : bonus
bonus : all
.PHONY : leaks
leaks :
make re WITH_LEAKS=1
.PHONY : sani
sani :
make all WITH_SANITIZE=1
.PHONY : norm
norm :
@norminette --version
norminette $(SRC_DIR) $(MINIRT_INCLUDE) $(LIBFT_DIR)
@ if [ $$? -eq 0 ]; then \
echo "\033[32mNORMINETTE OK\033[0m"; \
fi
-include $(DEPS)