-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (55 loc) · 1.59 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
#******************************* VARIABLES **********************************#
NAME = webserv
PYTHON3 = python3
# --------------- FILES --------------- #
include src.mk
# ------------ DIRECTORIES ------------ #
DIR_BUILD = .build/
DIR_SRC = src/
DIR_INCLUDE = include/
DIR_TEST = test/
# ------------- SHORTCUTS ------------- #
OBJ = $(patsubst %.cpp, $(DIR_BUILD)%.o, $(SRC))
DEP = $(patsubst %.cpp, $(DIR_BUILD)%.d, $(SRC))
SRC = $(addprefix $(DIR_SRC),$(LIST_SRC))
# ------------ COMPILATION ------------ #
CPPFLAGS = -Wall -Wextra -Werror -std=c++98
DEP_FLAGS = -MMD -MP
# ------------- COMMANDS ------------- #
RM = rm -rf
MKDIR = mkdir -p
#*********************************** RULES **********************************#
.PHONY: all
all: $(NAME)
# ---------- VARIABLES RULES ---------- #
$(NAME): $(OBJ)
$(CXX) $(CPPFLAGS) -o $(NAME) $(OBJ)
# ---------- COMPILED RULES ----------- #
-include $(DEP)
$(DIR_BUILD)%.o: %.cpp
mkdir -p $(shell dirname $@)
$(CXX) $(CPPFLAGS) $(DEP_FLAGS) -I $(DIR_INCLUDE) -c $< -o $@
.PHONY: clean
clean:
$(RM) $(DIR_BUILD)
.PHONY: fclean
fclean: clean
$(RM) $(NAME)
.PHONY: re
re: fclean
$(MAKE) all
.PHONY: run
run: all
./webserv resources/webserv.conf
.PHONY: test
test: all
$(PYTHON3) -m unittest discover -s $(DIR_TEST) -p "test_*.py"
.PHONY: benchmark
benchmark: all
$(PYTHON3) -m unittest discover -s $(DIR_TEST) -p "bench*.py"
.PHONY: build_image
build_image: Dockerfile
docker build -t webserv .
.PHONY: run_container
run_container:
docker run -d -p 4243:4243 webserv