-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
46 lines (36 loc) · 1.3 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
SRC=xdg-xmenu.c
BIN=xdg-xmenu
TESTS=$(wildcard tests/test_*)
PREFIX=/usr/local
all: ${BIN}
${BIN}: ${SRC}
${CC} -o ${BIN} ${SRC} -linih
install:
install -D -m 755 ${BIN} ${DESTDIR}${PREFIX}/bin/${BIN}
install -D -m 644 ${BIN}.1 ${DESTDIR}${PREFIX}/share/man/man1/${BIN}.1
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/${BIN}
rm -f ${DESTDIR}${PREFIX}/share/man/man1/${BIN}.1
profile:
${CC} -DDEBUG -Wall -o ${BIN}-prof ${SRC} -linih -g -lprofiler
CPUPROFILE=/tmp/${BIN}.prof CPUPROFILE_FREQUENCY=1000 ./${BIN}-prof -d > /dev/null
pprof --pdf ./${BIN}-prof /tmp/${BIN}.prof > prof.pdf
rm -f ${BIN}-prof
clean:
rm -f ${BIN}
test: ${TESTS}
tests/test_*:
printf "Testing %-70s" $@
# use arguments in the */args file if provided
[ -f $@/args ] && args=$$(cat $@/args) || true
# modify XDG_DATA_* variables to search only the test directory
XDG_DATA_DIRS= XDG_DATA_HOME=$@ ./xdg-xmenu -d -i hicolor $$args > $@/output
diff $@/output $@/menu && echo "\033[32mOK\033[0m" || echo "\033[31mFailed\033[0m"
rm -f $@/output
.PHONY: install uninstall clean test ${TESTS}
# learn something new everyday: use .SILENT to disable all echos
.SILENT: ${TESTS}
# use .ONESHELL to execute all command in one shell invocation, see $args variable
.ONESHELL: ${TESTS}
# use .NOTPARALLEL to force serial execution
.NOTPARALLEL: test