xref: /btstack/test/gatt_server/Makefile (revision 25336c9461bddbd32b7f862a6f161b0d8575868f)
1f9739491SMatthias Ringwald# Requirements: cpputest.github.io
2f9739491SMatthias Ringwald
3f9739491SMatthias RingwaldBTSTACK_ROOT =  ../..
4f9739491SMatthias Ringwald
5e0ff5d41SMatthias RingwaldCFLAGS  = -DUNIT_TEST  -g -Wall -Wnarrowing -Wconversion-null
6ae970bb9SMilanka RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael
7e2c00bfeSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
8e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/embedded
9e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/posix
10e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src
11*25336c94SMilanka RingwaldCFLAGS += -I${BTSTACK_ROOT}/test/mock
12e0ff5d41SMatthias RingwaldCFLAGS += -I.
13f9739491SMatthias Ringwald
14f9739491SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src
15f9739491SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble
161a449638SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble/gatt-service
17f9739491SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix
18e2c00bfeSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc
19ae970bb9SMilanka RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
20*25336c94SMilanka RingwaldVPATH += ${BTSTACK_ROOT}/test/mock
21f9739491SMatthias Ringwald
22f9739491SMatthias RingwaldCOMMON = \
23f9739491SMatthias Ringwald	ad_parser.c                 \
24f9739491SMatthias Ringwald	att_db.c                    \
25ae970bb9SMilanka Ringwald	att_db_util.c 				\
26ae970bb9SMilanka Ringwald	att_server.c                \
27ae970bb9SMilanka Ringwald	battery_service_server.c \
28ae970bb9SMilanka Ringwald	btstack_crypto.c            \
29f9739491SMatthias Ringwald	btstack_linked_list.c       \
30f9739491SMatthias Ringwald	btstack_memory.c            \
31f9739491SMatthias Ringwald	btstack_memory_pool.c       \
32f9739491SMatthias Ringwald	btstack_tlv.c               \
33ae970bb9SMilanka Ringwald	btstack_util.c              \
341a449638SMatthias Ringwald	cycling_power_service_server.c \
351a449638SMatthias Ringwald	cycling_speed_and_cadence_service_server.c \
361a449638SMatthias Ringwald	device_information_service_server.c \
37ae970bb9SMilanka Ringwald	hci_cmd.c                   \
38ae970bb9SMilanka Ringwald	hci_dump.c                  \
391a449638SMatthias Ringwald	heart_rate_service_server.c \
401a449638SMatthias Ringwald	hids_device.c \
41ae970bb9SMilanka Ringwald	le_device_db_memory.c       \
42ae970bb9SMilanka Ringwald	mock.c                      \
43*25336c94SMilanka Ringwald	mock_btstack_tlv.c          \
441a449638SMatthias Ringwald	nordic_spp_service_server.c \
45ae970bb9SMilanka Ringwald	rijndael.c 					\
461a449638SMatthias Ringwald	ublox_spp_service_server.c \
47f9739491SMatthias Ringwald
48cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
4971d52576SMatthias RingwaldCFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
50f9739491SMatthias Ringwald
51cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
52cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
53cd56fb44SMatthias RingwaldLDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
543d87570fSMatthias Ringwald
55e0ff5d41SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) build-coverage/uECC.o
56e0ff5d41SMatthias RingwaldCOMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o)) build-asan/uECC.o
57cd56fb44SMatthias Ringwald
58cd56fb44SMatthias Ringwald
59cd56fb44SMatthias Ringwaldall: build-coverage/gatt_server_test build-asan/gatt_server_test
60cd56fb44SMatthias Ringwald
61cd56fb44SMatthias Ringwaldbuild-%:
62cd56fb44SMatthias Ringwald	mkdir -p $@
63f9739491SMatthias Ringwald
64f9739491SMatthias Ringwald# compile .ble description
65cd56fb44SMatthias Ringwaldbuild-%/profile.h: profile.gatt | build-%
6675c13281SMatthias Ringwald	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
67f9739491SMatthias Ringwald
683d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage
69e2c00bfeSMatthias Ringwald	gcc -c $(CFLAGS_COVERAGE) $< -o $@
70e2c00bfeSMatthias Ringwald
71e0ff5d41SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage
72e0ff5d41SMatthias Ringwald	g++ -c $(CFLAGS_COVERAGE) $< -o $@
73cd56fb44SMatthias Ringwald
74e0ff5d41SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan
75e2c00bfeSMatthias Ringwald	gcc -c $(CFLAGS_ASAN) $< -o $@
76e2c00bfeSMatthias Ringwald
77e0ff5d41SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan
78e0ff5d41SMatthias Ringwald	g++ -c $(CFLAGS_ASAN) $< -o $@
79e2c00bfeSMatthias Ringwald
80cd56fb44SMatthias Ringwaldbuild-coverage/gatt_server_test: ${COMMON_OBJ_COVERAGE} build-coverage/profile.h build-coverage/gatt_server_test.o | build-coverage
81e0ff5d41SMatthias Ringwald	g++ $(filter-out build-coverage/profile.h,$^) ${LDFLAGS_COVERAGE} -o $@
82cd56fb44SMatthias Ringwald
83cd56fb44SMatthias Ringwaldbuild-asan/gatt_server_test: ${COMMON_OBJ_ASAN} build-asan/profile.h build-asan/gatt_server_test.o | build-asan
84e0ff5d41SMatthias Ringwald	g++ $(filter-out build-asan/profile.h,$^) ${LDFLAGS_ASAN} -o $@
85f9739491SMatthias Ringwald
86f9739491SMatthias Ringwaldtest: all
87cd56fb44SMatthias Ringwald	build-asan/gatt_server_test
883d87570fSMatthias Ringwald
893d87570fSMatthias Ringwaldcoverage: all
90cd56fb44SMatthias Ringwald	rm -f build-coverage/*.gcda
913d87570fSMatthias Ringwald	build-coverage/gatt_server_test
92f9739491SMatthias Ringwald
93f9739491SMatthias Ringwaldclean:
94cd56fb44SMatthias Ringwald	rm -rf build-coverage build-asan
95f9739491SMatthias Ringwald
96