xref: /btstack/test/gatt_server/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}/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	battery_service_server.c \
32	btstack_crypto.c            \
33	btstack_linked_list.c       \
34	btstack_memory.c            \
35	btstack_memory_pool.c       \
36	btstack_tlv.c               \
37	btstack_util.c              \
38	cycling_power_service_server.c \
39	cycling_speed_and_cadence_service_server.c \
40	device_information_service_server.c \
41	hci_cmd.c                   \
42	hci_dump.c                  \
43	heart_rate_service_server.c \
44	hids_device.c \
45	le_device_db_memory.c       \
46	mock.c                      \
47	mock_btstack_tlv.c          \
48	nordic_spp_service_server.c \
49	rijndael.c 					\
50	ublox_spp_service_server.c \
51
52CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
53CFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
54
55LDFLAGS += -lCppUTest -lCppUTestExt
56LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
57LDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
58
59COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) build-coverage/uECC.o
60COMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o)) build-asan/uECC.o
61
62
63all: build-coverage/gatt_server_test build-asan/gatt_server_test
64
65build-%:
66	mkdir -p $@
67
68# compile .ble description
69build-%/profile.h: profile.gatt | build-%
70	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
71
72build-coverage/%.o: %.c | build-coverage
73	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
74
75build-coverage/%.o: %.cpp | build-coverage
76	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
77
78build-asan/%.o: %.c | build-asan
79	${CC} -c $(CFLAGS_ASAN) $< -o $@
80
81build-asan/%.o: %.cpp | build-asan
82	${CXX} -c $(CFLAGS_ASAN) $< -o $@
83
84build-coverage/gatt_server_test: ${COMMON_OBJ_COVERAGE} build-coverage/profile.h build-coverage/gatt_server_test.o | build-coverage
85	${CXX} $(filter-out build-coverage/profile.h,$^) ${LDFLAGS_COVERAGE} -o $@
86
87build-asan/gatt_server_test: ${COMMON_OBJ_ASAN} build-asan/profile.h build-asan/gatt_server_test.o | build-asan
88	${CXX} $(filter-out build-asan/profile.h,$^) ${LDFLAGS_ASAN} -o $@
89
90test: all
91	build-asan/gatt_server_test
92
93coverage: all
94	rm -f build-coverage/*.gcda
95	build-coverage/gatt_server_test
96
97clean:
98	rm -rf build-coverage build-asan
99
100