forked from lucocozz/webserv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (65 loc) · 2.3 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lucocozz <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/01/21 19:56:36 by lucocozz #+# #+# #
# Updated: 2022/04/30 16:03:24 by lucocozz ### ########.fr #
# #
# **************************************************************************** #
NAME := webserv
CONFIG_FILE_NAME := "webserv.conf"
WEBSERV_PATH := "$(HOME)/.config/webserv/"
DEFAULT_PORT := "8080"
DEFAULT_ROOT := "/tmp/www/"
DEF := CONFIG_FILE_NAME WEBSERV_PATH DEFAULT_PORT DEFAULT_ROOT
DEFINES = $(addprefix -D ,$(foreach tmp,$(DEF),$(tmp)='$($(tmp))'))
SRC := main.cpp \
serverCore.cpp \
handleInput.cpp \
handleOutput.cpp \
handleConnection.cpp \
handleDeconnection.cpp \
handleSignal.cpp \
createServers.cpp \
closeServers.cpp \
eventLoop.cpp \
statusCode.cpp \
configData.cpp \
fileRelated.cpp \
locationRelated.cpp \
pathRelated.cpp \
stringRelated.cpp \
URLRelated.cpp
MAKE = make
MAKEFLAGS += --no-print-directory
CXX := c++
CXXFLAGS := -Wall -Wextra -Werror -MMD -std=c++98 -Wpedantic -g3
BUILD_DIR := .build
INCLUDES_DIR := $(shell find includes -type d)
SOURCE_DIR := sources
DEP := $(SRC:%.cpp=$(BUILD_DIR)/%.d)
OBJ := $(DEP:.d=.o)
vpath %.cpp ./ $(shell find $(SOURCE_DIR) -type d)
all: $(NAME) config
$(NAME): $(OBJ)
$(CXX) $(CXXFLAGS) $^ -o $@
config:
mkdir -p $(WEBSERV_PATH)
mkdir -p $(DEFAULT_ROOT)
cp -r config/* $(WEBSERV_PATH)
cp -r sites $(DEFAULT_ROOT)
clean:
rm -rf $(BUILD_DIR)
fclean: clean
rm -f $(NAME)
re: fclean all
test: $(NAME)
$(BUILD_DIR):
mkdir $@
$(BUILD_DIR)/%.o: %.cpp | $(BUILD_DIR)
$(CXX) $(DEFINES) $(CXXFLAGS) $(INCLUDES_DIR:%=-I %) -c $< -o $@
.PHONY: all clean fclean re test config
-include $(DEP)