forked from TamLem/Webserv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
147 lines (110 loc) · 3.28 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
NAME = webserv
CXX = c++
UNAME := $(shell uname)
CXXFLAGS = -std=c++98 -Wall -Wextra -Werror
# CXXFLAGS += -g# -fsanitize=address -fsanitize=alignment -fsanitize=unreachable -fsanitize=bounds # can be used to check for any memory faults
# CXXFLAGS += -D FORTYTWO_TESTER
# CXXFLAGS += -D SHOW_CONSTRUCTION # enables the printing of constructor/destructor messages
# CXXFLAGS += -D SHOW_LOG_SOCKET
# CXXFLAGS += -D SHOW_LOG_CONFIG
# CXXFLAGS += -D SHOW_LOG #enables the printing of surface-level logs, server-side only
# CXXFLAGS += -D SHOW_LOG_2 #enables the printing of deep-level logs, server-side only
# CXXFLAGS += -D SHOW_LOG_REQUEST
# CXXFLAGS += -D SHOW_LOG_RESPONSE
# CXXFLAGS += -D SHOW_LOG_EXCEPTION
# CXXFLAGS += -D SHOW_LOG_ROUTING
# CXXFLAGS += -D SHOW_LOG_CGI
#directories
PWD = $(shell pwd)
SRC_DIR = server/src/
OBJ_DIR = server/obj/
INC_DIR = server/include/
#controll codes
RESET = \033[0m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
RED = \033[31m
UP = \033[A
CUT = \033[K
#source files
SRC_FILES = main.cpp \
SocketHandler.cpp \
Server.cpp \
ServerExceptions.cpp \
Routing.cpp \
ServerUtils.cpp \
Message.cpp \
Response.cpp \
Send.cpp \
Receive.cpp \
Cgi.cpp \
CgiResponse.cpp \
Request.cpp \
Config.cpp \
SingleServerConfig.cpp
OBJ_FILES = $(SRC_FILES:.cpp=.o)
DEP = $(wildcard $(INC_DIR)*.hpp) $(wildcard $(INC_DIR)*/*.hpp) Makefile
#paths
SRC = $(addprefix $(SRC_DIR), $(SRC_FILES))
OBJ = $(addprefix $(OBJ_DIR), $(OBJ_FILES))
#all rule
all: $(NAME)
#ascii art can be found at: https://patorjk.com/software/taag/#p=display&f=Calvin%20S&t=ft%20containers
@printf "\n"
@printf "$(GREEN)┬ ┬┌─┐┌┐ ┌─┐┌─┐┬─┐┬ ┬ \n$(RESET)"
@printf "$(GREEN)│││├┤ ├┴┐└─┐├┤ ├┬┘└┐┌┘ \n$(RESET)"
@printf "$(GREEN)└┴┘└─┘└─┘└─┘└─┘┴└─ └┘ \n$(RESET)"
@printf "\n"
#compile the executable
$(NAME): $(OBJ)
@echo "$(YELLOW)Compiling [$(NAME)]...$(RESET)"
@$(CXX) $(CXXFLAGS) $(OBJ) -o $(NAME)
@echo "$(GREEN)Finished [$(NAME)]$(RESET)"
#compile objects
$(OBJ_DIR)%.o:$(SRC_DIR)%.cpp $(DEP)
@mkdir -p $(OBJ_DIR)
@echo "$(YELLOW)Compiling [$@]...$(RESET)"
@$(CXX) $(CXXFLAGS) -I $(INC_DIR) -o $@ -c $<
@printf "$(UP)$(CUT)"
@echo "$(GREEN)Finished [$@]$(RESET)"
@printf "$(UP)$(CUT)"
#clean rule
clean:
@if [ -d "$(OBJ_DIR)" ]; then \
rm -rf $(OBJ_DIR); \
echo "$(BLUE)Deleting all objects from $(PWD)...$(RESET)"; else \
echo "No objects to remove from $(PWD)."; \
fi;
#fclean rule
fclean: clean
@if [ -f "$(NAME)" ]; then \
rm -f $(NAME); \
echo "$(BLUE)Deleting $(NAME) from $(PWD)...$(RESET)"; else \
echo "No Executable to remove from $(PWD)."; \
fi;
#re rule
re: fclean all
#run rule
run: all
./$(NAME) server/config/test.conf
ae: all
./$(NAME) server/config/ae.conf
site: all
./$(NAME) server/config/site.conf
trans: all
./$(NAME) server/config/trans.conf
42: all
./$(NAME) server/config/42tester.conf
our: all
./$(NAME) server/config/ourTester.conf
tester:
@make -C ./ourTester
rmtester:
@make clean -C ./ourTester
rm42tester:
-rm 42tester/file_should_exist_after
-rm 42tester/multiple_same
-rm 42tester/post_body
#phony
.PHONY: all clean fclean re run ae 42 our tester rmtester rm42tester