-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (107 loc) · 4.28 KB
/
Makefile
File metadata and controls
133 lines (107 loc) · 4.28 KB
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
NAME = miniRT
LIB = libft.a
CC = cc
CFLAGS = -Wall -Wextra -Werror -g
TESTING_FLAGS = -g
RM = rm -rf
FILES = main log_error miniRT_data
PARSER_FILES = parse_scene validation_scene parse_helpers validate_helpers \
get_rgb get_coords shape parse_shape\
parse_ambient_light parse_camera parse_light parse_sphere parse_plane parse_cylinder \
log_parsed_data
IMG_FILES = create_win win_events img_data translation_events
VEC_OPS_FILES = basic_vector_ops get_vec_length normalize_vector copy_vector scale_vector \
cross_product inverse_matrix
SDF_FILES = sd_selector
RAY_TRACE_FILES = trace_ray matrix intersection color \
precompute_data cylinder_intersection normal
SRC_DIR = src
PARSER_DIR = parser
IMG_DIR = image
VEC_OPS_DIR = vector_ops
SDF_DIR = sd_functions
RAY_TRACE_DIR = ray_tracing
MINILIBX_DIR = minilibx-linux
LINKED_OBJS = obj
SRC = $(addsuffix .c, $(FILES))
PARSER_SRC = $(addprefix $(PARSER_DIR)/, $(addsuffix .c, $(PARSER_FILES)))
IMG_SRC = $(addprefix $(IMG_DIR)/, $(addsuffix .c, $(IMG_FILES)))
VEC_OPS_SRC = $(addprefix $(VEC_OPS_DIR)/, $(addsuffix .c, $(VEC_OPS_FILES)))
SDF_SRC = $(addprefix $(SDF_DIR)/, $(addsuffix .c, $(SDF_FILES)))
RAY_TRACE_SRC = $(addprefix $(RAY_TRACE_DIR)/, $(addsuffix .c, $(RAY_TRACE_FILES)))
SRCS = $(addprefix $(SRC_DIR)/, $(SRC))
PARSER_SRCS = $(addprefix $(SRC_DIR)/, $(PARSER_SRC))
IMG_SRCS = $(addprefix $(SRC_DIR)/, $(IMG_SRC))
VEC_OPS_SRCS = $(addprefix $(SRC_DIR)/, $(VEC_OPS_SRC))
SDF_SRCS = $(addprefix $(SRC_DIR)/, $(SDF_SRC))
RAY_TRACE_SRCS = $(addprefix $(RAY_TRACE_DIR)/, $(RAY_TRACE_SRC))
OBJS = $(addprefix $(LINKED_OBJS)/, $(addsuffix .o, $(FILES)))
PARSER_OBJS = $(addprefix $(LINKED_OBJS)/, $(addsuffix .o, $(PARSER_FILES)))
IMG_OBJS = $(addprefix $(LINKED_OBJS)/, $(addsuffix .o, $(IMG_FILES)))
VEC_OPS_OBJS = $(addprefix $(LINKED_OBJS)/, $(addsuffix .o, $(VEC_OPS_FILES)))
SDF_OBJS = $(addprefix $(LINKED_OBJS)/, $(addsuffix .o, $(SDF_FILES)))
RAY_TRACE_OBJS = $(addprefix $(LINKED_OBJS)/, $(addsuffix .o, $(RAY_TRACE_FILES)))
ALL_OBJS = $(OBJS) $(PARSER_OBJS) $(IMG_OBJS) $(VEC_OPS_OBJS) $(SDF_OBJS) $(RAY_TRACE_OBJS)
# COLORS
BLACK:="\033[1;30m"
RED:="\033[1;31m"
GREEN:="\033[1;32m"
PURPLE:="\033[1;35m"
CYAN:="\033[1;36m"
WHITE:="\033[1;37m"
EOC:="\033[0;0m"
%.o : %.c
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) -I/usr/include -Imlx_linux -O3 $< -o $@
all: submodule $(NAME)
@echo $(GREEN) "OK COMPILED" $(EOC)
testing: CFLAGS = $(TESTING_FLAGS)
testing: submodule $(NAME)
@echo $(RED) "WARNING: COMPILED WITHOUT MANDATORY FLAGS" $(EOC)
submodule:
@git submodule update --init
@$(MAKE) -C $(MINILIBX_DIR) -s
$(LINKED_OBJS)/%.o: $(SRC_DIR)/%.c
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) $< -o $@
$(LINKED_OBJS)/%.o: $(SRC_DIR)/$(PARSER_DIR)/%.c
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) $< -o $@
$(LINKED_OBJS)/%.o: $(SRC_DIR)/$(IMG_DIR)/%.c
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) $< -o $@
$(LINKED_OBJS)/%.o: $(SRC_DIR)/$(VEC_OPS_DIR)/%.c
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) $< -o $@
$(LINKED_OBJS)/%.o: $(SRC_DIR)/$(SDF_DIR)/%.c
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) $< -o $@
$(LINKED_OBJS)/%.o: $(SRC_DIR)/$(RAY_TRACE_DIR)/%.c
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@mkdir -p $(LINKED_OBJS)
@$(CC) -c $(CFLAGS) $< -o $@
$(LIB):
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@$(MAKE) -C libft -s
$(NAME): $(ALL_OBJS) $(LIB)
@echo $(CYAN) "Compiling $@...🛠️" $(EOC)
@$(CC) $(ALL_OBJS) -I include $(LIB) -Lminilibx-linux -lmlx_Linux -L/usr/lib -Imlx_linux -lXext -lX11 -lm -lz -o $(NAME)
run:
@valgrind --suppressions=suppressions.supp --leak-check=full --show-leak-kinds=all --child-silent-after-fork=yes ./miniRT
clean:
@$(RM) $(LINKED_OBJS)
@$(MAKE) clean -C libft -s
@echo $(RED) "Cleaned..." $(EOC)
fclean: clean
@$(RM) $(NAME)
@$(RM) $(MINILIBX_DIR)
@$(MAKE) fclean -C libft -s
@echo $(PURPLE) "Full Cleaned...🧹" $(EOC)
re: fclean all
@git submodule update --remote -q
.PHONY: all clean fclean re submodule testing