-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
156 lines (115 loc) · 3.53 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: seozcan <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/12/07 19:14:12 by seozcan #+# #+# #
# Updated: 2024/02/08 17:11:08 by seozcan ### ########.fr #
# #
# **************************************************************************** #
include settings.mk
# :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::DIRECTORIES::
S = src/
ifeq ($(MAKECMDGOALS), bonus)
S = bonus/
endif
O = obj/
I = inc/
D = dep/
L = Libft/
P = ft_printf/
M = minilibx-linux/
# ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::CUSTOM FLAGS::
CFLAGS += -I$I
LDFLAGS =
ifeq ($(IS_LIB), true)
CFLAGS += -I$L$I
LDFLAGS += -L$L -lft
endif
ifeq ($(IS_PTF), true)
CFLAGS += -I$P$I
LDFLAGS += -L$P -lftprintf
endif
ifeq ($(IS_MLX), true)
CFLAGS += -I$M
LDFLAGS += -L$M -lmlx
ifeq ($(shell uname -s), Darwin)
LDFLAGS += -framework OpenGL -framework AppKit -lX11 -lXext
else ifeq ($(shell uname -s), Linux)
LDFLAGS += -lXext -lX11 -lm
endif
endif
ifeq (debug, $(filter debug,$(MAKECMDGOALS)))
CFLAGS += -g3
endif
ifeq (sanadd, $(filter sanadd,$(MAKECMDGOALS)))
CFLAGS += -fsanitize=address
endif
ifeq (santhread, $(filter santhread,$(MAKECMDGOALS)))
CFLAGS += -fsanitize=thread
endif
RM = /bin/rm -rf
SPACE = awk -F ':' '{ printf "%-61s %s\n", $$1 ":", $$2 }'
# :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::OBJECTS::
OBJ = $(SRC:$S%=$O%.o)
DEP = $(SRC:$S%=$D%.d)
# :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::RULES::
all: header lib h2 message $(NAME)
bonus: all
$O:
@mkdir -p $@
@echo "$(HIGREEN)creating $O folder:[OK]$(RESET)" | $(SPACE)
$(OBJ): | $O
$(OBJ): $O%.o: $S%
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -c $< -o $@
@echo "$(HIGREEN)compiling $<:[OK]$(RESET)" | $(SPACE)
$D:
@mkdir -p $@
@echo "$(HIGREEN)creating $D folder:[OK]$(RESET)" | $(SPACE)
$(DEP): | $D
$(DEP): $D%.d: $S%
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -MM -MF $@ -MT "$O$*.o $@" $<
@echo "$(HIGREEN)compiling $<:[OK]$(RESET)" | $(SPACE)
$(NAME): $(OBJ) $(DEP)
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME) $(LDFLAGS)
@echo "$(HIGREEN)compiling $(NAME):[OK]$(RESET)" | $(SPACE)
debug: all
sanadd: all
santhread: all
lib:
ifeq ($(IS_LIB),true)
@make -C $L --quiet
endif
ifeq ($(IS_PTF),true)
@make -C $P --quiet
endif
ifeq ($(IS_MLX),true)
@make -C $M --quiet
endif
cleanobj:
@$(RM) $(O)
@echo "$(HIORANGE)removing $O folder:[RM]$(RESET)" | $(SPACE)
cleandep:
@$(RM) $(D)
@echo "$(HIORANGE)removing $D folder:[RM]$(RESET)" | $(SPACE)
clean: header h2 cleanobj cleandep
fcleanlib: header
ifeq ($(IS_LIB),true)
@make -C $L --quiet fclean
endif
ifeq ($(IS_PTF),true)
@make -C $P --quiet fclean
endif
ifeq ($(IS_MLX),true)
@make -C $M --quiet clean
endif
fclean: header fcleanlib h2 clean
@$(RM) $(NAME)
@echo "$(HIORANGE)removing $(NAME):[RM]$(RESET)" | $(SPACE)
re: header fclean all
include colors.mk output.mk header.mk
.PHONY: all clean fclean re