forked from denicem/42-webserv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
130 lines (104 loc) · 4 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
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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: shaas <shaas@student.42heilbronn.de> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/11/08 22:02:51 by shaas #+# #+# #
# Updated: 2023/01/13 19:20:10 by shaas ### ########.fr #
# #
# **************************************************************************** #
NAME = webserv
BS4INSTALLED := $(shell pip3 show bs4 | grep Name)
ISDOCKER := $(shell ls -a /)
ifeq ( , $(findstring .dockerenv, $(ISDOCKER)))
CC = c++
else
CC = g++
endif
CC_FLAGS = -Wall -Wextra -Werror -std=c++98 -g
DIR_OBJ = obj/
DIR_SRC = src/
DIR_CGI_SRC = cgi-bin/cgi-src/
DIR_CGI_OBJ = cgi-bin/
SRC := $(shell find $(DIR_SRC) -name "*.cpp")
OBJ := $(patsubst $(DIR_SRC)%.cpp, $(DIR_OBJ)%.o, $(SRC))
CGI_SRC := $(shell find $(DIR_CGI_SRC) -name "*.cpp")
CGI_OBJ := $(patsubst $(DIR_CGI_SRC)%.cpp, $(DIR_CGI_OBJ)%.cgi, $(CGI_SRC))
INCLUDE := -I./inc/
# **************************************************************************** #
# RULES #
# **************************************************************************** #
all: $(CGI_OBJ) $(NAME)
$(NAME): $(OBJ)
@printf $(BLUE)"Linking objects to a binary file\r"$(RESET)
@$(CC) $(CC_FLAGS) $(INCLUDE) $^ -o $@
@printf $(SPACE)$(GREEN)"[✓]\n"$(RESET)
@printf $(GREEN)$(BOLD)"\t\tCOMPLETE!\n\n"$(RESET)
@printf $(MAGENTA)"\t\tName of executable: "$(RESET)$(BOLD)$(MAGENTA_BG)" $(NAME) "$(RESET)"\n\n"
$(DIR_OBJ)%.o: $(DIR_SRC)%.cpp
@mkdir -p $(dir $@)
@printf $(BLUE)$(BOLD)"\rCompiling: "$(CYAN)"$(notdir $<)\r"
@$(CC) $(CC_FLAGS) $(INCLUDE) -c $< -o $@
@printf $(SPACE)$(GREEN)"[✓]\n"$(RESET)
$(DIR_CGI_OBJ)%.cgi: $(DIR_CGI_SRC)%.cpp
@printf $(BLUE)$(BOLD)"\rCompiling: "$(CYAN)"$(notdir $<)\r"
@$(CC) $< -o $@
@printf $(SPACE)$(GREEN)"[✓]\n"$(RESET)
install:
@pip3 --disable-pip-version-check install bs4 > /dev/null
@pip3 --disable-pip-version-check install requests > /dev/null
@brew install siege
@printf $(CYAN)$(BOLD)"Required packages installed [✓]\n"$(RESET)
clean:
@printf $(MAGENTA)"Removing object files...\r"$(RESET)
@rm -rf $(DIR_OBJ)
@printf $(SPACE)$(GREEN)"[✓]\n"$(RESET)
fclean: clean
@printf $(MAGENTA)"Removing binary file...\r"$(RESET)
@rm -rf $(NAME)
@rm -rf $(CGI_OBJ)
@printf $(SPACE)$(GREEN)"[✓]\n\n"$(RESET)
re: fclean all
exe:
# export PYTHONPATH="`python3 -m site --user-base`/lib/python/site-packages"
./$(NAME)
run: all exe
.PHONY: all clean fclean re exe
# **************************************************************************** #
# TEXT MODIFIERS / FORMATITING CODES #
# **************************************************************************** #
RED = "\e[31m"
GREEN = "\e[32m"
YELLOW = "\e[33m"
BLUE = "\e[34m"
MAGENTA = "\e[35m"
CYAN = "\e[36m"
LIGHTGRAY = "\e[37m"
DARKGRAY = "\e[90m"
LIGHTRED = "\e[91m"
LIGHTGREEN = "\e[92m"
LIGHTYELLOW = "\e[93m"
LIGHTBLUE = "\e[94m"
LIGHTMAGENTA = "\e[95m"
LIGHTCYAN = "\e[96m"
RED_BG = "\e[41m"
GREEN_BG = "\e[42m"
YELLOW_BG = "\e[43m"
BLUE_BG = "\e[44m"
MAGENTA_BG = "\e[45m"
CYAN_BG = "\e[46m"
LIGHTGRAY_BG = "\e[47m"
DARKGRAY_BG = "\e[100m"
LIGHTRED_BG = "\e[101m"
LIGHTGREEN_BG = "\e[102m"
LIGHTYELLOW_BG = "\e[103m"
LIGHTBLUE_BG = "\e[104m"
LIGHTMAGENTA_BG = "\e[105m"
LIGHTCYAN_BG = "\e[106m"
BOLD = "\e[1m"
ITALIC = "\e[3m"
UNDERLINED = "\e[4m"
RESET = "\e[0m"
SPACE = "\e[50C"