This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
134 lines (105 loc) · 3.64 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: rgramati <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/08/06 21:19:50 by kiroussa #+# #+# #
# Updated: 2024/04/27 19:47:43 by rgramati ### ########.fr #
# #
# **************************************************************************** #
NAME = miniRT
DEBUG ?= 0
BUILD_DIR = build
SRC = error/rt_err.c \
error/rt_errd.c \
error/rt_error_print.c \
error/rt_ok.c \
parse/scene/rt_parse_line.c \
parse/scene/rt_parse_scene.c \
parse/rt_parse_error.c \
render/color/rt_color.c \
render/color/rt_color_argb.c \
render/debug/rt_ray_debugger.c \
render/objects/rt_obj_box.c \
render/objects/rt_obj_camera.c \
render/objects/rt_obj_cone.c \
render/objects/rt_obj_quad.c \
render/objects/rt_obj_cylinder.c \
render/objects/rt_obj_light.c \
render/objects/rt_obj_plane.c \
render/objects/rt_obj_sphere.c \
render/rt_colors.c \
render/rt_hooks.c \
render/rt_rays.c \
render/rt_render.c \
render/rt_rendering.c \
scene/rt_objects_init.c \
scene/rt_scene_free.c \
scene/rt_scene_init.c \
scene/rt_scene_transform.c \
main.c
SRC_DIR = src
SRC := $(addprefix $(SRC_DIR)/, $(SRC))
OBJ_DIR = $(BUILD_DIR)/obj
OBJ = $(subst $(SRC_DIR)/,,$(SRC:.c=.o))
OBJ := $(addprefix $(OBJ_DIR)/, $(OBJ))
INCLUDE_DIR = include
MLX_DIR = third-party/MacroLibX
MLX = $(MLX_DIR)/libmlx.so
LIBFT_DIR = third-party/libft
LIBFT = $(LIBFT_DIR)/libft.so
CC = clang
CFLAGS = -Wall -Wextra -Werror
ifeq ($(FUNMODE), 1)
CFLAGS += -O3
endif
COPTS = -I $(INCLUDE_DIR) -I $(MLX_DIR)/$(INCLUDE_DIR)s -I $(LIBFT_DIR)/$(INCLUDE_DIR)
LDFLAGS = -lSDL2 -lm
ifeq ($(DEBUG), 1)
CFLAGS += -gdwarf-4 -g3
LDFLAGS += -rdynamic
endif
MAKE_CMD = make
RM = rm -rf
VALGRIND = valgrind
VALGRIND_OPTS = --suppressions=$(MLX_DIR)/valgrind.supp --leak-check=full --show-leak-kinds=all --track-origins=yes -q
VALGRIND_PROGRAM_ARGS = ./scenes/valid/minimalist.rt
#
# Rules
#
all: $(NAME)
$(NAME): $(LIBFT) $(MLX) $(OBJ)
$(CC) $(CFLAGS) $(COPTS) -o $(NAME) $(OBJ) $(LIBFT) $(MLX) $(LDFLAGS)
bonus: COPTS += -DMINIRT_BONUS
bonus: remake
rt: COPTS += -DRT_MODE
rt: remake
$(NAME_BONUS): $(LIBFT) $(MLX) $(OBJ_BONUS)
$(CC) $(CFLAGS) $(COPTS) -o $(NAME_BONUS) $(OBJ_BONUS) $(LIBFT) $(MLX) $(LDFLAGS)
$(LIBFT):
$(MAKE_CMD) -j -C $(LIBFT_DIR) CFLAGS="$(CFLAGS)" all DEBUG="$(DEBUG)"
$(MLX):
ifeq ($(DEBUG), 1)
$(MAKE_CMD) -j -C $(MLX_DIR) DEBUG="true" all
else
$(MAKE_CMD) -j -C $(MLX_DIR) all
endif
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(COPTS) -c $< -o $@
remake: oclean all
valgrind:
$(VALGRIND) $(VALGRIND_OPTS) ./$(NAME) $(VALGRIND_PROGRAM_ARGS)
clean: oclean
make -C $(LIBFT_DIR) clean
make -C $(MLX_DIR) clean
oclean:
$(RM) $(OBJ_DIR)
fclean: clean
make -C $(LIBFT_DIR) fclean
make -C $(MLX_DIR) fclean
$(RM) $(NAME) $(NAME_BONUS)
re: fclean all
.PHONY: all bonus clean oclean fclean remake re