-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (57 loc) · 2.12 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: dfarhi <dfarhi@student.42lausanne.ch> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/06/22 19:19:03 by davifah #+# #+# #
# Updated: 2023/05/09 15:26:48 by dfarhi ### ########.fr #
# #
# **************************************************************************** #
MAIN = src/main.o
FILES = Channel.cpp Client.cpp IRCServer.cpp MessageParser.cpp main.cpp
FILES := $(addprefix src/, ${FILES})
FILES := $(filter-out src/main.cpp, $(FILES))
OBJS = ${FILES:.cpp=.o}
NAME = ircserv
CC = c++
CC_OPTIONS = -Wall -Wextra -Werror
INCLUDES = -I./include
LIB =
SYSTEM = $(shell uname -s)
STD98 = 1
ifeq ($(STD98), 1)
CC_OPTIONS := $(CC_OPTIONS) -std=c++98 -pedantic
ifeq ($(SYSTEM), Linux)
LIB := ${LIB} -DLINUX_OS
endif
ifeq ($(SYSTEM), Darwin)
CC := g++
endif
endif
all: ${NAME}
${NAME}: ${OBJS} ${MAIN}
${CC} ${CC_OPTIONS} ${INCLUDES} -o ${NAME} ${MAIN} ${OBJS} ${LIB}
.cpp.o:
${CC} ${CC_OPTIONS} -c ${INCLUDES} $< -o ${<:.cpp=.o}
AddressSanitizer: CC_OPTIONS := ${CC_OPTIONS} -fsanitize=address -g
ifeq ($(SYSTEM), Linux)
AddressSanitizer: CC_OPTIONS := ${CC_OPTIONS} -static-libasan
endif
AddressSanitizer: all
# cmd to prof code:
# gprof ${NAME} gmon.out > analysis.txt
profile: fclean
profile: CC_OPTIONS := ${CC_OPTIONS} -pg
profile: all
cmake:
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S . build/
ln -sf build/compile_commands.json compile_commands.json
clean:
rm -f ${OBJS}
rm -f ${MAIN}
fclean: clean
rm -f ${NAME}
re: fclean all
.PHONY: all clean fclean re AddressSanitizer