Update README.md
[pp.git] / Makefile
blob6857a56163fa061475369a01988136befe71f0a0
1 .POSIX:
3 .PHONY: all test clean install uninstall
5 CC = cc
6 CFLAGS = -std=c99 -O2 -Wall -Wextra \
7 -Walloca -Wcast-qual -Wconversion -Wformat=2 -Wformat-security -Wvla \
8 -Wnull-dereference -Wstack-protector -Wstrict-overflow=3 \
9 -Warray-bounds -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 -D_FORTIFY_SOURCE=2 \
16 -fstack-protector-strong -fsanitize=safe-stack -fPIE \
17 -fstack-clash-protection
18 # -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer \
19 # -fsanitize=undefined -fsanitize=bounds-strict \
20 # -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow \
21 # -fsanitize=integer -fsanitize-no-recover
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