-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
103 lines (80 loc) · 2.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
NAME := ircserv
CC := c++
# Flags used by default
CFLAGS := -Wall -Wextra -Werror \
-std=c++14
# Flags used by default, except with "make release"
DFLAGS := -DDEBUG \
-g3 \
-Wconversion \
-Wdouble-promotion
# Flags used with DFLAGS, except with "make lldb"
SFLAGS := -fsanitize=address,undefined,unreachable,null
# Flags used only with "make release"
RFLAGS := -O3
rwildcard = $(strip $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)$(filter $(subst *,%,$2),$d)))
SRCS := $(strip $(call rwildcard,src/,*.cpp))
INCS := $(strip $(call rwildcard,src/,*.h)) $(strip $(call rwildcard,src/,*.hpp))
OBJS := $(strip $(patsubst src/%, obj/%, $(SRCS:.cpp=.o)))
TEST_SRCS := $(strip $(call rwildcard,test/,*.cpp))
NOMAIN_SRCS := $(filter-out src/main/main.cpp, $(SRCS))
.PHONY: all
all: CFLAGS += $(DFLAGS)
all: CFLAGS += $(SFLAGS)
all: $(NAME)
$(NAME): $(OBJS) $(INCS)
$(CC) $(CFLAGS) -o $(NAME) $(OBJS)
obj/%.o: src/%.cpp
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -I$(dir $<) -Isrc/common -c -o $@ $<
.PHONY: clean
clean:
rm -rf obj/
rm -rf $(NAME).dSYM
rm -f test.out
.PHONY: fclean
fclean: clean
rm -f $(NAME)
.PHONY: re
re: fclean all
.PHONY: nuke
nuke:
git clean -dxf
git reset --hard
.PHONY: makefile-debug
makefile-debug:
$(info NAME=$(NAME))
$(info CC=$(CC))
$(info CFLAGS=$(CFLAGS))
$(info SRCS=$(SRCS))
$(info OBJS=$(OBJS))
$(info TEST_SRCS=$(TEST_SRCS))
$(info NOMAIN_SRCS=$(NOMAIN_SRCS))
.PHONY: run
run: all
./run.sh 6667 horse
.PHONY: ports
ports:
@echo "ircserv running on ports and sockets:"
@lsof -i -P -n | grep "ircserv" | tr -s ' ' | cut -d' ' -f1,2,5,9,10
.PHONY: kill
kill:
@lsof -i -P -n | grep "ircserv" | tr -s ' ' | cut -d' ' -f2 | sort | uniq | xargs kill -9
.PHONY: softkill
softkill:
@lsof -i -P -n | grep "ircserv" | tr -s ' ' | cut -d' ' -f2 | sort | uniq | xargs kill
.PHONY: release
release: CFLAGS += $(RFLAGS)
release: fclean $(NAME)
.PHONY: lldb
lldb: CFLAGS += $(DFLAGS)
lldb: fclean $(NAME)
.PHONY: test
test: $(TEST_SRCS) $(NOMAIN_SRCS)
$(CC) $(CFLAGS) -o test.out $(TEST_SRCS) $(NOMAIN_SRCS)
./test.out $(ARGS)
.PHONY: git-clean-branches
git-clean-branches:
git checkout main
git fetch -p
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d