-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (61 loc) · 1.74 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
NAME = webserv
CXX = c++
CXXFLAGS = -Wall -Wextra -Werror -std=c++98 -gdwarf-4
LDFLAGS = -lstdc++ # Add the C++ standard library
SRC_DIR = source
INC_DIR = include
BUILD_DIR = build
SRCS = $(shell find $(SRC_DIR) -name "*.cpp")
OBJ_DIR = $(BUILD_DIR)/objects
DEP_DIR = $(BUILD_DIR)/dependencies
OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
DEPS = $(patsubst $(SRC_DIR)/%.cpp, $(DEP_DIR)/%.d, $(SRCS))
INCFLAGS = $(shell find $(INC_DIR) -type d -exec echo -I{} \;)
all: $(NAME)
$(NAME): $(OBJS) $(DEPS)
$(CXX) $(CXXFLAGS) $(INCFLAGS) $(LDFLAGS) $(OBJS) -o $(NAME)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCFLAGS) -c $< -o $@
$(DEP_DIR)/%.d: $(SRC_DIR)/%.cpp
mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(INCFLAGS) -M -MP -MF $@ $<
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),fclean)
-include $(DEPS)
endif
endif
clean:
rm -rf $(BUILD_DIR)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re
# **************************** COLORS ******************************* #
STY_RES := "\e[0m"
STY_BOL := "\e[1m"
STY_ITA := "\e[3m"
STY_UND := "\e[4m"
STY_RED := "\e[31m"
STY_GRE := "\e[32m"
STY_YEL := "\e[33m"
STY_BLU := "\e[34m"
STY_MAG := "\e[35m"
STY_CYA := "\e[36m"
STY_WHI := "\e[37m"
STY_GRA := "\e[90m"
STY_WHI_BRI := "\e[97m"
STY_BLA_BG := "\e[40m"
STY_RED_BG := "\e[41m"
STY_GRE_BG := "\e[42m"
STY_YEL_BG := "\e[43m"
STY_BLU_BG := "\e[44m"
STY_MAG_BG := "\e[45m"
STY_CYA_BG := "\e[46m"
STY_WHI_BG := "\e[47m"
STY_GRA_BG := "\e[100m"
STY_WHI_BRI_BG := "\e[107m"
# *************************** MAKEFILE DEBUGGING ***************************** #
# Execute "make print-[variable name]" to list the variable's values
print-% :
echo $* = $($*)