-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
73 lines (61 loc) · 1.88 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
CXX := clang++
NAME := webserv
RM := rm -f
SRCS := srcs/main.cpp \
\
srcs/components/components.cpp \
\
srcs/lib/split.cpp srcs/lib/gnl.cpp srcs/lib/file.cpp \
srcs/lib/utils.cpp srcs/lib/argv.cpp \
\
srcs/middlewares/body.cpp srcs/middlewares/Cgi.cpp \
srcs/middlewares/eject.cpp srcs/middlewares/error.cpp \
srcs/middlewares/forbidden.cpp srcs/middlewares/keep_alive.cpp \
srcs/middlewares/log_request.cpp \
srcs/middlewares/mimetypes.cpp srcs/middlewares/read.cpp \
srcs/middlewares/redirect.cpp srcs/middlewares/remover.cpp \
srcs/middlewares/upload.cpp srcs/middlewares/write_body.cpp \
srcs/middlewares/write_headers.cpp \
\
srcs/serve/Definition.cpp srcs/serve/Chain.cpp \
srcs/serve/Serve.cpp \
\
srcs/static/Static.cpp
LIBRARY ?= -I ./srcs/components/includes \
-I ./srcs/help \
-I ./srcs/includes \
-I ./srcs/lib/includes \
-I ./srcs/middlewares/includes \
-I ./srcs/serve/includes \
-I ./srcs/static/includes \
-I ./srcs
OBJS := $(SRCS:.cpp=.o)
CXXFLAGS ?= -Wall -Werror -Wextra -std=c++98 $(LIBRARY)
# Colors
RED := \e[0;91m
GREEN := \e[0;92m
BLUE := \e[0;94m
MAGENTA := \e[0;95m
RESET := \e[0;0m
PREFIX := $(MAGENTA)$(NAME)$(RESET) =>
$(NAME): $(OBJS)
@echo "$(PREFIX)$(GREEN)Bundling $(RESET)$(NAME)$(GREEN) executable$(RESET)"
@$(CXX) $(CXXFLAGS) $(OBJS) $(LIBRARY) -o $@
%.o: %.cpp
@echo "$(PREFIX)$(GREEN)Compiling file $(RESET)$< $(BLUE)to $(RESET)$@"
@$(CXX) $(CXXFLAGS) $(LIBRARY) -c $< -o $@
all: help $(NAME)
help:
@if command -v xxd > /dev/null; then \
echo "$(PREFIX)$(GREEN)xxd generate documentation$(RESET)"; \
xxd -i ./srcs/help/documentation > srcs/help/generateDocumentation.hpp; \
else \
echo "$(PREFIX)$(RED)xxd command is not present, skip this part$(RESET)"; \
fi
fclean:
$(RM) $(OBJS)
$(RM) $(NAME)
clean:
$(RM) $(OBJS)
re: fclean
$(MAKE) all