-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
66 lines (50 loc) · 1.3 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
# Makefile for webserv
# ...
NAME := webserv
CC := c++
FLAGS := -Wall -Wextra -Werror --std=c++98
INC := -I include/
#HOME SRCS LIST
HSL := main.cpp
#HOME SRCS PATH
HSP := $(addprefix srcs/home/,$(HSL))
#CORE SRCS LIST
CSL := Lexer.cpp Config.cpp Server.cpp Location.cpp Utils.cpp Http.cpp Logger.cpp Client.cpp Request.cpp RequestParser.cpp Response.cpp Cgi.cpp
#CORE SRCS PATH
CSP := $(addprefix srcs/core/,$(CSL))
#SOURCES LIST WITHOUT PATH
SL := $(HSL) $(CSL)
#SOURCES WITH PATH
SRCS := $(HSP) $(CSP)
#Object
O_DIR = object/
O_LIST = $(patsubst %.cpp, %.o, $(SL))
OBJ = $(addprefix $(O_DIR), $(O_LIST))
# COLORS
GREEN = \033[0;32m
RED = \033[0;31m
RESET = \033[0m
all : $(NAME)
$(NAME): $(O_DIR) $(OBJ)
@tput el
@$(CC) $(FLAGS) $(OBJ) -o $(NAME)
@echo "$(RESET)\n$(NAME): $(GREEN)$(NAME) object files was created"
@echo "$(RESET)$(NAME): $(GREEN)$(NAME) was created"
$(O_DIR):
@mkdir -p $(O_DIR)
$(O_DIR)%.o : srcs/home/%.cpp
@echo "$(GREEN)Compiling $@"
@$(CC) $(FLAGS) $(INC) -c $< -o $@
@sleep .1
$(O_DIR)%.o : srcs/core/%.cpp
@echo "Compiling $(GREEN)$@"
@$(CC) $(FLAGS) $(INC) -c $< -o $@
@sleep .1
clean:
@rm -rf $(O_DIR)
fclean: clean
@rm -f $(NAME)
re:
@$(MAKE) fclean
@$(MAKE) all
.PHONY: all clean fclean re