-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (49 loc) · 1.64 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
68
69
CC = cc
CFLAGS = -g -std=gnu17 -fPIC -Wall -Wextra
LDFLAGS = -lm
OUTPUT_OPTION = -MMD -MP -o $@
SHARED_LIBRARY_EXTENSION = dylib
SHARED_LIBRARY_FLAG = -dynamiclib
BUILD_DIR := ./build
SRC_DIRS := ./src
TEST_DIRS := ./test
SRCS := $(shell find $(SRC_DIRS) -name *.c)
OBJS := $(SRCS:.c=.o)
default: help
all: check lib test
lib: $(BUILD_DIR)/libpony.${SHARED_LIBRARY_EXTENSION}(${OBJS})
$(BUILD_DIR)/libpony.${SHARED_LIBRARY_EXTENSION}: ${OBJS}
${CC} ${SHARED_LIBRARY_FLAG} -o $@ $^
check:
cppcheck --suppress='*:include/*' --force ${SRCS} ${TEST_SRCS}
TEST_SRCS := $(shell find $(TEST_DIRS) -name *.c)
TEST_OBJS := $(TEST_SRCS:.c=.o)
$(BUILD_DIR)/test: ${TEST_OBJS}
${CC} -Lbuild -lpony -o $@ $^
build_test: lib $(BUILD_DIR)/test
pre_test: build_test
rm -rf tmp/*
test: pre_test
./build/test
format:
clang-format -i src/*.{h,c}
BENCH_SRCS := $(shell find ./bench -name *.c)
BENCH_OBJS := $(BENCH_SRCS:.c=.o)
build_bench: lib $(BUILD_DIR)/bench
bench: build_bench
mkdir -p tmp/bench
rm -rf tmp/bench/*
./build/bench -c 8192 > tmp/bench/timings.tsv
./bench/plot.sh
$(BUILD_DIR)/bench: ${BENCH_OBJS}
${CC} -Lbuild -lpony -o $@ $^
clean:
-rm -rf $(BUILD_DIR)/* $(SRC_DIRS)/*.o $(SRC_DIRS)/*.d $(TEST_DIRS)/*.o $(TEST_DIRS)/*.d $(TEST_DIRS)/*.o bench/*.o bench/*.d
help:
-@echo "make lib: build libpony.${SHARED_LIBRARY_EXTENSION}"
-@echo "make test: run unit tests"
-@echo "make check: run cppcheck"
-@echo "make bench: run benchmarks"
-@echo "make format: run clang-format -i"
-@echo "make clean: remove all build files"
.PHONY: help test clean all bench format