File: Makefile

package info (click to toggle)
libtoxcore 0.2.20-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,124 kB
  • sloc: ansic: 75,034; cpp: 4,933; sh: 1,115; python: 651; makefile: 329; perl: 39
file content (123 lines) | stat: -rw-r--r-- 3,567 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
CC ?= gcc
CLANG ?= clang

EXTRA_CFLAGS ?= -Werror -Wall -Wextra -funsigned-char -fwrapv -Wconversion \
				-Wno-sign-conversion -Wmissing-format-attribute \
				-Wpointer-arith -Wformat-nonliteral -Winit-self \
				-Wwrite-strings -Wshadow -Wenum-compare -Wempty-body \
				-Wparentheses -Wcast-align -Wstrict-aliasing --pedantic-errors
CMPCFLAGS ?= -std=c89 -Wno-c99-extensions
TESTCFLAGS ?= -std=c99 -Wno-error=deprecated-declarations \
			  -Wno-deprecated-declarations -O0
NOFPUTESTCFLAGS ?= $(TESTCFLAGS) -DCMP_NO_FLOAT

ADDRCFLAGS ?= -fsanitize=address
MEMCFLAGS ?= -fsanitize=memory -fno-omit-frame-pointer \
			 -fno-optimize-sibling-calls
UBCFLAGS ?= -fsanitize=undefined,nullability,local-bounds,float-divide-by-zero,integer

.PHONY: all clean test coverage

all: cmpunittest example1 example2

profile: cmpprof
	@env LD_PRELOAD=/usr/lib/libprofiler.so CPUPROFILE=cmp.prof \
		CPUPROFILE_FREQUENCY=1000 ./cmpprof
	@pprof --web ./cmpprof cmp.prof

test: addrtest memtest nofloattest ubtest unittest

testprogs: cmpaddrtest cmpmemtest cmpnofloattest cmpubtest cmpunittest

addrtest: cmpaddrtest
	@./cmpaddrtest

memtest: cmpmemtest
	@./cmpmemtest

nofloattest: cmpnofloattest
	@./cmpnofloattest
	@rm -f *.gcno *.gcda *.info

ubtest: cmpubtest
	@./cmpubtest

unittest: cmpunittest
	@./cmpunittest

cmp.o: cmp.c
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CMPCFLAGS) \
		-fprofile-arcs -ftest-coverage -g -I. -c cmp.c

cmpprof: cmp.o
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(TESTCFLAGS) $(LDFLAGS) \
		-fprofile-arcs -I. \
		-o cmpprof cmp.o test/profile.c test/tests.c test/buf.c test/utils.c \
		-lcmocka -lprofiler

cmpunittest: cmp.o
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(TESTCFLAGS) $(LDFLAGS) \
		-fprofile-arcs -ftest-coverage -g -I. \
		-o cmpunittest cmp.o test/test.c test/tests.c test/buf.c test/utils.c \
		-lcmocka

cmpnofloattest: cmp.o
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(NOFPUTESTCFLAGS) $(LDFLAGS) \
		-fprofile-arcs -ftest-coverage -g -I. \
		-o cmpnofloattest cmp.o test/test.c test/tests.c test/buf.c \
		test/utils.c \
		-lcmocka

clangcmp.o: cmp.c
	$(CLANG) $(CFLAGS) $(EXTRA_CFLAGS) $(CMPCFLAGS) \
		-fprofile-arcs -ftest-coverage -g -I. -c cmp.c -o clangcmp.o

cmpaddrtest: clangcmp.o clean
	$(CLANG) $(CFLAGS) $(EXTRA_CFLAGS) $(TESTCFLAGS) $(ADDRCFLAGS) $(LDFLAGS) \
		-I. -o cmpaddrtest \
		cmp.c test/test.c test/tests.c test/buf.c test/utils.c \
		-lcmocka

cmpmemtest: clangcmp.o clean
	$(CLANG) $(CFLAGS) $(EXTRA_CFLAGS) $(TESTCFLAGS) $(MEMCFLAGS) $(LDFLAGS) \
		-I. -o cmpmemtest \
		cmp.c test/test.c test/tests.c test/buf.c test/utils.c \
		-lcmocka

cmpubtest: clangcmp.o clean
	$(CLANG) $(CFLAGS) $(EXTRA_CFLAGS) $(TESTCFLAGS) $(UBCFLAGS) $(LDFLAGS) \
		-I. -o cmpubtest \
		cmp.c test/test.c test/tests.c test/buf.c test/utils.c \
		-lcmocka

example1:
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) --std=c89 -O3 -I. -o example1 \
		cmp.c examples/example1.c

example2:
	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) --std=c89 -O3 -I. -o example2 \
		cmp.c examples/example2.c

coverage:
	@rm -f base_coverage.info test_coverage.info total_coverage.info
	@rm -rf coverage
	@lcov -q -c -i -d . -o base_coverage.info
	@lcov -q -c -d . -o test_coverage.info
	@lcov -q -a base_coverage.info -a test_coverage.info -o total_coverage.info
	@lcov -q --summary total_coverage.info
	@mkdir coverage
	@genhtml -q -o coverage total_coverage.info

clean:
	@rm -f cmp.prof
	@rm -f cmpunittest
	@rm -f cmpaddrtest
	@rm -f cmpmemtest
	@rm -f cmpubtest
	@rm -f cmpnofloattest
	@rm -f cmpprof
	@rm -f example1
	@rm -f example2
	@rm -f *.o
	@rm -f *.gcno *.gcda *.info
	@rm -f cmp_data.dat