forked from spaskalev/buddy_alloc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (43 loc) · 1.66 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
#
# Copyright 2021 Stanislav Paskalev <spaskalev@protonmail.com>
#
# Disable default implicit rules
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:
LLVM_VERSION?=11
CC=clang-$(LLVM_VERSION)
CFLAGS=-std=c99 -pg -no-pie -fno-builtin -g -O0 -Og -fstrict-aliasing -fstack-protector-all -fsanitize=undefined -pedantic -Wall -Wextra -Werror -Wfatal-errors -Wformat --coverage
LLVM_COV=llvm-cov-$(LLVM_VERSION)
CTIDY=clang-tidy-$(LLVM_VERSION)
CTIDY_CHECKS='bugprone-*,performance-*,readability-*,-readability-magic-numbers,-clang-analyzer-security.*'
CTIDY_EXTRA='-std=c99'
TESTS_SRC=tests.c
LIB_SRC=buddy_alloc.h
test: tests.out spell
rm -f *.gcda
./tests.out
$(LLVM_COV) gcov -b $(TESTS_SRC) | paste -s -d ',' | sed -e 's/,,/,\n/' | cut -d ',' -f 1,2,3
! grep '#####:' *.gcov
! grep -E '^branch\s*[0-9]? never executed$$' *.gcov
tests.out: $(TESTS_SRC) $(LIB_SRC) test-clang-tidy test-cppcheck check-recursion
$(CC) $(CFLAGS) $(TESTS_SRC) -o $@
test-clang-tidy: $(TESTS_SRC)
$(CTIDY) -checks=$(CTIDY_CHECKS) -warnings-as-errors='*' --extra-arg=$(CTIDY_EXTRA) $^ --
test-cppcheck: $(TESTS_SRC)
cppcheck --error-exitcode=1 --quiet $^
test-multiplatform: $(TESTS_SRC)
# 64-bit
powerpc64-linux-gnu-gcc -static $(TESTS_SRC) && ./a.out
aarch64-linux-gnu-gcc -static $(TESTS_SRC) && ./a.out
# 32-bit
i686-linux-gnu-gcc -static -g tests.c && ./a.out
powerpc-linux-gnu-gcc -static $(TESTS_SRC) && ./a.out
check-recursion: $(LIB_SRC)
[ $$( cflow --no-main $(LIB_SRC) | grep -c 'recursive:' ) -eq "0" ]
clean:
rm -f a.out *.gcda *.gcno *.gcov tests.out
spell:
spell -d .dict *.md
[ -z "$$(spell -d .dict *.md)" ]
.PHONY: test clean test-clang-tidy test-cppcheck spell
.PRECIOUS: tests.out