-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (84 loc) · 3.46 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: pgueugno <pgueugno@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/01/10 12:56:57 by pgueugno #+# #+# #
# Updated: 2022/02/17 17:36:34 by pgueugno ### ########.fr #
# #
# **************************************************************************** #
################################################################################
# MAKEFILE #
# by Yannou & PL <3 #
################################################################################
#_______________________________Filename output________________________________#
NAME = webserv
#______________________________Commands and arguments__________________________#
CXX = @ clang++
CXXFLAGS = -Wall -Wextra -Werror -std=c++98 -g3 -MMD
DEBUG_LEAK = -fsanitize=address
RM = @ rm -f
#_________________________Sources and objects directories______________________#
SRCS_DIR = ./
BUILDING_DIR = ./building_dir/
INCLUDES_DIR = ./
FILES = $(addsuffix .cpp, $(SRCS))
OBJECTS = $(addprefix $(BUILDING_DIR),$(FILES:.cpp=.o))
DEPENDS = $(OBJECTS:.o=.d)
#_______________________________Sources filenames______________________________#
SRCS = main \
request \
response \
utils \
cgi \
webserv \
Server
#________________________________Building rules________________________________#
all: init_hooks init $(NAME)
init:
@ if test -f $(NAME);\
then echo "$(_CYAN)[program already created]$(_NC)";\
else echo "$(_YELLOW)[Initialize program]$(_NC)";\
fi
$(shell mkdir -p $(BUILDING_DIR))
$(BUILDING_DIR)%.o:$(SRCS_DIR)%.cpp
@ echo "\t$(_YELLOW) compiling... $*.cpp$(_NC)"
$(CXX) $(CXXFLAGS) -I $(INCLUDES_DIR) -c $< -o $@
${NAME}: $(OBJECTS)
@ echo "\t$(_YELLOW)[Creating program]$(_NC)"
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $(NAME)
@ echo "$(_GREEN)[program created & ready]$(_NC)"
#________________________________Debugging rules_______________________________#
debug: CXXFLAGS += $(DEBUG_LEAK)
debug: all
rd: fclean
rd: debug
verbose: CXXFLAGS += -D DEBUG
verbose: all
rv: fclean
rv: verbose
#________________________________Cleaning rules________________________________#
clean:
@ echo "$(_RED)[cleaning up objects & dependancies files]$(_NC)"
$(RM) $(OBJECTS) $(DEPENDS)
fclean: clean
@ echo "$(_RED)[cleaning up binary files]$(_NC)"
$(RM) $(NAME)
re: fclean all
#_____________________________________Hooks____________________________________#
init_hooks:
@if [ -e .git/hooks/commit-msg ];\
then :;\
else cp .hooks/commit-msg .git/hooks/commit-msg;\
fi
#_____________________________________Misc.____________________________________#
-include $(DEPENDS)
_RED = \033[31m
_GREEN = \033[32m
_YELLOW = \033[33m
_CYAN = \033[96m
_NC = \033[0m
.PHONY: all clean fclean re
#.SILENT: all