This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (36 loc) · 1.63 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
COMMON_FLAGS=-g -D_GNU_SOURCE -pedantic -Wall -Werror -Wextra -Wpacked -Wshadow -std=c99 -m64 -O3 -Wno-format -Wno-absolute-value
CFLAGS=$(COMMON_FLAGS) -DNDEBUG -fomit-frame-pointer
DEBUG_FLAGS=$(COMMON_FLAGS)
CODE_FILES=$(wildcard *.c *.h Makefile)
BENCH_FILES=$(CODE_FILES) $(wildcard benches/*.c benches/*.h)
TEST_FILES=$(CODE_FILES) $(wildcard tests/*.c tests/*.h)
FILTER_FILES=Makefile %.h
all: weak
weak: $(CODE_FILES)
./genver.sh
$(CC) $(CFLAGS) $(filter-out $(FILTER_FILES), $^) -o $@
# Typically, we don't want to run long-running benchmarks. Default to QUICK_BENCH.
bench: $(BENCH_FILES)
$(CC) $(CFLAGS) -DQUICK_BENCH $(filter-out $(FILTER_FILES) main.c, $^) -o benches/bench
./benches/bench
benchfull: $(BENCH_FILES)
$(CC) $(CFLAGS) $(filter-out $(FILTER_FILES) main.c, $^) -o benches/bench
./benches/bench
clean:
rm -rf weak *.dSYM benches/bench benches/*.dSYM tests/test tests/*.dSYM
debug: $(CODE_FILES)
./genver.sh
$(CC) $(DEBUG_FLAGS) $(filter-out $(FILTER_FILES), $^) -o weak
# Typically, we don't want to run long-running tests. Default to QUICK_TEST.
test: $(TEST_FILES)
$(CC) $(DEBUG_FLAGS) -DQUICK_TEST $(filter-out $(FILTER_FILES) main.c, $^) -o tests/test
./tests/test
# However, if pedantry is required, we have this :-)
# Don't use debug flags here, as full tests become impractically slow.
testfull: $(TEST_FILES)
$(CC) $(CFLAGS) $(filter-out $(FILTER_FILES) main.c, $^) -o tests/test
./tests/test
trail:
# Remove trailing whitespace in all .c, .h files.
find . -name '*.h' -or -name '*.c' -or -name 'Makefile' | xargs -I _ sed -i '' 's/[ \\t]+$$//' _
.PHONY: all bench benchfull clean debug test testfull trail