-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
67 lines (49 loc) · 1.92 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
CFLAGS:=-std=gnu11 -O2 -pedantic -Wall -Wextra -Wwrite-strings -Warray-bounds -Wconversion -Wstrict-prototypes -Werror $(shell pkg-config --cflags libnotify) $(CFLAGS)
CPPFLAGS:=$(CPPFLAGS)
LDFLAGS:=$(shell pkg-config --libs libnotify) $(LDFLAGS)
INSTALL:=install
prefix:=/usr/local
bindir:=$(prefix)/bin
datarootdir:=$(prefix)/share
mandir:=$(datarootdir)/man
SOURCES=$(wildcard *.c)
EXECUTABLES=$(patsubst %.c,%,$(SOURCES))
.PHONY: test
all: $(EXECUTABLES)
%: %.c %.h
$(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$<) -o $@ $(LIBS) $(LDFLAGS)
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) $< -c -o $@
%: %.o
$(CC) $< -o $@ $(LIBS) $(LDFLAGS)
# Noisy clang build that's expected to fail, but can be useful to find corner
# cases.
clang-everything: CC=clang
clang-everything: CFLAGS+=-Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-unused-macros -Wno-covered-switch-default
clang-everything: all
sanitisers: CFLAGS+=-fsanitize=address -fsanitize=undefined -fanalyzer
sanitisers: debug
debug: CFLAGS+=-Og -ggdb -fno-omit-frame-pointer
debug: all
afl: CC=afl-gcc
afl: CFLAGS+=-DWANT_FUZZER
afl: export AFL_HARDEN=1 AFL_USE_ASAN=1
afl: sanitisers
fuzz-configs: afl
fuzz/configs/run
fuzz-pressures: afl
fuzz/pressures/run
clang-tidy:
# DeprecatedOrUnsafeBufferHandling: See https://stackoverflow.com/a/50724865/945780
clang-tidy psi-notify.c -checks=-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling -- $(CFLAGS) $(LDFLAGS)
install: all
mkdir -p $(DESTDIR)$(bindir)/
$(INSTALL) -pt $(DESTDIR)$(bindir)/ $(EXECUTABLES)
$(INSTALL) -Dp -m 644 psi-notify.service $(DESTDIR)$(prefix)/lib/systemd/user/psi-notify.service
$(INSTALL) -Dp -m 644 psi-notify.1 $(DESTDIR)$(mandir)/man1/psi-notify.1
test: CFLAGS+=-D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -Og -ggdb -fno-omit-frame-pointer
test:
$(CC) $(CPPFLAGS) $(CFLAGS) test/test.c -o test/test $(LIBS) $(LDFLAGS)
test/test
clean:
rm -f $(EXECUTABLES) test/test