Add explanation on how to provide own make flags
[pp.git] / Makefile
blobc3c9aa3003c72550485d1049ce1f10ea86c01d2e
1 .POSIX:
3 .PHONY: all test clean install uninstall
5 CC = clang
6 CFLAGS = -std=c99 -O2 -Wall -Wextra \
7 -Walloca -Wcast-qual -Wconversion -Wformat=2 -Wformat-security -Wvla \
8 -Wnull-dereference -Wstack-protector -Warray-bounds \
9 -Warray-bounds-pointer-arithmetic -Wassign-enum \
10 -Wbad-function-cast -Wconditional-uninitialized -Wconversion \
11 -Wfloat-equal -Wformat-type-confusion -Widiomatic-parentheses \
12 -Wimplicit-fallthrough -Wloop-analysis -Wpointer-arith \
13 -Wshift-sign-overflow -Wshorten-64-to-32 -Wswitch-enum \
14 -Wtautological-constant-in-range-compare -Wunreachable-code-aggressive \
15 -Wthread-safety -Wthread-safety-beta -Wcomma \
16 -D_FORTIFY_SOURCE=2 \
17 -fstack-protector-strong -fsanitize=safe-stack -fPIE \
18 -fstack-clash-protection
19 # -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer \
20 # -fsanitize=undefined -fsanitize=float-divide-by-zero \
21 # -fsanitize=float-cast-overflow -fsanitize=integer
23 LDFLAGS = -fsanitize=safe-stack -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack \
24 -Wl,-z,separate-code
25 LDLIBS =
26 PREFIX = /usr/local
27 RM = rm
29 SRCS != echo src/*.c
30 OBJS = $(SRCS:.c=.o)
32 all: pp
34 pp: $(OBJS)
35 $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
37 pp.o: pp.c
39 test: pp
40 ./test/harness.sh
42 clean:
43 $(RM) -f $(OBJS) pp
45 install: pp pp.1
46 mkdir -p $(DESTDIR)$(PREFIX)/bin
47 install -m 755 pp $(DESTDIR)$(PREFIX)/bin
48 mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1
49 gzip < pp.1 > $(DESTDIR)$(PREFIX)/share/man/man1/pp.1.gz
51 uninstall:
52 $(RM) -f $(DESTDIR)$(PREFIX)/bin/pp
53 $(RM) -f $(DESTDIR)$(PREFIX)/share/man/man1/pp.1.gz