-
Notifications
You must be signed in to change notification settings - Fork 3
/
GNUmakefile
102 lines (82 loc) · 2.18 KB
/
GNUmakefile
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
include config.mk
#
# dependencies
#
SRC_H = $(wildcard inc/*.h)
SRC_C = $(wildcard src/*.c)
SRC_O = $(SRC_C:.c=.o)
PRO_X = $(wildcard pro/*.xml)
PRO_H = $(PRO_X:.xml=.h)
PRO_C = $(PRO_X:.xml=.c)
PRO_O = $(PRO_X:.xml=.o)
LIB_H = $(wildcard lib/col/inc/*.h)
LIB_C = $(wildcard lib/col/src/*.c)
LIB_O = $(LIB_C:.c=.o)
TST_H = $(wildcard tst/*.h)
TST_C = $(wildcard tst/*.c)
TST_O = $(TST_C:.c=.o)
TST_E = $(patsubst tst/%.c,%,$(wildcard tst/tst-*.c))
TST_T = $(patsubst tst%,test%,$(TST_E))
#
# build
#
all: wideriver
$(SRC_O): $(SRC_H) $(PRO_H)
$(PRO_O): $(PRO_H)
$(LIB_O): $(LIB_H)
wideriver: $(SRC_O) $(PRO_O) $(LIB_O)
$(CC) -o $(@) $(^) $(LDFLAGS) $(LDLIBS)
$(PRO_H): $(PRO_X)
wayland-scanner client-header $(@:.h=.xml) $@
$(PRO_C): $(PRO_X)
wayland-scanner private-code $(@:.c=.xml) $@
clean:
rm -f wideriver $(SRC_O) $(PRO_O) $(PRO_H) $(PRO_C) $(LIB_O) $(TST_O) $(TST_E)
#
# install
#
install: wideriver man/wideriver.1
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f wideriver $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/wideriver
mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1
cp -f man/wideriver.1 $(DESTDIR)$(PREFIX)/share/man/man1
chmod 644 $(DESTDIR)$(PREFIX)/share/man/man1/wideriver.1
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/wideriver
rm -f $(DESTDIR)$(PREFIX)/share/man/man1/wideriver.1
#
# doc
#
doc: wideriver
$(MAKE) -f doc/GNUmakefile
#
# iwyu
#
iwyu: override CC = $(IWYU) -Xiwyu --check_also="inc/*h"
iwyu: clean $(SRC_O) $(TST_O)
IWYU = include-what-you-use -Xiwyu --no_fwd_decls -Xiwyu --error=1 -Xiwyu --verbose=3
#
# cppcheck
#
cppcheck: $(SRC_H) $(SRC_C) $(TST_H) $(TST_C)
cppcheck $(^) --enable=warning,unusedFunction,performance,portability --suppressions-list=.cppcheck.supp --error-exitcode=1 $(CPPFLAGS)
#
# valgrind
#
%-vg: VALGRIND = valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all --gen-suppressions=all
%-vg: % ;
#
# test
#
test: $(TST_T)
test-vg: $(TST_T)
$(TST_T): EXE = $(patsubst test%,tst%,$(@))
$(TST_T): $(SRC_O) $(PRO_O) $(LIB_O)
$(MAKE) -f tst/GNUmakefile $(EXE)
$(VALGRIND) ./$(EXE)
#
# targets
#
.PHONY: all clean install uninstall doc iwyu cppcheck test test-vg $(TST_T)
.NOTPARALLEL: iwyu test test-vg