-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
85 lines (64 loc) · 1.74 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
SHELL = bash
# ===== Target & FLAGS =====
NAME := webserv
CXX := c++
CXXFLAGS := -std=c++98 -pedantic -Wall -Wextra -Werror
RM := rm -rf
# ===== Sources =====
INCD := -I ./include
SRCS_DIR := src
SRCS_NAME := main.cpp \
Log.cpp \
Scanner.cpp \
Parser.cpp \
Config.cpp \
ConfigCommon.cpp \
ConfigLocation.cpp \
ConfigServer.cpp \
Server.cpp \
Processor.cpp \
Request.cpp \
Utilities.cpp \
Webserv.cpp \
Response.cpp \
FileManager.cpp \
CgiHandler.cpp
SRCS := $(addprefix $(SRCS_DIR)/, $(SRCS_NAME))
OBJS := $(SRCS:.cpp=.o)
# ===== Style =====
FG_TEXT = \033[38;5;85m
FG_DEBUG = \033[48;5;2m
CL_RESET = \033[0m
CL_BOLD = \033[1m
CL_BRESET = \033[21m
# ===== Rules =====
.PHONY : all clean fclean re
all : $(NAME)
clean :
@$(RM) ./src/*.o
@echo -e "🗑 Remove $(CL_BOLD)$(NAME)'s OBJs$(CL_RESET) ... Done"
fclean : clean
@$(RM) $(NAME)
@echo -e "🗑 Remove $(CL_BOLD)$(NAME)$(CL_RESET) ... Done"
re : fclean
@make all
$(NAME) : $(OBJS)
@$(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME) -g
@echo -e " $(CL_RESET)$(FG_TEXT)Done$(CL_RESET)"
INDEX = 0
%.o : %.cpp
$(eval INDEX = $(shell expr $(INDEX) + 1))
@if [ $(INDEX) = 1 ] ; then \
echo -en "$(FG_TEXT)Creating $(CL_BOLD)$(NAME) ◼︎︎︎︎︎︎︎︎◼︎︎︎︎︎︎◼︎︎︎︎︎︎︎◼" ; \
else \
echo -en "$(FG_TEXT)◼︎︎︎︎︎︎◼︎︎︎︎︎" ; \
fi
@$(CXX) $(CXXFLAGS) $(INCD) -c $< -o $@ -g
# ===== Custom =====
.PHONY : run test
run : all
@./$(NAME)
test : all
@rm -f www/put_test/file_should_exist_after www/YoupiBanane/youpi.bla
@touch www/YoupiBanane/youpi.bla
@./$(NAME) ./config/test.conf