-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
163 lines (130 loc) · 4.79 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
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
END_COLOR = \033[0m
BOLD_GREEN = \033[1;32m
BOLD_YELLOW = \033[1;33m
END = \033[0m
NAME = cub3D
NAME_BONUS = cub3D_bonus
CFLAGS = -Wall -Werror -Wextra -g
VGFLAGS = VGFLAGS = valgrind --leak-check=full --suppressions=sup --track-origins=yes --show-leak-kinds=all --log-file=leaks.log -s
LIBMLX_DIR = lib/
LIBMLX = $(addprefix $(LIBMLX_DIR), libmlx.a)
LIBFT_DIR = libft/
LIBFT = $(addprefix $(LIBFT_DIR), libft.a)
VGFLAGS = valgrind --leak-check=full --suppressions=sup --track-origins=yes --show-leak-kinds=all --log-file=leaks.log -s
TESTFLAGS = -fsanitize=address
INCDIR:=srcs
ODIR:=obj
INCDIR_BONUS:=bonus
ODIR_BONUS:=obj_bonus
SRC := closing_bonus.c freeing_bonus.c handlers_bonus.c init_window_bonus.c \
main_bonus.c main_utils_bonus.c minimaper_bonus.c raycaster_bonus.c \
raycaster_bonus2.c raycaster_bonus3.c raycaster_bonus4.c\
raycaster_bonus_utils.c raycaster_bonus_utils2.c \
errors_bonus.c render_bonus.c minimaper_utils_bonus.c render_utils_bonus.c \
minimaper_renders_bonus.c\
rgb_bonus.c parser_cub_bonus.c map_build_bonus.c tests_bonus.c controls_bonus.c \
animation.c animation_utils.c \
fileread_xpm.c fileread_utils2.c fileread.c fileread_utils.c \
additional_functions.c minimaper_extra_utils.c minimap_render_2.c \
raycaster_bonus5.c minimaper_helpers.c doors_functions.c \
handlers_bonus2.c handlers_bonus3.c handlers_bonus4.c handlers_bonus5.c \
doors2.c handlers_bonus6.c init_window_bonus2.c init_window_bonus3.c\
init_window_bonus4.c
BONUS_SRC = closing_bonus.c freeing_bonus.c handlers_bonus.c init_window_bonus.c \
main_bonus.c main_utils_bonus.c minimaper_bonus.c raycaster_bonus.c \
raycaster_bonus2.c raycaster_bonus3.c raycaster_bonus4.c\
raycaster_bonus_utils.c raycaster_bonus_utils2.c \
errors_bonus.c render_bonus.c minimaper_utils_bonus.c render_utils_bonus.c \
minimaper_renders_bonus.c\
rgb_bonus.c parser_cub_bonus.c map_build_bonus.c tests_bonus.c controls_bonus.c \
animation.c animation_utils.c \
fileread_xpm.c fileread_utils2.c fileread.c fileread_utils.c \
additional_functions.c minimaper_extra_utils.c minimap_render_2.c \
raycaster_bonus5.c minimaper_helpers.c doors_functions.c \
handlers_bonus2.c handlers_bonus3.c handlers_bonus4.c handlers_bonus5.c \
doors2.c handlers_bonus6.c init_window_bonus2.c init_window_bonus3.c\
init_window_bonus4.c
OBJ := $(patsubst %.c, $(ODIR)/%.o,$(SRC))
OBJ_BONUS = $(patsubst %.c, $(ODIR_BONUS)/%.o,$(BONUS_SRC))
LIBFLAGS = $(LIBFT) -I$(LIBMLX_DIR) -L$(LIBMLX_DIR) -lmlx -lX11 -lXext -lm -O3
CC = cc
RM = rm -f
TOTAL_FILES := $(words $(SRC))
COMPILED_FILES := $(shell if [ -d "$(ODIR)" ]; then find $(ODIR) -name "*.o" | wc -l; else echo 0; fi)
all: $(NAME)
bonus: $(NAME_BONUS)
$(NAME): $(OBJ) $(LIBFT) $(LIBMLX)
@$(CC) $(CFLAGS) $(OBJ) $(LIBFLAGS) -o $(NAME)
@printf "$(BOLD_GREEN)...cub3d in the making: $$(echo "$(shell find $(ODIR) -name "*.o" | wc -l) $(TOTAL_FILES)" | awk '{printf "%.2f", $$1/$$2 * 100}')%%$(RES)\r"
@printf "\n"
@echo "${BOLD_GREEN}cub3d is reborn...${END}"
$(NAME_BONUS): $(OBJ_BONUS) $(LIBFT) $(LIBMLX)
@$(CC) $(CFLAGS) $(OBJ_BONUS) $(LIBFLAGS) -o $(NAME_BONUS)
@printf "$(BOLD_GREEN)... bonus cub3d in the making: $$(echo "$(shell find $(ODIR_BONUS) -name "*.o" | wc -l) $(TOTAL_FILES)" | awk '{printf "%.2f", $$1/$$2 * 100}')%%$(RES)\r"
@printf "\n"
@echo "${BOLD_GREEN}bonus cub3d is reborn...${END}"
$(ODIR):
@mkdir -p $@
$(ODIR)/%.o: $(INCDIR)/%.c
@mkdir -p $(dir $@)
@printf "$(BOLD_GREEN)...cub3d in the making: $$(echo "$(shell find $(ODIR) -name "*.o" | wc -l) $(TOTAL_FILES)" | awk '{printf "%.2f", $$1/$$2 * 100}')%%$(RES)\r"
@$(CC) $(CFLAGS) -c -o $@ $<
$(ODIR_BONUS):
@mkdir -p $@
$(ODIR_BONUS)/%.o: $(INCDIR_BONUS)/%.c
@mkdir -p $(dir $@)
@printf "$(BOLD_GREEN)...cub3d in the making: $$(echo "$(shell find $(ODIR_BONUS) -name "*.o" | wc -l) $(TOTAL_FILES)" | awk '{printf "%.2f", $$1/$$2 * 100}')%%$(RES)\r"
@$(CC) $(CFLAGS) -c -o $@ $<
$(LIBFT):
@make -C $(LIBFT_DIR)
@echo "${BOLD_GREEN}LIBFT BUILT${END}"
$(LIBMLX):
@make -C $(LIBMLX_DIR)
@echo "${GREEN}LIBMLX BUILT${END}"
fclean: clean
@$(RM) $(NAME)
@$(RM) $(NAME_BONUS)
# @make clean -C $(LIBMLX_DIR)
clean:
@$(RM) $(OBJ)
@$(RM) $(OBJ_BONUS)
@$(RM) valgrind_failures.log
@make fclean -C $(LIBFT_DIR)
@echo "${RED}cub3d is no more...${END}"
re: fclean all
suppress: sup_file all
@echo "${BOLD_YELLOW}LEAK CHECKER ON${END}"
leaks: ./cub3d_bonus
$(VGFLAGS) ./run_invalids.sh
sup_file:
$(file > sup, $(SUP_BODY))
@echo "${BOLD_YELLOW}Suppressing mousemove leaks${END}"
define SUP_BODY
{
mlx_mouse_hide
Memcheck:Leak
...
fun:mlx_mouse_hide
}
{
leak XrmGetStringDatabase
Memcheck:Leak
...
fun:XrmGetStringDatabase
}
{
leak _dl_open
Memcheck:Leak
...
fun:_dl_open
}
{
leak _XrmInitParseInfo
Memcheck:Leak
...
fun:_XrmInitParseInfo
}
endef