-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
147 lines (120 loc) · 3.83 KB
/
Makefile
File metadata and controls
147 lines (120 loc) · 3.83 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: seyu <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/10/10 23:07:12 by seheon #+# #+# #
# Updated: 2021/08/25 15:44:06 by seyu ### ########.fr #
# #
# **************************************************************************** #
.SUFFIXES:
.SUFFIXES: .cpp .o .hpp
NAME = webserv
SHELL := /bin/zsh
CP = cp
RM = rm -f
MKDIR = mkdir -p
MV = mv
ECHO = echo
PRINTF = printf
PROGRESS= 0
# ----------------------------------
# Echo Colors
# ----------------------------------
NOCOLOR = \033[0m
RED = \033[0;31m
GREEN = \033[0;32m
ORANGE = \033[0;33m
BLUE = \033[0;34m
PURPLE = \033[0;35m
CYAN = \033[0;36m
LIGHTGRAY = \033[0;37m
DARKGRAY = \033[1;30m
LIGHTRED = \033[1;31m
LIGHTGREEN = \033[1;32m
YELLOW = \033[1;33m
LIGHTBLUE = \033[1;34m
LIGHTPURPLE = \033[1;35m
LIGHTCYAN = \033[1;36m
WHITE = \033[1;37m
# ----------------------------------
# Echo Escape Characters
# ----------------------------------
LINE_CLEAR = \33[2K\r
# ----------------------------------
# Mandatory source files
# ----------------------------------
SRCS = main.cpp
SRCS += \
CGI.cpp \
Client.cpp \
EventHandler.cpp \
FDManager.cpp \
Location.cpp \
PortManager.cpp \
Request.cpp \
RequestReader.cpp \
Resource.cpp \
Response.cpp \
ResponseWriter.cpp \
Server.cpp \
# ----------------------------------
# Object files
# ----------------------------------
OBJS = $(addprefix $(DIR_OBJ)/, $(SRCS:%.cpp=%.o))
# ----------------------------------
# Directories and Paths
# ----------------------------------
DIR_INC = ./inc
DIR_SRC = ./src
DIR_OBJ = ./obj
SUBDIRS = \
VPATH = $(DIR_SRC) $(addprefix $(DIR_SRC)/, $(SUBDIRS))
# ----------------------------------
# Compiler and flags
# ----------------------------------
CC = clang++
CFLAGS = -Wall -Wextra -Werror -g3 -fsanitize=address #-fsanitize=leak
CLIBFMW = #-lkqueue
# ----------------------------------
# Rules
# ----------------------------------
all: $(NAME)
$(DIR_OBJ):
@$(MKDIR) $@
$(DIR_OBJ)/%.o: %.cpp
@$(PRINTF) "$(LINE_CLEAR)""$(WHITE)Compiling Progress$(NOCOLOR): [%3d%%] [ " $$(expr $(PROGRESS) \* 100 \/ $$($(ECHO) $(SRCS) | wc -w))
@itr=1; while [[ $${itr} -le $(PROGRESS) ]] ; do \
$(PRINTF) '\u2588' ; \
((itr = itr + 1)) ; \
done
@itr=$$(expr $(PROGRESS) + 1); while [[ $$itr -le $$($(ECHO) $(SRCS) | wc -w) ]] ; do \
$(PRINTF) '.' ; \
((itr = itr + 1)) ; \
done
@$(PRINTF) ' ] : $(DARKGRAY)$<$(NOCOLOR) '
@$(eval PROGRESS = $(shell expr $(PROGRESS) + 1))
@$(CC) $(CFLAGS) -I$(DIR_INC) -c $< -o $@
$(NAME): $(DIR_OBJ) $(OBJS)
@$(PRINTF) "$(LINE_CLEAR)""$(WHITE)Compiling Progress$(NOCOLOR): [100%%] [ "
@itr=1; while [[ $${itr} -le $$($(ECHO) $(SRCS) | wc -w) ]] ; do \
$(PRINTF) '\u2588' ; \
((itr = itr + 1)) ; \
done
@$(ECHO) " ]"
@$(ECHO) "$(WHITE)Compiled$(NOCOLOR) all source files"
@$(CC) $(CFLAGS) -I$(DIR_INC) $(OBJS) $(CLIBFMW) -o $(NAME)
@$(ECHO)
@$(ECHO) "Usage: ./webserv [config file]"
@$(CC) cgi/reveal_cgi.cpp -o cgi/reveal_cgi.out
@$(CC) www/bin/python.cpp -o www/bin/python.bin
bonus: $(NAME)
clean:
@$(RM) -r $(DIR_OBJ)
@$(ECHO) "$(WHITE)Removed$(NOCOLOR) $(RED)$(DIR_OBJ)$(NOCOLOR)"
fclean: clean
@$(RM) -r $(NAME)
@$(ECHO) "$(WHITE)Removed$(NOCOLOR) $(RED)$(NAME)$(NOCOLOR)"
re: fclean $(NAME)