-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
102 lines (79 loc) · 3.08 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mreymond <mreymond@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/10/11 12:17:38 by dfarhi #+# #+# #
# Updated: 2022/11/09 17:32:22 by dfarhi ### ########.fr #
# #
# **************************************************************************** #
FILES = minirt
FILES_D = mlx_setup mlx_utils colors_utils render_loop render_camera_ray \
math_utils render_setup render_sphere render_per_pixel \
render_plane render_cylinder render_cylinder_utils vector_op1 \
vector_op2 vector_op3 render_antialiasing time multithreading multithreading_utils thread
FILES_M = parsing parsing_setup parsing_tab parsing_volumes errors free \
display parsing_utils parsing_range render_lights render_shadows \
lights_combinations lights_utils render_lights_types parsing_lights \
parsing_volumes_param
FILES := $(FILES) $(FILES_D) $(FILES_M)
FILES := $(addprefix src/, ${FILES})
FILES := $(addsuffix .c, ${FILES})
OBJS = ${FILES:.c=.o}
NAME = miniRT
CC = gcc -Wall -Wextra -Werror
INCLUDES = -I./includes -I./libft/includes
LIB = -L./libft/ -lft -lm -pthread
LIBFT = libft/libft.a
LIBFT_ARGS =
MINILIBX_V =
MINILIBX =
SYSTEM = $(shell uname -s)
ifeq ($(SYSTEM), Linux)
MINILIBX_V = minilibx_linux
MINILIBX = $(MINILIBX_V)/libmlx.a
LIB := $(LIB) -L./$(MINILIBX_V) -lmlx -lXext -lX11
else
INCLUDES := ${INCLUDES} -D MACOS
MINILIBX_V = minilibx_macos
MINILIBX = $(MINILIBX_V)/libmlx.a
LIB := $(LIB) -framework OpenGL -framework AppKit -L./$(MINILIBX_V) -lmlx
endif
INCLUDES := $(INCLUDES) -I./$(MINILIBX_V)
ifndef T
T := $(shell getconf _NPROCESSORS_ONLN)
endif
INCLUDES := $(INCLUDES) -D THREAD_N=$(T)
${NAME}: ${LIBFT} ${OBJS} ${MINILIBX}
${CC} ${INCLUDES} -o ${NAME} ${OBJS} ${LIB}
.c.o:
${CC} -c ${INCLUDES} $< -o ${<:.c=.o}
all: ${NAME}
${MINILIBX}:
$(MAKE) -C ./$(MINILIBX_V)
AddressSanitizer: CC := ${CC} -fsanitize=address -g
ifeq ($(SYSTEM), Linux)
AddressSanitizer: CC := ${CC} -static-libasan
endif
AddressSanitizer: LIBFT_ARGS := ${LIBFT_ARGS} ADDRESS_SANITIZER=1
AddressSanitizer: ${NAME}
# cmd to prof code:
# gprof ${NAME} gmon.out > analysis.txt
profile: fclean
profile: CC := ${CC} -pg
profile: LIBFT_ARGS := ${LIBFT_ARGS} PROFILE=1
profile: ${NAME}
${LIBFT}:
$(MAKE) -C ./libft expanded get-next-line ${LIBFT_ARGS}
git:
git submodule update --init --recursive
clean:
rm -f ${OBJS}
make -C ./libft clean
make -C ./$(MINILIBX_V) clean
fclean: clean
rm -f ${NAME} libft/libft.a
re: fclean all
.PHONY: all clean fclean re