-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (69 loc) · 1.81 KB
/
Makefile
File metadata and controls
86 lines (69 loc) · 1.81 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
# Names
NAME = webserv
# Compilation
CXX = c++
CXXFLAG = -std=c++98 -Wall -Werror -Wextra
RM = rm -rf
SRC_DIR = srcs/
SRC = $(notdir $(shell find $(SRC_DIR) -type f -name "*.cpp"))
OBJ_DIR = obj
OBJ = $(addprefix $(OBJ_DIR)/,$(SRC:.cpp=.o))
INC_DIR = headers
INC = $(shell find $(INC_DIR) -type f -name "*.hpp")
IFLAGS = -I $(INC_DIR)
vpath %.cpp $(shell find $(SRC_DIR) -type d)
.SUFFIXES: .cpp .o .hpp
# Color
_YELLOW = \033[38;5;184m
_GREEN = \033[38;5;46m
_RESET = \033[0m
_INFO = [$(_YELLOW)INFO$(_RESET)]
_SUCCESS = [$(_GREEN)SUCCESS$(_RESET)]
_CLEAR = \033[2K\c
# Rules
# Defaults:
all : init $(NAME)
@ echo "$(_SUCCESS) Compilation done"
container_init :
mkdir -p container/volume
mkdir -p container/html
mkdir -p container/conf
cp -r srcs container/volume
cp -r headers container/volume
cp -r html container
cp -r conf container
cp Makefile container/volume
# Bonus:
bonus : all
# Init:
init :
@ $(shell mkdir -p $(OBJ_DIR))
# Compile:
$(NAME) : $(OBJ) $(INC)
@ echo "$(_INFO) Initialize $(NAME)"
@ $(CXX) $(CXXFLAG) $(IFLAGS) -o $(NAME) $(OBJ)
$(OBJ_DIR)/%.o : %.cpp
@ echo "\t$(_YELLOW)Compiling$(_RESET) $*.cpp"
@ $(CXX) $(CXXFLAG) $(IFLAGS) -c $< -o $@
@ echo "$(_CLEAR)"
# Clean:
clean :
@ echo "$(_INFO) Deleted object files and directories"
@ $(RM) $(OBJ_DIR)
@ echo "$(_SUCCESS) Working directory clean"
clean_container :
@ echo "$(_INFO) Deleting container files"
$(RM) container/volume
$(RM) container/conf
$(RM) container/html
# FClean:
fclean : clean
@ $(RM) $(NAME)
# Re:
re : fclean all
# Norminette:
norminette :
@ ~/.norminette/norminette.rb $(SRC_DIR)
@ ~/.norminette/norminette.rb $(INC_DIR)
# Phony:
.PHONY: all fclean clean re