xref: /btstack/test/gatt_server/Makefile (revision 4a9eead824c50b40e12b6f72611a74a3f57a47f6)
1# Requirements: cpputest.github.io
2
3BTSTACK_ROOT =  ../..
4
5CFLAGS  = -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null
6CFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
7CFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
8CFLAGS += -I${BTSTACK_ROOT}/platform/embedded
9CFLAGS += -I${BTSTACK_ROOT}/platform/posix
10CFLAGS += -I${BTSTACK_ROOT}/src
11CFLAGS += -I${BTSTACK_ROOT}/test/mock
12CFLAGS += -I.
13
14VPATH += ${BTSTACK_ROOT}/src
15VPATH += ${BTSTACK_ROOT}/src/ble
16VPATH += ${BTSTACK_ROOT}/src/ble/gatt-service
17VPATH += ${BTSTACK_ROOT}/platform/posix
18VPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
19VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
20VPATH += ${BTSTACK_ROOT}/test/mock
21
22COMMON = \
23	ad_parser.c                 \
24	att_db.c                    \
25	att_db_util.c 				\
26	att_server.c                \
27	battery_service_server.c \
28	btstack_crypto.c            \
29	btstack_linked_list.c       \
30	btstack_memory.c            \
31	btstack_memory_pool.c       \
32	btstack_tlv.c               \
33	btstack_util.c              \
34	cycling_power_service_server.c \
35	cycling_speed_and_cadence_service_server.c \
36	device_information_service_server.c \
37	hci_cmd.c                   \
38	hci_dump.c                  \
39	heart_rate_service_server.c \
40	hids_device.c \
41	le_device_db_memory.c       \
42	mock.c                      \
43	mock_btstack_tlv.c          \
44	nordic_spp_service_server.c \
45	rijndael.c 					\
46	ublox_spp_service_server.c \
47
48CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
49CFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
50
51LDFLAGS += -lCppUTest -lCppUTestExt
52LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
53LDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
54
55COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) build-coverage/uECC.o
56COMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o)) build-asan/uECC.o
57
58
59all: build-coverage/gatt_server_test build-asan/gatt_server_test
60
61build-%:
62	mkdir -p $@
63
64# compile .ble description
65build-%/profile.h: profile.gatt | build-%
66	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
67
68build-coverage/%.o: %.c | build-coverage
69	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
70
71build-coverage/%.o: %.cpp | build-coverage
72	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
73
74build-asan/%.o: %.c | build-asan
75	${CC} -c $(CFLAGS_ASAN) $< -o $@
76
77build-asan/%.o: %.cpp | build-asan
78	${CXX} -c $(CFLAGS_ASAN) $< -o $@
79
80build-coverage/gatt_server_test: ${COMMON_OBJ_COVERAGE} build-coverage/profile.h build-coverage/gatt_server_test.o | build-coverage
81	${CXX} $(filter-out build-coverage/profile.h,$^) ${LDFLAGS_COVERAGE} -o $@
82
83build-asan/gatt_server_test: ${COMMON_OBJ_ASAN} build-asan/profile.h build-asan/gatt_server_test.o | build-asan
84	${CXX} $(filter-out build-asan/profile.h,$^) ${LDFLAGS_ASAN} -o $@
85
86test: all
87	build-asan/gatt_server_test
88
89coverage: all
90	rm -f build-coverage/*.gcda
91	build-coverage/gatt_server_test
92
93clean:
94	rm -rf build-coverage build-asan
95
96