-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
48 lines (34 loc) · 1.03 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
.POSIX:
# Some potential options:
# - SANITIZE=address,undefined
# - SANITIZE=memory
CC := clang
CLANG_CHECK := clang-check
CFLAGS := -std=c11 -g -pedantic-errors -fsanitize=${SANITIZE} \
-Wall -Wextra -Wconversion -Wcast-qual \
-D_XOPEN_SOURCE=700
SRCFILES != ls src/*.c
EXEFILES != echo ${SRCFILES} | sed 's/src/bin/g' | sed 's/\.c//g'
RSTFILES != echo ${SRCFILES} | sed 's/src/doc/g' | sed 's/\.c/.rst/g'
all: ${EXEFILES} docs
docs: ${RSTFILES}
${EXEFILES}:
@mkdir -p bin/
${CC} ${CFLAGS} $$(echo $@ | sed 's/bin\//src\//').c -o $@
lint: compile_commands.json
${CLANG_CHECK} -p . ${SRCFILES}
pylint:
pylint $$(find test -name '*.py')
test: all
pytest
compile_commands.json:
rm -f compile_commands.json
$(MAKE) ${EXEFILES} CC="./util/append-compile-commands.py ${CC}"
${RSTFILES}:
@mkdir -p doc/
./util/ccomex.py $$(echo $@ | sed 's/doc\//src\//' | sed 's/\.rst/\.c/') > $@
clean:
rm -rf bin/
rm -rf doc/
# compile_commands.json isn't _actually_ phony, but this ensures it's always built.
.PHONY: clean all compile_commands.json