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