forked from CedricHnrt/42-IRC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
184 lines (162 loc) · 5.65 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: chonorat <chonorat@student.42lyon.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/04/05 13:40:10 by chonorat #+# #+# #
# Updated: 2024/04/15 17:54:19 by chonorat ### ########.fr #
# #
# **************************************************************************** #
#COLOR
_GREEN = \033[92m
_YELLOW = \033[33m
_RED = \033[31m
#POLICE
_END = \033[0m
_BOLD = \033[1m
NAME = ircserv
BONUS_NAME = ircserv_bot
CC = @g++
INCLUDES = -I ./Includes/ \
-I ./Includes/Server \
-I ./Includes/Builders \
-I ./Includes/CacheManager \
-I ./Includes/Channel \
-I ./Includes/Commands \
-I ./Includes/Exceptions \
-I ./Includes/User \
-I ./Includes/Configuration \
-I ./Includes/Replies
C++FLAGS = -Wall -Wextra -Werror $(INCLUDES) -std=c++98 -MD -g3
C++DFLAGS = -Wall -Wextra -Werror $(INCLUDES) -std=c++20 -MD -O0 -fno-omit-frame-pointer
RM = @rm -rf
DIR = @mkdir -p
PRINT = @echo
FILES = Server/Server \
Configuration/Configuration \
Configuration/ConfigurationSection \
Exceptions/ChannelCacheException \
Exceptions/ChannelGetException \
Exceptions/ChannelBuildException \
Exceptions/UserBuildException \
Exceptions/UserCacheException \
Exceptions/UserCacheExceptionString \
Exceptions/UserConnectionException \
Exceptions/ConfigurationIOException \
Exceptions/ServerStartingException \
Exceptions/ServerInitializationException \
Utils/PrimitivePredicate \
Utils/IRCPredicate \
Utils/StringUtils \
Utils/IrcLogger \
Utils/Colors \
Utils/FileUtils \
Utils/TimeUtils \
Models/User/User \
Models/User/UserProperties \
Models/Channel/ChannelProperties \
Models/Channel/Channel \
CacheManager/ChannelCacheManager \
CacheManager/UsersCacheManager \
CacheManager/CommandManager \
Builders/UserBuilder \
Builders/ChannelBuilder \
Helpers/UserListHelper \
Replies/NumericReplies \
Commands/ICommand \
Commands/Message \
Commands/Join \
Commands/Part \
Commands/Quit \
Commands/List \
Commands/Who \
Commands/WhoIs \
Commands/Invite \
Commands/Ping \
Commands/Pong \
Commands/Mode \
Commands/Nick \
Commands/Topic \
Commands/Kick
BONUS_FILES = main \
Bot \
Exceptions/BotBuildException \
Exceptions/BotRunException
MAIN_FILES = $(FILES) \
main
DEBUG_FILES = $(FILES) \
Tests/Tests
OBJS = $(addsuffix .o, $(addprefix Objects/, $(MAIN_FILES)))
DPDS = $(addsuffix .d, $(addprefix Objects/, $(MAIN_FILES)))
DEBUG_OBJS = $(addsuffix .o, $(addprefix Objects/, $(DEBUG_FILES)))
DEBUG_DPDS = $(addsuffix .d, $(addprefix Objects/, $(DEBUG_FILES)))
BONUS_OBJS = $(addsuffix .o, $(addprefix Bonus/Objects/, $(BONUS_FILES)))
BONUS_DPDS = $(addsuffix .d, $(addprefix Bonus/Objects/, $(BONUS_FILES)))
DEBUG = false
$(NAME): $(OBJS)
$(PRINT) "\n${_YELLOW}Making $(NAME)...${_END}"
$(CC) $(OBJS) -o $(NAME)
$(PRINT) "${_BOLD}${_GREEN}$(NAME) done.\a${_END}"
$(BONUS_NAME): $(BONUS_OBJS)
$(PRINT) "\n${_YELLOW}Making $(BONUS_NAME)...${_END}"
$(CC) $(BONUS_OBJS) -o $(BONUS_NAME)
$(PRINT) "${_BOLD}${_GREEN}$(BONUS_NAME) done.\a${_END}"
debug: fclean $(DEBUG_OBJS)
ifeq ($(DEBUG), true)
$(PRINT) "\n${_BOLD}${_YELLOW}DEBUG${_END}"
$(PRINT) "\n${_YELLOW}Making $(NAME)...${_END}"
$(CC) $(DEBUG_OBJS) -o $(NAME)
$(PRINT) "${_BOLD}${_GREEN}$(NAME) done.\a${_END}"
else
$(PRINT) "${_RED}DEBUG USAGE: make debug DEBUG=true${_END}"
endif
Objects/%.o: Sources/%.cpp Makefile
$(DIR) Objects/Builders Objects/Exceptions Objects/Server Objects/Configuration \
Objects/Models/Channel Objects/Models/User Objects/CacheManager Objects/Utils \
Objects/Helpers Objects/Replies Objects/Commands
$(PRINT) "Compiling ${_BOLD}$<$(_END)..."
ifeq ($(DEBUG), true)
$(DIR) Objects/Tests
$(CC) -c $(C++DFLAGS) $< -o $@
else
$(CC) -c $(C++FLAGS) $< -o $@
endif
Bonus/Objects/%.o: Bonus/Sources/%.cpp Makefile
$(DIR) Bonus/Objects Bonus/Objects/Exceptions
$(PRINT) "Compiling ${_BOLD}$<$(_END)..."
$(CC) -c $(C++FLAGS) $< -o $@
all: $(NAME) $(BONUS_NAME)
bonus: $(BONUS_NAME)
clean:
ifneq ($(strip $(wildcard $(OBJS))),)
$(PRINT) "\n${_RED}Cleaning Objects...${_END}"
$(RM) Objects
$(PRINT) "${_GREEN}Objects cleaned.${_END}"
endif
ifneq ($(strip $(wildcard $(BONUS_OBJS))),)
$(PRINT) "${_RED}Cleaning Bonus/Objects...${_END}"
$(RM) Bonus/Objects
$(PRINT) "${_GREEN}Bonus/Objects cleaned.${_END}"
endif
fclean: clean
ifeq ($(wildcard $(NAME)), $(NAME))
$(PRINT) "${_RED}Deleting $(NAME)...${_END}"
$(RM) $(NAME)
$(PRINT) "${_GREEN}$(NAME) deleted.\a${_END}"
endif
ifeq ($(wildcard $(BONUS_NAME)), $(BONUS_NAME))
$(PRINT) "${_RED}Deleting $(BONUS_NAME)...${_END}"
$(RM) $(BONUS_NAME)
$(PRINT) "${_GREEN}$(BONUS_NAME) deleted.\a${_END}"
endif
re: fclean all
exec : all
./ircserv 7777 434
val : all
valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes ./ircserv 7777 434
.PHONY: all clean fclean re exec val bonus debug
-include $(DPDS)
-include $(DEBUG_DPDS)
-include $(BONUS_DPDS)