-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
110 lines (78 loc) · 2.49 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
# **********************************************************************#
# #
# webserv #
# #
# ********************************************************************* #
EXECUTABLE_NAME = webserv
# ********************************************************************* #
CC = clang++
CFLAGS = \
-Wall -Wextra -Werror \
-std=c++98 \
-Wc++98-compat \
-pedantic
# ********************************************************************* #
# project-specific (setup):
ENTRY_POINT = webserv.cpp
SOURCES_DIR = ./src/
INCLUDE_DIR = ./include/
CLASSES_NAME = \
Config \
CGI \
PollDescriptors \
Response \
Request \
TCP_Connection
OTHER_CPPFILES = \
GetResponse.cpp\
PostResponse.cpp \
Server_signals.cpp \
Server_core.cpp
OTHER_HEADERS = \
utility.hpp \
http_tokens.hpp \
Server.hpp \
sockets.hpp
# ********************************************************************* #
# internal setup:
# (Classes must have .cpp/.hpp extension to be compiled)
CLASS_CPP := $(addsuffix .cpp, $(CLASSES_NAME))
CLASS_HPP := $(addsuffix .hpp, $(CLASSES_NAME))
INTERFACES_HPP := $(addsuffix .hpp, $(INTERFACES))
SOURCES_LIST = $(CLASS_CPP) $(ENTRY_POINT) $(OTHER_CPPFILES)
SOURCES = $(addprefix $(SOURCES_DIR), $(SOURCES_LIST))
INCLUDE_DEPS_LIST = $(CLASS_HPP) $(HPP_TEMPLATES) $(OTHER_HEADERS)
INCLUDE_DEPS = $(addprefix $(INCLUDE_DIR), $(INCLUDE_DEPS_LIST))
OBJ_DIR = ./obj/
OBJ_FILES = $(SOURCES_LIST:.cpp=.o)
OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILES))
$(OBJ_DIR)%.o: $(SOURCES_DIR)%.cpp $(INCLUDE_DEPS)
@$(CC) $(CFLAGS) -c $< -o $@
# ********************************************************************* #
# compile all:
all: $(EXECUTABLE_NAME)
$(EXECUTABLE_NAME): obj $(OBJ) $(INCLUDE_DEPS)
@ echo "\033[38;5;36mBuilding webserver..."
@ $(CC) $(CFLAGS) -o $(EXECUTABLE_NAME) $(OBJ)
@ echo "Done ✓\033[0m"
# $(EXECUTABLE_NAME): $(SOURCES) $(INCLUDE_DEPS)
# @ echo "\033[38;5;36mBuilding webserver..."
# @ $(CC) $(CFLAGS) -o $(EXECUTABLE_NAME) $(SOURCES)
# @ echo "Done ✓\033[0m"
obj:
@mkdir -p $(OBJ_DIR)
# compile with fsanitize address flag: 'make dbg'
sani: re
@ echo "\033[34;0;36mDebug mode: fsanitize address"
@ $(CC) $(CFLAGS) -o $(EXECUTABLE_NAME) $(SOURCES) -g3 -fsanitize=address
dbg:
@ echo "\033[34;0;36mDebug mode: flag DEBUG = true"
@ $(CC) $(CFLAGS) -o $(EXECUTABLE_NAME) $(SOURCES) -DDEBUG=1
.PHONY = clean
clean:
@ rm -rf $(EXECUTABLE_NAME)
@ rm -f $(OBJ_DIR)/*
fclean: clean
@ rm -f $(EXECUTABLE_NAME)
@ rm -rf *.dSYM
re: fclean all