-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
102 lines (80 loc) · 2.12 KB
/
Makefile
File metadata and controls
102 lines (80 loc) · 2.12 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
.DEFAULT_GOAL = all
# program name
NAME = miniRT
# compile
CC = cc
CFLAGS = -Wall -Wextra -Werror -MMD -MP
CFLAGS_SANITIZE = -fsanitize=address -g3
CPPFLAGS = \
-I./$(PART_PATH)/includes \
-I./$(PART_PATH)/includes/structs
LDFLAGS =
LDLIBS = -lm
ifdef SANITIZE
CFLAGS += $(CFLAGS_SANITIZE)
endif
# ********************************** LIBRARY ********************************* #
# libft, libmlx, libmath
include config/library.mk
# ********************************** miniRT ********************************* #
# determine part
ifdef BONUS
PART_PATH = bonus
PART_SUFFIX = _bonus
else
PART_PATH = mandatory
PART_SUFFIX =
endif
# files
include config/filename.mk
SRCS = $(addprefix ./$(PART_PATH)/srcs/, $(addsuffix $(PART_SUFFIX).c, $(FILENAME)))
OBJS = $(addprefix ./$(PART_PATH)/objs/, $(addsuffix $(PART_SUFFIX).o, $(FILENAME)))
DEPS = $(OBJS:.o=.d)
# build
# dependency rule
ifeq ($(MAKECMDGOALS), fclean)
else ifeq ($(MAKECMDGOALS), clean)
else
-include $(DEPS)
endif
# build program
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $(CPPFLAGS) $^ -o $@ $(LDLIBS) $(LDFLAGS)
$(PART_PATH)/objs/%.o : $(PART_PATH)/srcs/%.c
mkdir -p $(@D)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
# ******************************* BASIC RULES ******************************** #
all:
make get_filenames
make -C $(LIBFT_PATH) --silent
make -C $(LIBMLX_PATH) --silent
make -C $(LIBMATH_PATH) --silent
make $(NAME)
bonus:
make -C $(LIBFT_PATH) --silent
make -C $(LIBMLX_PATH) --silent
make -C $(LIBMATH_PATH) --silent
BONUS=1 make $(NAME)
clean:
make -C $(LIBFT_PATH) clean --silent
make -C $(LIBMLX_PATH) clean --silent
make -C $(LIBMATH_PATH) clean --silent
$(RM) -rf mandatory/objs
$(RM) -rf bonus/objs
fclean:
make -C $(LIBMLX_PATH) clean --silent
make -C $(LIBFT_PATH) fclean --silent
make -C $(LIBMATH_PATH) fclean --silent
$(RM) $(LIBMLX_PATH)/$(LIBMLX)
$(RM) -rf mandatory/objs
$(RM) -rf bonus/objs
$(RM) $(NAME)
re:
make fclean
make all
.PHONY: all clean fclean re bonus
# ******************************* ASSIST RULES ******************************* #
ifdef DEBUG
LLDB = lldb
endif
include config/debug_rule.mk