-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (62 loc) · 2.42 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
############## VARIABLES ##############
NAME = webserv
SRCS = srcs/main.cpp\
srcs/Cgi/Cgi.cpp\
srcs/Configuration/Configuration.cpp\
srcs/Configuration/Parsing.cpp\
srcs/Http/Authentication.cpp\
srcs/Http/ChunkedBody.cpp\
srcs/Http/Request.cpp\
srcs/Http/Response.cpp\
srcs/Server/ContentNegotiation/ContentNegotiation.cpp\
srcs/Server/ConnectionsManagement.cpp\
srcs/Server/Methods.cpp\
srcs/Server/Routing.cpp\
srcs/Server/ServerManagement.cpp\
srcs/Server/ServerSocket.cpp\
srcs/Server/Worker.cpp\
srcs/Utils/Files.cpp\
srcs/Utils/Logger.cpp\
srcs/Utils/Time.cpp\
srcs/Utils/Utils.cpp
UT_SRCS = tests/unit_tests/main.cpp\
tests/unit_tests/Methods.cpp\
tests/unit_tests/Request.cpp\
tests/unit_tests/Response.cpp
INCS = $($(filter-out srcs/main.cpp, $(SRCS)):.cpp=.hpp)
INCS := $(addsuffix srcs/Http/Http.hpp, $(INCS))
CC = clang++
CFLAGS = -g3 -Wall -Wextra -std=c++98 -lpthread
UT_CFLAGS = -Wall -Wextra -std=c++11
#CFLAGS = -g3 -fsanitize=address -Wall -Wextra -std=c++98
#CFLAGS = -g3 -fsanitize=thread -Wall -Wextra -std=c++98
#UT_CFLAGS = -g3 -fsanitize=address -Wall -Wextra -std=c++11
############## RECIPES ##############
# compile server
$(NAME): Makefile $(SRCS) $(INCS)
@echo "\033[33m > compiling...\033[0m"
@$(CC) $(CFLAGS) $(SRCS) -o $(NAME)
@echo "\033[32m > server compiled\033[0m"
@echo "\033[32m > execute ./$(NAME) to run server\033[0m"
# compile program with unit tests
unit_tests: Makefile $(filter-out srcs/main.cpp, $(SRCS)) $(UT_SRCS) $(INCS)
@echo "\033[33m > compiling...\033[0m"
@$(CC) $(UT_CFLAGS) $(filter-out srcs/main.cpp, $(SRCS)) $(UT_SRCS) -o $(NAME)
@echo "\033[32m > unit tests compiled\033[0m"
@echo "\033[32m > execute ./$(NAME) to run all unit tests\033[0m"
# compile program with test main (tests/main.cpp)
no_unit_tests: Makefile $(filter-out srcs/main.cpp, $(SRCS)) $(UT_SRCS) $(INCS)
@echo "\033[33m > compiling...\033[0m"
@$(CC) $(UT_CFLAGS) -DNO_UNIT_TESTS $(filter-out srcs/main.cpp, $(SRCS)) tests/unit_tests/main.cpp -o $(NAME)
@echo "\033[32m > test main compiled\033[0m"
@echo "\033[32m > execute ./$(NAME) to run test main\033[0m"
clean:
@rm -rf $(NAME).o
@rm -rf $(NAME).dSYM
@rm -rf tmp_*
@echo "\033[31m > make clean done\033[0m"
fclean: clean
@rm -rf $(NAME)
@rm -rf log
@echo "\033[31m > make fclean done\033[0m"
re: fclean $(NAME)