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