-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
80 lines (58 loc) · 1.22 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
# GENERAL VARS
NAME := webserv
OBJ_DIR := ./obj
SRC_DIR := ./src
INC := -I include
HEADERS := $(wildcard include/*.hpp)
SRC := CGI.cpp \
Client.cpp \
ConfigReturn.cpp \
ConfigShared.cpp \
Configuration.cpp \
Directive.cpp \
HelperFuncs.cpp \
HTTPServer.cpp \
Location.cpp \
Logger.cpp \
main.cpp \
Poll.cpp \
PollableFileDescriptor.cpp \
Request.cpp \
Response.cpp \
ResponseHelpers.cpp \
Server.cpp \
Socket.cpp
OBJ := $(addprefix $(OBJ_DIR)/,$(SRC:.cpp=.o))
SRC := $(addprefix $(SRC_DIR)/,$(SRC))
CC := c++
FLAGS := -std=c++20 -Wall -Werror -Wextra
ifdef DEBUG
FLAGS += -g
endif
ifdef FSAN
FLAGS += -fsanitize=address,undefined
endif
COMPILE := $(CC) $(FLAGS)
############### RECIPES ###############
all: $(NAME)
$(OBJ_DIR):
mkdir -p $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp $(HEADERS) | $(OBJ_DIR)
@mkdir -p $(@D)
$(CC) $(FLAGS) $(INC) -c $< -o $@
$(NAME): $(OBJ)
$(CC) $(FLAGS) $^ -o $(NAME)
clean:
@rm -rf $(OBJ_DIR)
fclean: clean
@rm -f $(NAME)
re: clean all
debug:
$(MAKE) DEBUG=1
rebug: fclean
$(MAKE) debug
fsan:
$(MAKE) DEBUG=1 FSAN=1
resan: fclean fsan
.PHONY: all clean fclean re debug rebug
.DEFAULT_GOAL := all