-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (91 loc) · 2.4 KB
/
Copy pathMakefile
File metadata and controls
107 lines (91 loc) · 2.4 KB
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
# Output Name:
NAME:= ircserv
# Folders:
BUILD:= ./build
SOURCE:= ./source
TESTS:= ./tests
# Other Variables:
COMPILER:= c++
COMPFLAGS:= -Wall -Werror -Wextra -g -std=c++98
# Source Files:
SRCFILES:=\
main.cpp\
utils.cpp\
irc.cpp\
client/client.cpp\
message/message.cpp\
channel/channel.cpp\
commands/channel/invite.cpp\
commands/channel/join.cpp\
commands/channel/kick.cpp\
commands/channel/list.cpp\
commands/channel/mode.cpp\
commands/channel/modeusr.cpp\
commands/channel/names.cpp\
commands/channel/part.cpp\
commands/channel/topic.cpp\
commands/connection/away.cpp\
commands/connection/nick.cpp\
commands/connection/oper.cpp\
commands/connection/pass.cpp\
commands/connection/quit.cpp\
commands/connection/user.cpp\
commands/connection/welcome.cpp\
commands/connection/motd.cpp\
commands/message/notice.cpp\
commands/message/ping.cpp\
commands/message/privmsg.cpp\
commands/queries/who.cpp\
commands/queries/whois.cpp\
commands/queries/time.cpp\
commands/queries/version.cpp\
commands/optional/ison.cpp\
commands/optional/dummy.cpp\
commands/server/admin.cpp\
commands/server/info.cpp\
# ------------------------------------------
# Do not change anything beyond this point!
# ------------------------------------------
# Process Variables
CXX:= $(COMPILER)
CXXFLAGS:= $(COMPFLAGS)
SRCS:= $(addprefix $(SOURCE)/,$(SRCFILES))
OBJS:= $(SRCS:$(SOURCE)/%.cpp=$(BUILD)/%.o)
NAME:= ./$(NAME)
OS:= $(shell uname -s)
.PHONY: all clean fclean re test run
# Catch Rules
all:
make -j $(nproc) $(NAME)
# Compile .cpp files to .o Files
$(OBJS): $(BUILD)%.o : $(SOURCE)%.cpp
@mkdir -p $(dir $@)
$(CXX) -c $(CXXFLAGS) $< -o $@
# Main Build Rule
$(NAME): $(OBJS)
@echo "--> Compiling Executable"
$(CXX) $(CXXFLAGS) $(OBJS) -o $(NAME)
# Clean up Objects
clean:
$(RM) -r $(BUILD)
# Clean up Executables and static libraries
fclean: clean
$(RM) -r $(NAME)
# Clean the re-compile
re: fclean all
# Run the test script
test: re
ifeq ($(wildcard $(TESTS)/test.sh),)
$(error "Test Script test.sh not found in $(TESTS)")
endif
@./tests/test.sh
#Run the executable
run: re
@echo "--------------------------------"
ifeq ($(OS),Linux)
valgrind -q --leak-check=full --errors-for-leak-kinds=all $(NAME) 6669 ""
else ifeq ($(OS),Darwin)
leaks -q --atExit -- $(NAME) 6669 "h"
else
$(NAME) 6669 ""
endif