forked from AndreRenaud/PDFGen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
66 lines (51 loc) · 2.47 KB
/
Makefile
File metadata and controls
66 lines (51 loc) · 2.47 KB
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
LFLAGS=-fprofile-arcs -ftest-coverage
CLANG=clang
CLANG_FORMAT=clang-format
XXD=xxd
ifeq ($(OS),Windows_NT)
CFLAGS=-Wall
CFLAGS_OBJECT=/Fo:
CFLAGS_EXE=/Fe:
O_SUFFIX=.obj
else
CFLAGS=-g -Wall -pipe --std=c1x -O3 -pedantic -Wsuggest-attribute=const -Wsuggest-attribute=format -Wclobbered -Wempty-body -Wignored-qualifiers -Wmissing-field-initializers -Wold-style-declaration -Wmissing-parameter-type -Woverride-init -Wtype-limits -Wuninitialized -Wunused-but-set-parameter -fprofile-arcs -ftest-coverage
CFLAGS_OBJECT=-o
CFLAGS_EXE=-o
O_SUFFIX=.o
endif
default: testprog
testprog: pdfgen$(O_SUFFIX) tests/main$(O_SUFFIX) tests/penguin$(O_SUFFIX)
$(CC) $(CFLAGS_EXE) $@ pdfgen$(O_SUFFIX) tests/main$(O_SUFFIX) tests/penguin$(O_SUFFIX) $(LFLAGS)
tests/fuzz-%: tests/fuzz-%.c pdfgen.c
$(CLANG) -I. -g -o $@ $< pdfgen.c -fsanitize=fuzzer,address
tests/penguin.c: data/penguin.jpg
# Convert data/penguin.jpg to a C source file with binary data in a variable
$(XXD) -i $< > $@ || ( rm -f $@ ; false )
%$(O_SUFFIX): %.c
$(CC) -I. -c $< $(CFLAGS_OBJECT) $@ $(CFLAGS)
check: testprog pdfgen.c pdfgen.h example-check
cppcheck --std=c99 --enable=style,warning,performance,portability,unusedFunction --quiet pdfgen.c pdfgen.h tests/main.c
./tests.sh
./tests.sh acroread
$(CLANG_FORMAT) pdfgen.c | colordiff -u pdfgen.c -
$(CLANG_FORMAT) pdfgen.h | colordiff -u pdfgen.h -
$(CLANG_FORMAT) tests/main.c | colordiff -u tests/main.c -
gcov -r pdfgen.c
example-check: FORCE
# Extract the code block from the README & make sure it compiles
sed -n '/^```/,/^```/ p' < README.md | sed '/^```/ d' > example-check.c
$(CC) $(CFLAGS) -o example-check example-check.c pdfgen.c $(LFLAGS)
rm example-check example-check.c
check-fuzz-%: tests/fuzz-% FORCE
mkdir -p fuzz-artifacts
./$< -verbosity=0 -max_total_time=60 -max_len=4096 -rss_limit_mb=1024 -artifact_prefix="./fuzz-artifacts/"
fuzz-check: check-fuzz-ppm check-fuzz-jpg check-fuzz-header check-fuzz-text check-fuzz-dstr
format: FORCE
$(CLANG_FORMAT) -i pdfgen.c pdfgen.h tests/main.c tests/fuzz-ppm.c tests/fuzz-jpg.c tests/fuzz-header.c tests/fuzz-text.c
docs: FORCE
doxygen pdfgen.dox 2>&1 | tee doxygen.log
cat doxygen.log | test `wc -c` -le 0
FORCE:
clean:
rm -f *$(O_SUFFIX) tests/*$(O_SUFFIX) testprog *.gcda *.gcno *.gcov tests/*.gcda tests/*.gcno output.pdf output.txt tests/fuzz-ppm tests/fuzz-jpg tests/fuzz-header tests/fuzz-text output.pdftk fuzz.jpg fuzz.ppm fuzz.pdf doxygen.log tests/penguin.c valgrind.log
rm -rf docs fuzz-artifacts infer-out