-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (94 loc) · 4.25 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: bsoubaig <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/03/12 17:45:22 by bsoubaig #+# #+# #
# Updated: 2024/03/11 18:00:40 by bsoubaig ### ########.fr #
# #
# **************************************************************************** #
# Colors constants
PURPLE = \033[38;5;141m
GREEN = \033[38;5;46m
RED = \033[0;31m
GREY = \033[38;5;240m
RESET = \033[0m
BOLD = \033[1m
CLEAR = \r\033[K
# Executable and compilation
NAME = ircserv
SRC_DIR = ./srcs/
SRCS = entities/User.cpp \
entities/Server.cpp \
entities/Channel.cpp \
commands/ACommand.cpp \
commands/PassCommand.cpp \
commands/NickCommand.cpp \
commands/UserCommand.cpp \
commands/PingCommand.cpp \
commands/KickCommand.cpp \
commands/InviteCommand.cpp \
commands/TopicCommand.cpp \
commands/ModeCommand.cpp \
commands/CapCommand.cpp \
commands/JoinCommand.cpp \
commands/PrivmsgCommand.cpp \
commands/PartCommand.cpp \
commands/QuitCommand.cpp \
Executor.cpp \
IRCLogger.cpp \
Utils.cpp \
main.cpp \
OBJ_DIR = ./objs/
OBJS = ${addprefix ${OBJ_DIR}, ${SRCS:.cpp=.o}}
CC = c++
CFLAGS = -Wall -Wextra -Werror -std=c++98 -pedantic -ggdb3
RM = rm -rf
# Checking OS type
UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S),Linux)
ifneq ($(UNAME_S),Darwin)
$(error Unsupported OS $(UNAME_S))
endif
endif
# Adding a specific flag for MacOS not Intel based
ifeq ($(UNAME_S),Darwin)
CFLAGS += -arch x86_64
endif
# Debug compilation is launched
ifdef DEBUG
ifeq ($(UNAME_S),Linux)
CFLAGS += -fsanitize=leak -g
endif
endif
# Compile with logs
ifdef WLOGS
CFLAGS += -D LOGS=true
endif
${OBJ_DIR}%.o: ${SRC_DIR}%.cpp
@printf "${CLEAR}${RESET}${GREEN}»${RESET} [${PURPLE}${BOLD}${NAME}${RESET}]: Compiling ${GREEN}%s${RESET}...${GREY}" ${notdir $<}
@${CC} ${CFLAGS} -I${SRC_DIR} -c $< -o $@
all: $(NAME)
$(NAME): $(OBJS)
@$(CC) $(CFLAGS) $(OBJS) -o $(NAME)
@clear
@printf "${CLEAR}${RESET}${GREY}────────────────────────────────────────────────────────────────────────────\n${RESET}${GREEN}»${RESET} [${PURPLE}${BOLD}${NAME}${RESET}]: ${RED}${BOLD}${NAME} ${RESET}compiled ${GREEN}successfully${RESET}.${GREY}\n${RESET}${GREY}────────────────────────────────────────────────────────────────────────────\n${RESET}"
${OBJS}: | ${OBJ_DIR}
${OBJ_DIR}:
@mkdir -p ${OBJ_DIR}/entities
@mkdir -p ${OBJ_DIR}/commands
debug:
@make DEBUG=1 re
logs:
@make WLOGS=true re
clean:
@${RM} ${OBJ_DIR}
@printf "${CLEAR}${RESET}${GREEN}»${RESET} [${PURPLE}${BOLD}${NAME}${RESET}]: Objects were cleaned ${GREEN}successfully${RESET}.\n${RESET}"
fclean: clean
@${RM} ${NAME}
@printf "${CLEAR}${RESET}${GREY}────────────────────────────────────────────────────────────────────────────\n${RESET}${GREEN}»${RESET} [${PURPLE}${BOLD}${NAME}${RESET}]: Project cleaned ${GREEN}successfully${RESET}.${GREY}\n${RESET}${GREY}────────────────────────────────────────────────────────────────────────────\n${RESET}"
re: fclean all
.SILENT: all clean fclean re
.PHONY: all clean fclean re