xref: /btstack/test/ble_client/Makefile (revision 08a78038ba366a6a2a2df8fea05d5123880fdff2)
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 -g -Wall -Wnarrowing -Wconversion-null
10CFLAGS += -I${BTSTACK_ROOT}/src
11CFLAGS += -I.
12
13CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
14CFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
15
16LDFLAGS += -lCppUTest -lCppUTestExt
17LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
18LDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
19
20VPATH += ${BTSTACK_ROOT}/src/ble
21VPATH += ${BTSTACK_ROOT}/src
22VPATH += ${BTSTACK_ROOT}/platform/posix
23
24COMMON = \
25	btstack_linked_list.c	    \
26	btstack_memory.c			\
27	btstack_memory_pool.c		\
28	btstack_run_loop.c			\
29	btstack_run_loop_posix.c 	\
30	btstack_util.c			    \
31	hci.c                       \
32	hci_cmd.c					\
33	hci_dump.c					\
34
35COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
36COMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o))
37
38all: build-coverage/ad_parser_test build-asan/ad_parser_test
39
40build-%:
41	mkdir -p $@
42
43build-coverage/%.o: %.c | build-coverage
44	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
45
46build-coverage/%.o: %.cpp | build-coverage
47	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
48
49build-asan/%.o: %.c | build-asan
50	${CC} -c $(CFLAGS_ASAN) $< -o $@
51
52build-asan/%.o: %.cpp | build-asan
53	${CXX} -c $(CFLAGS_ASAN) $< -o $@
54
55build-coverage/ad_parser_test: ${COMMON_OBJ_COVERAGE} build-coverage/ad_parser_test.o | build-coverage
56	${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
57
58build-asan/ad_parser_test: ${COMMON_OBJ_ASAN} build-asan/ad_parser_test.o | build-asan
59	${CXX} $^ ${LDFLAGS_ASAN} -o $@
60
61test: all
62	build-asan/ad_parser_test
63
64coverage: all
65	rm -f build-coverage/*.gcda
66	build-coverage/ad_parser_test
67
68clean:
69	rm -rf build-coverage build-asan
70