-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
89 lines (72 loc) · 2.7 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
86
87
88
89
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mdesalle <mdesalle@student.s19.be> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/03/14 16:55:18 by mdesalle #+# #+# #
# Updated: 2022/03/18 12:01:09 by mdesalle ### ########.fr #
# #
# **************************************************************************** #
NAME := webserv
DEBUG := 0
# =============================== COMPILATION ================================ #
CC := clang++
CFLAGS := -Wall -Wextra -Werror -std=c++98 #-fsanitize=address -g3
# ================================== FILES =================================== #
BIN_DIR := .bin/
SRC_DIR := src/
INC_DIR := include/
MAIN := Webserv.cpp
CONFIG := ConfigHandler.cpp \
Server.cpp \
Location.cpp
SOCKETS := ListenSocket.cpp \
ClientSocket.cpp \
Webserv.cpp
HTTP := Request.cpp \
URI.cpp \
Response.cpp \
Header.cpp \
Value.cpp
UTILS := Timer.cpp \
utils.cpp
CGI := CommonGatewayInterface.cpp \
INCLUDES = -I ./${INC_DIR}
INCLUDES += -I $(addprefix $(INC_DIR), config)
INCLUDES += -I $(addprefix $(INC_DIR), HTTP_Config)
INCLUDES += -I $(addprefix $(INC_DIR), sockets)
INCLUDES += -I $(addprefix $(INC_DIR), cgi)
INCLUDES += -I $(addprefix $(INC_DIR), utils)
MAIN_DIR := $(addprefix src/, $(MAIN))
CONFIG := $(addprefix src/config/, $(CONFIG))
HTTP := $(addprefix src/HTTP_Config/, $(HTTP))
SOCKETS := $(addprefix src/sockets/, $(SOCKETS))
CGI := $(addprefix src/cgi/, $(CGI))
UTILS := $(addprefix src/utils/, $(UTILS))
SRC := $(MAIN_DIR) $(CONFIG) $(HTTP) $(SOCKETS) $(CGI) $(UTILS)
OBJ := $(subst ${SRC_DIR},${BIN_DIR}, ${SRC:.cpp=.o})
# ================================== RULES =================================== #
$(BIN_DIR)%.o: $(SRC_DIR)%.cpp
@mkdir -p $(dir $@)
ifeq ($(DEBUG), 1)
$(CC) $(CFLAGS) -D DEBUG -c $< -o $@
else
$(CC) $(CFLAGS) -c $< -o $@
endif
$(NAME): $(OBJ)
ifeq ($(DEBUG), 1)
@$(CC) $(CFLAGS) -D DEBUG $(OBJ) -o $(NAME)
else
@$(CC) $(CFLAGS) $(OBJ) -o $(NAME)
endif
all: $(NAME)
clean:
@rm -rf $(OBJ)
@rm -rf *.dSYM
fclean: clean
@rm -rf $(BIN_DIR)
@rm -rf $(NAME)
re: fclean all
.PHONY: all clean re fclean