-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (58 loc) · 2.26 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: hpatsi <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/07/10 11:39:42 by hpatsi #+# #+# #
# Updated: 2024/08/23 14:06:16 by hpatsi ### ########.fr #
# #
# **************************************************************************** #
NAME=webserv
######## UTILS ########
NAMECOLOR = \033[1;36m
PIPECOLOR = \033[1;35m
FILECOLOR = \033[1;32m
OUTCOLOR = \033[1;34m
RESET = \033[0m
MESSAGE = \033[38;41m
INDENT = | sed 's/^/ /'
######## FILES ########
SRCDIR = srcs/
OBJDIR = obj/
INCLUDEDIR = include/
CPP = c++
FLAGS = -Wall -Wextra -Werror -std=c++17 \
-I$(INCLUDEDIR) -D DEBUG=1
SRC = $(wildcard $(SRCDIR)*.cpp)
OBJ = $(addprefix $(OBJDIR), $(notdir $(SRC:.cpp=.o)))
INC = $(wildcard $(INCLUDEDIR)*.hpp)
######## RULES ########
all: $(NAME)
$(NAME): $(OBJDIR) $(OBJ) $(INC)
@echo "$(NAMECOLOR)$(NAME) $(PIPECOLOR)| $(FILECOLOR)compiling executable: $(OUTCOLOR)$(NAME)$(RESET)"
@$(CPP) $(FLAGS) $(OBJ) -o $(NAME)
$(OBJDIR)%.o: $(SRCDIR)%.cpp $(INCLUDEDIR)%.hpp
@echo "$(NAMECOLOR)$(NAME) $(PIPECOLOR)| $(FILECOLOR)$< => $(OUTCOLOR)$@ $(RESET)"
@$(CPP) $(FLAGS) -c $< -o $@
$(OBJDIR)%.o: $(SRCDIR)%.cpp
@echo "$(NAMECOLOR)$(NAME) $(PIPECOLOR)| $(FILECOLOR)$< => $(OUTCOLOR)$@ $(RESET)"
@$(CPP) $(FLAGS) -c $< -o $@
$(OBJDIR):
@mkdir -p $@
clean:
@echo "$(MESSAGE)removing files:$(RESET)"
@ls $(OBJDIR)* $(INDENT)
@rm -rf $(OBJDIR)
fclean: clean
@echo "$(MESSAGE)removing executable:$(RESET)"
@echo "$(OUTCOLOR)$(NAME)$(RESET)" $(INDENT)
@rm -rf $(NAME)
re: fclean all
######## TESTS ########
test:
make
./webserv confs/local.conf
######## MISC. ########
.PHONY: all clean fclean re