-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
224 lines (196 loc) · 6.06 KB
/
Makefile
File metadata and controls
224 lines (196 loc) · 6.06 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#----COLORS----#
DEF_COLOR = \033[0m
WHITE_BOLD = \033[1;39m
BLACK = \033[1;30m
RED = \033[1;31m
RED_REGULAR = \033[0;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
BLUE = \033[1;34m
PINK = \033[1;35m
CYAN = \033[1;36m
#----OS COMPATIBILITY----#
ifeq ($(OS),Windows_NT)
CCFLAGS += -D WIN32
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
CCFLAGS += -D AMD64
else
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
CCFLAGS += -D AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
CCFLAGS += -D IA32
endif
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CCFLAGS += -D LINUX=1
export LINUX=1
endif
ifeq ($(UNAME_S),Darwin)
CCFLAGS += -D DARWIN=1
export DARWIN=1
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
CCFLAGS += -D AMD64
endif
ifneq ($(filter %86,$(UNAME_P)),)
CCFLAGS += -D IA32
endif
ifneq ($(filter arm%,$(UNAME_P)),)
CCFLAGS += -D ARM
endif
endif
#----NAME----#
NAME = webserv
#----COMPILER----#
CC = c++
CCFLAGS += -std=c++98 -Wall -Wextra -Werror -fsanitize=address -g # -Ofast
#----DIRS----#
BIN_DIR = bin/
SRC = src/
INCLUDES = -I$(SRC)
#----VPATH----#
vpath %.cpp $(SRC): \
$(SRC)WebServer/ConfigParser : \
$(SRC)WebServer/ConfigParser/helpers/DirectiveRegistry/ : \
$(SRC)utils: \
$(SRC)WebServer/Connection/Request/Body : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestBodyFramingVerifier : \
$(SRC)WebServer/Connection/Request/RequestFactory : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestPathNormalizer : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestPctDecoder : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestProcesser : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestValidator/ConnectionHeaderValidator : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestValidator/ContentLengthHeaderValidator : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestValidator/HostHeaderValidator : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestValidator : \
$(SRC)WebServer/Connection/Request/RequestFactory/RequestValidator/TransferEncodingHeaderValidator : \
$(SRC)WebServer/Connection/Request/RequestLine : \
$(SRC)WebServer/Connection/Request/RequestLine/Target : \
$(SRC)WebServer/Connection/Request/RequestParser : \
$(SRC)WebServer/Connection/Request/RequestTokenizer/RequestToken : \
$(SRC)WebServer/Connection/Request/RequestTokenizer : \
$(SRC)WebServer/Connection/Response/ResponseFactory : \
$(SRC)WebServer/Connection/Response/StatusLine : \
$(SRC)WebServer/Connection/Response/RequestHandler/Context : \
$(SRC)WebServer/Connection/Response/RequestHandler/RequestExecutor/Methods : \
$(SRC)WebServer/Connection/Response/RequestHandler/RequestExecutor/Methods/Factory : \
$(SRC)WebServer/Connection/Response/RequestHandler/RequestExecutor/Methods/Implemented/DELETE : \
$(SRC)WebServer/Connection/Response/RequestHandler/RequestExecutor/Methods/Implemented/GET : \
$(SRC)WebServer/Connection/Response/RequestHandler/RequestExecutor/Methods/Implemented/POST : \
$(SRC)WebServer/Connection/Response/RequestHandler/RequestExecutor : \
$(SRC)WebServer/Connection/Response/RequestHandler/Result : \
$(SRC)WebServer/Connection/Response/RequestHandler : \
$(SRC)WebServer/Connection : \
$(SRC)WebServer/Server/Location : \
$(SRC)WebServer/Server/Session : \
$(SRC)WebServer/Server : \
$(SRC)WebServer : \
$(SRC)utils/HeaderCollection/Header : \
$(SRC)utils/HeaderCollection : \
$(SRC)utils/cgi : \
$(SRC)utils/exceptions : \
$(SRC)utils/fileHandler : \
$(SRC)utils/numeric : \
$(SRC)utils/string : \
$(SRC)utils/Result : \
$(SRC)utils/http :
#----SHARED----#
SRCS = Body.cpp \
RequestBodyFramingVerifier.cpp \
RequestFactory.cpp \
RequestPathNormalizer.cpp \
RequestPctDecoder.cpp \
RequestProcesser.cpp \
ConnectionHeaderValidator.cpp \
ContentLengthHeaderValidator.cpp \
HostHeaderValidator.cpp \
RequestValidator.cpp \
TransferEncodingHeaderValidator.cpp \
RequestLine.cpp \
Target.cpp \
RequestParser.cpp \
RequestToken.cpp \
RequestTokenizer.cpp \
ResponseFactory.cpp \
StatusLine.cpp \
Context.cpp \
AMethod.cpp \
MethodFactory.cpp \
Delete.cpp \
Get.cpp \
Post.cpp \
RequestExecutor.cpp \
RequestHandler.cpp \
Connection.cpp \
Location.cpp \
Session.cpp \
Server.cpp \
WebServer.cpp \
Header.cpp \
HeaderCollection.cpp \
cgi.cpp \
Exceptions.cpp \
files.cpp \
numeric.cpp \
string.cpp \
SimpleResult.cpp \
webserv.cpp \
ConfigParser.cpp \
DirectiveRegistry.cpp \
http.cpp
OBJS = $(SRCS:%.cpp=$(BIN_DIR)%.o)
DEPS = $(OBJS:%.o=%.d)
AMETHTDD=./assets/tests/amethyst/amethtdd
#----- R U L E S -----#
all:
@$(MAKE) --no-print-directory $(NAME)
$(NAME): $(OBJS)
mkdir -p assets/www/uploads
@printf "$(BLUE)Linking objects and creating program...$(DEF_COLOR)\n"
$(CC) $(CCFLAGS) $(OBJS) $(LIBRARIES) $(LIBRARIES_DEPS) -o $(NAME)
@echo "$(GREEN)[✓] $(PINK)$(NAME)$(GREEN) created!!!$(DEF_COLOR)"
$(BIN_DIR)%.o: %.cpp Makefile
@printf "$(CYAN)Compiling: $(PINK)$(notdir $<)...$(DEF_COLOR)\n"
@mkdir -p $(BIN_DIR)
@$(CC) $(CCFLAGS) $(INCLUDES) -MMD -c $< -o $@
clean:
@rm -rf $(BIN_DIR)
@echo "$(RED)Binaries deleted$(DEF_COLOR)\n"
fclean: clean
@rm -rf $(NAME)
@echo "$(RED)Executable deleted$(DEF_COLOR)\n"
re: fclean all
bonus:
$(MAKE) --no-print-directory all BONUS=1
b: bonus
bonusre: fclean bonus
bre: bonusre
test:
cd assets/tests/subject; ./ubuntu_tester "http://localhost:8080"
tester:
$(MAKE) --no-print-directory -C assets/tests/amethyst && $(AMETHTDD)
testercl:
$(MAKE) --no-print-directory -C assets/tests/amethyst clean
testerfcl:
$(MAKE) --no-print-directory -C assets/tests/amethyst fclean
testerre:
$(MAKE) --no-print-directory -C assets/tests/amethyst re && $(AMETHTDD)
.PHONY: all \
clean \
fclean \
re \
bonus \
b \
bonusre \
bre \
test \
# min-test \
# test-clean
-include $(DEPS)
-include $(MDEPS)
-include $(BDEPS)
.SILENT: