forked from hanmpark/ft_irc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
125 lines (104 loc) · 2.98 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
# === Colors === #
RED := \033[0;31m
GREY := \033[0;90m
GREEN := \033[0;32m
BLUE := \033[0;34m
RESET := \033[0m
UP := \033[A
# === Prompt === #
PROMPT = ${GREY}[${BLUE}${NAME}${GREY}]${RESET}:
# === Compilation === #
CC := c++
CFLAGS = -Wall -Wextra -Werror -std=c++98
ifdef STRICT
CFLAGS += -pedantic
endif
ifdef DEBUG
CFLAGS += -fsanitize=address -g3
endif
ifdef WLOGS
CFLAGS += -D WLOGS=1
endif
# === Sources & Objects === #
# Directories
SRCS_DIR := ./srcs/
OBJS_DIR := ./objs/
HEADER := ./inc/
DEPS := ${addprefix ${HEADER}, Server.hpp \
Replies.hpp} \
${addprefix ${HEADER}channel/, Channel.hpp \
ChannelList.hpp} \
${addprefix ${HEADER}client/, Client.hpp \
ClientList.hpp} \
${addprefix ${HEADER}commands/, ACommand.hpp \
CommandList.hpp \
CAP.hpp \
INVITE.hpp \
JOIN.hpp \
KICK.hpp \
PART.hpp \
MODE.hpp \
NICK.hpp \
PASS.hpp \
PING.hpp \
PRIVMSG.hpp \
QUIT.hpp \
TOPIC.hpp \
USER.hpp}
# Files
SRCS = ${addprefix ${SRCS_DIR}, main.cpp \
Replies.cpp} \
${addprefix ${SRCS_DIR}server/, Server.cpp \
connection.cpp \
runner.cpp \
data.cpp} \
${addprefix ${SRCS_DIR}client/, Client.cpp \
ClientList.cpp} \
${addprefix ${SRCS_DIR}channel/, Channel.cpp \
ChannelList.cpp} \
${addprefix ${SRCS_DIR}commands/, CommandList.cpp \
CAP.cpp \
INVITE.cpp \
JOIN.cpp \
KICK.cpp \
MODE.cpp \
NICK.cpp \
PART.cpp \
PASS.cpp \
PING.cpp \
PRIVMSG.cpp \
QUIT.cpp \
TOPIC.cpp \
USER.cpp}
OBJS = ${SRCS:.cpp=.o}
SRC_COUNT = 0
SRC_TOT := ${shell find ${SRCS_DIR} -type f -name "*.cpp" | wc -l}
SRC_PRCT = ${shell expr 100 \* ${SRC_COUNT} / ${SRC_TOT}}
BAR = ${shell expr 23 \* ${SRC_COUNT} / ${SRC_TOT}}
${SRCS_DIR}%.o: ${SRCS_DIR}%.cpp ${DEPS}
@${eval SRC_COUNT = ${shell expr ${SRC_COUNT} + 1}}
@${CC} ${CFLAGS} -I${HEADER} -c $< -o $@
@printf "${PROMPT} ${GREEN}Compiling${RESET}\n"
@printf " ${GREY} [${GREEN}%-23.${BAR}s${GREY}] [${SRC_COUNT}/${SRC_TOT} (${SRC_PRCT}%%)]${RESET}" "***********************"
@printf "${UP}${UP}\n"
# === Rules === #
NAME = ircserv
all: ${NAME}
${NAME}: ${OBJS}
@printf "${PROMPT} ${GREEN}Linking${RESET} ${NAME} \n"
@printf " ${GREY} [${GREEN}%-23.${BAR}s${GREY}] [${SRC_COUNT}/${SRC_TOT} (${SRC_PRCT}%%)]${RESET}\n" "***********************"
@${CC} ${CFLAGS} ${OBJS} -o ${NAME}
strict:
@${MAKE} STRICT=1
debug:
@${MAKE} DEBUG=1
wlogs:
@${MAKE} WLOGS=1
clean:
@printf "${PROMPT} ${RED}Cleaning${RESET} objects\n"
@rm -f ${OBJS}
fclean: clean
@printf "${PROMPT} ${RED}Cleaning${RESET} ${NAME}\n"
@rm -f ${NAME}
re: fclean all
.PHONY: all strict debug wlogs clean fclean re