-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
122 lines (99 loc) · 2.72 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
NAME = ft_irc
CC = c++
ifdef DEBUG
CFLAGS = -g3 -fsanitize=address
else ifdef LEAKS
CFLAGS = -g
else
CFLAGS = -Wall -Wextra -Werror
endif
RM = rm -rf
INC_DIR = ./include/
INC = -I$(INC_DIR)
SRC_MAIN_DIR = main/
SRC_MAIN = $(addprefix $(SRC_MAIN_DIR), main.cpp)
SRC_CONTROLLER_DIR = controller/
SRC_CONTROLLER = $(addprefix $(SRC_CONTROLLER_DIR), \
BotController.cpp \
ChannelController.cpp \
Executor.cpp \
ClientController.cpp)
SRC_ENTITY_DIR = entity/
SRC_ENTITY = $(addprefix $(SRC_ENTITY_DIR), \
Channel.cpp \
Client.cpp)
SRC_HANDLER_DIR = handler/
SRC_HANDLER = $(addprefix $(SRC_HANDLER_DIR), \
EventHandler.cpp \
ErrorHandler.cpp \
ResponseHandler.cpp)
SRC_CORE_DIR = core/
SRC_CORE = $(addprefix $(SRC_CORE_DIR), \
Server.cpp \
Parser.cpp \
Command.cpp \
utility.cpp \
Socket.cpp)
SRC = $(SRC_MAIN) \
$(SRC_CONTROLLER) \
$(SRC_ENTITY) \
$(SRC_HANDLER) \
$(SRC_CORE)
SRCS_DIR = ./src/
SRCS = $(addprefix $(SRCS_DIR), $(SRC))
# OBJS_DIR = $(addprefix $(OBJ_DIR), $(SRC_MAIN_DIR) \
# $(SRC_CONTROLLER_DIR) \
# $(SRC_ENTITY_DIR) \
# $(SRC_CORE_DIR))
OBJS_DIR = ./obj/
OBJS = $(addprefix $(OBJS_DIR), $(SRC:.cpp=.o))
$(OBJS_DIR)%.o: $(SRCS_DIR)%.cpp
@mkdir -p $(OBJS_DIR)
@mkdir -p $(OBJS_DIR)/$(SRC_MAIN_DIR)
@mkdir -p $(OBJS_DIR)/$(SRC_CONTROLLER_DIR)
@mkdir -p $(OBJS_DIR)/$(SRC_CORE_DIR)
@mkdir -p $(OBJS_DIR)/$(SRC_ENTITY_DIR)
@mkdir -p $(OBJS_DIR)/$(SRC_HANDLER_DIR)
@$(CC) $(CFLAGS) $(INC) -o $@ -c $<
@echo $(CUT)$(BOLD)$(MINT) Compiling with $(CFLAGS)...$(RESET)
@echo $(CUT)$(MAUVE) [$(notdir $<)] to [$(notdir $@)] $(RESET)
@printf $(UP)$(UP)
$(NAME) : $(OBJS)
@printf $(DOWN)$(CUT)
@echo $(BOLD)$(GREEN)"🔮 Creating ft_irc"$(RESET)
@$(CC) $(CFLAGS) $(OBJS) -o $(NAME)
@printf $(CUT)$(CUT)
@echo $(BOLD)$(MINT) 🎮 $(NAME) 🎮 $(RESET)$(BOLD)is ready 🎉 $(RESET)
.PHONY : all
all: $(NAME)
.PHONY : clean
clean:
@$(RM) $(OBJS_DIR) $(NAME).dSYM
@echo $(BOLD)$(MAUVE) 🗒 object files $(RESET)$(BOLD)have been cleaned....🗑️$(RESET)
.PHONY : fclean
fclean: clean
@$(RM) $(NAME)
@echo $(BOLD)$(MINT) 🎮 $(NAME) 🎮 $(RESET)$(BOLD)has been cleaned....🗑️$(RESET)
.PHONY : re
re: fclean all
.PHONY : debug
debug : fclean
@make DEBUG=1 all
.PHONY : leaks
leaks :
@make LEAKS=1 all
######################### Color #########################
GREEN="\033[32m"
MINT="\033[38;5;51m"
L_PURPLE="\033[38;5;55m"
MAUVE="\033[38;5;147m"
PINK="\033[38;5;175m"
RESET="\033[0m"
BOLD="\033[1m"
UP = "\033[A"
DOWN = "\033[B"
RIGHT = "\033[C"
LEFT = "\033[D"
CUT = "\033[K"
SAVE = "\033[s"
RESTORE = "\033[u"