forked from dhess/c-ringbuf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
51 lines (37 loc) · 1.13 KB
/
GNUmakefile
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
CC=clang
CFLAGS=-O0 -g -Wall -Wpointer-arith -ftrapv -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error
# or, for gcc...
#CC=gcc
#CFLAGS=-O0 -g -Wall
LD=$(CC)
LDFLAGS=-g
test: ringbuf-test
./ringbuf-test
coverage: ringbuf-test-gcov
./ringbuf-test-gcov
gcov -o ringbuf-gcov.o ringbuf.c
valgrind: ringbuf-test
valgrind ./ringbuf-test
help:
@echo "Targets:"
@echo
@echo "test - build and run ringbuf unit tests."
@echo "coverage - use gcov to check test coverage of ringbuf.c."
@echo "valgrind - use valgrind to check for memory leaks."
@echo "clean - remove all targets."
@echo "help - this message."
ringbuf-test-gcov: ringbuf-test-gcov.o ringbuf-gcov.o
gcc -o ringbuf-test-gcov --coverage $^
ringbuf-test-gcov.o: ringbuf-test.c ringbuf.h
gcc -c $< -o $@
ringbuf-gcov.o: ringbuf.c ringbuf.h
gcc --coverage -c $< -o $@
ringbuf-test: ringbuf-test.o ringbuf.o
$(LD) -o ringbuf-test $(LDFLAGS) $^
ringbuf-test.o: ringbuf-test.c ringbuf.h
$(CC) $(CFLAGS) -c $< -o $@
ringbuf.o: ringbuf.c ringbuf.h
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -f ringbuf-test ringbuf-test-gcov *.o *.gcov *.gcda *.gcno
.PHONY: clean