xref: /btstack/test/gatt_server/Makefile (revision ec4690afd10fec8b375d4122b81902e9c9a379a0)
1f9739491SMatthias Ringwald# Requirements: cpputest.github.io
2f9739491SMatthias Ringwald
3f9739491SMatthias RingwaldBTSTACK_ROOT =  ../..
4f9739491SMatthias Ringwald
598e87e77SMatthias Ringwald# CppuTest from pkg-config
698e87e77SMatthias RingwaldCFLAGS  += ${shell pkg-config --cflags CppuTest}
798e87e77SMatthias RingwaldLDFLAGS += ${shell pkg-config --libs   CppuTest}
898e87e77SMatthias Ringwald
998e87e77SMatthias RingwaldCFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null
10ae970bb9SMilanka RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
11e2c00bfeSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
12e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/embedded
13e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/posix
14e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src
1525336c94SMilanka RingwaldCFLAGS += -I${BTSTACK_ROOT}/test/mock
16e0ff5d41SMatthias RingwaldCFLAGS += -I.
17f9739491SMatthias Ringwald
18f9739491SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src
19f9739491SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble
201a449638SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble/gatt-service
21f9739491SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix
22e2c00bfeSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
23ae970bb9SMilanka RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
2425336c94SMilanka RingwaldVPATH += ${BTSTACK_ROOT}/test/mock
25f9739491SMatthias Ringwald
26f9739491SMatthias RingwaldCOMMON = \
27f9739491SMatthias Ringwald	ad_parser.c                 \
28f9739491SMatthias Ringwald	att_db.c                    \
29ae970bb9SMilanka Ringwald	att_db_util.c 				\
30ae970bb9SMilanka Ringwald	att_server.c                \
31*ec4690afSMatthias Ringwald	btstack_hid_parser.c        \
32ae970bb9SMilanka Ringwald	battery_service_server.c    \
33ae970bb9SMilanka Ringwald	btstack_crypto.c            \
34f9739491SMatthias Ringwald	btstack_linked_list.c       \
35f9739491SMatthias Ringwald	btstack_memory.c            \
36f9739491SMatthias Ringwald	btstack_memory_pool.c       \
37f9739491SMatthias Ringwald	btstack_tlv.c               \
38ae970bb9SMilanka Ringwald	btstack_util.c              \
391a449638SMatthias Ringwald	cycling_power_service_server.c \
401a449638SMatthias Ringwald	cycling_speed_and_cadence_service_server.c \
411a449638SMatthias Ringwald	device_information_service_server.c \
42ae970bb9SMilanka Ringwald	hci_cmd.c                   \
43ae970bb9SMilanka Ringwald	hci_dump.c                  \
441a449638SMatthias Ringwald	heart_rate_service_server.c \
451a449638SMatthias Ringwald	hids_device.c \
46ae970bb9SMilanka Ringwald	le_device_db_memory.c       \
47ae970bb9SMilanka Ringwald	mock.c                      \
4825336c94SMilanka Ringwald	mock_btstack_tlv.c          \
491a449638SMatthias Ringwald	nordic_spp_service_server.c \
50ae970bb9SMilanka Ringwald	rijndael.c 					\
511a449638SMatthias Ringwald	ublox_spp_service_server.c \
52f9739491SMatthias Ringwald
53cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
5471d52576SMatthias RingwaldCFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
55f9739491SMatthias Ringwald
56cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
57cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
58cd56fb44SMatthias RingwaldLDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
593d87570fSMatthias Ringwald
60e0ff5d41SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) build-coverage/uECC.o
61e0ff5d41SMatthias RingwaldCOMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o)) build-asan/uECC.o
62cd56fb44SMatthias Ringwald
63cd56fb44SMatthias Ringwald
64cd56fb44SMatthias Ringwaldall: build-coverage/gatt_server_test build-asan/gatt_server_test
65cd56fb44SMatthias Ringwald
66cd56fb44SMatthias Ringwaldbuild-%:
67cd56fb44SMatthias Ringwald	mkdir -p $@
68f9739491SMatthias Ringwald
69f9739491SMatthias Ringwald# compile .ble description
70cd56fb44SMatthias Ringwaldbuild-%/profile.h: profile.gatt | build-%
7175c13281SMatthias Ringwald	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
72f9739491SMatthias Ringwald
733d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage
741d3bd1e5SMatthias Ringwald	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
75e2c00bfeSMatthias Ringwald
76e0ff5d41SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage
771d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
78cd56fb44SMatthias Ringwald
79e0ff5d41SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan
801d3bd1e5SMatthias Ringwald	${CC} -c $(CFLAGS_ASAN) $< -o $@
81e2c00bfeSMatthias Ringwald
82e0ff5d41SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan
831d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_ASAN) $< -o $@
84e2c00bfeSMatthias Ringwald
85cd56fb44SMatthias Ringwaldbuild-coverage/gatt_server_test: ${COMMON_OBJ_COVERAGE} build-coverage/profile.h build-coverage/gatt_server_test.o | build-coverage
861d3bd1e5SMatthias Ringwald	${CXX} $(filter-out build-coverage/profile.h,$^) ${LDFLAGS_COVERAGE} -o $@
87cd56fb44SMatthias Ringwald
88cd56fb44SMatthias Ringwaldbuild-asan/gatt_server_test: ${COMMON_OBJ_ASAN} build-asan/profile.h build-asan/gatt_server_test.o | build-asan
891d3bd1e5SMatthias Ringwald	${CXX} $(filter-out build-asan/profile.h,$^) ${LDFLAGS_ASAN} -o $@
90f9739491SMatthias Ringwald
91f9739491SMatthias Ringwaldtest: all
92cd56fb44SMatthias Ringwald	build-asan/gatt_server_test
933d87570fSMatthias Ringwald
943d87570fSMatthias Ringwaldcoverage: all
95cd56fb44SMatthias Ringwald	rm -f build-coverage/*.gcda
963d87570fSMatthias Ringwald	build-coverage/gatt_server_test
97f9739491SMatthias Ringwald
98f9739491SMatthias Ringwaldclean:
99cd56fb44SMatthias Ringwald	rm -rf build-coverage build-asan
100f9739491SMatthias Ringwald
101