xref: /btstack/test/hid_parser/Makefile (revision 98e87e7776ef9a7fe55135aea8cddc761fe3a7a5)
1# Requirements: cpputest.github.io
2
3BTSTACK_ROOT =  ../..
4
5# CppuTest from pkg-config
6CFLAGS  += ${shell pkg-config --cflags CppuTest}
7LDFLAGS += ${shell pkg-config --libs   CppuTest}
8
9CFLAGS += -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null
10
11CFLAGS += -I.
12CFLAGS += -I ${BTSTACK_ROOT}/src
13CFLAGS += -I ${BTSTACK_ROOT}/platform/posix
14
15VPATH += ${BTSTACK_ROOT}/src ${BTSTACK_ROOT}/platform/posix
16
17COMMON = \
18	btstack_util.c \
19	btstack_hid_parser.c \
20	hci_dump.c \
21	hci_dump_posix_fs.c \
22
23CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
24CFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
25
26LDFLAGS += -lCppUTest -lCppUTestExt
27LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
28LDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
29
30COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
31COMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o))
32
33all: build-coverage/hid_parser_test build-asan/hid_parser_test
34
35build-%:
36	mkdir -p $@
37
38build-coverage/%.o: %.c | build-coverage
39	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
40
41build-coverage/%.o: %.cpp | build-coverage
42	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
43
44build-asan/%.o: %.c | build-asan
45	${CC} -c $(CFLAGS_ASAN) $< -o $@
46
47build-asan/%.o: %.cpp | build-asan
48	${CXX} -c $(CFLAGS_ASAN) $< -o $@
49
50build-coverage/hid_parser_test: ${COMMON_OBJ_COVERAGE} build-coverage/hid_parser_test.o | build-coverage
51	${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
52
53build-asan/hid_parser_test: ${COMMON_OBJ_ASAN} build-asan/hid_parser_test.o | build-asan
54	${CXX} $^ ${LDFLAGS_ASAN} -o $@
55
56
57test: all
58	build-asan/hid_parser_test
59
60coverage: all
61	rm -f build-coverage/*.gcda
62	build-coverage/hid_parser_test
63
64clean:
65	rm -rf build-coverage build-asan
66
67