18e8dfe94SMatthias Ringwald# Requirements: cpputest.github.io 2f45e14b1S[email protected] 3f45e14b1S[email protected]BTSTACK_ROOT = ../.. 4f45e14b1S[email protected] 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 -I. -Ibuild-coverage -I${BTSTACK_ROOT}/src 10f45e14b1S[email protected] 11cbe987fbSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src 123edc84c5SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble 136bdecec7SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble/gatt-service 14dd9e275cSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 15cbe987fbSMatthias Ringwald 16f45e14b1S[email protected]COMMON = \ 17a484130cSMatthias Ringwald ad_parser.c \ 187b4ad037SMatthias Ringwald ancs_client.c \ 19591423b2SMatthias Ringwald att_db.c \ 20a484130cSMatthias Ringwald att_dispatch.c \ 214fd23d47SMatthias Ringwald btstack_linked_list.c \ 22cbe987fbSMatthias Ringwald btstack_memory.c \ 23489a58deSMatthias Ringwald btstack_memory_pool.c \ 24489a58deSMatthias Ringwald btstack_util.c \ 25a484130cSMatthias Ringwald gatt_client.c \ 2656042629SMatthias Ringwald hci_cmd.c \ 27*06816492SMatthias Ringwald hci_event_builder.c \ 28cbe987fbSMatthias Ringwald hci_dump.c \ 2957fe2af8SMatthias Ringwald le_device_db_memory.c \ 309796ebeaSMatthias Ringwald mock.c \ 317bdc6798S[email protected] 32cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 3371d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 34f45e14b1S[email protected] 35cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 36cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 37cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 383d87570fSMatthias Ringwald 39cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 40cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 41cd56fb44SMatthias Ringwald 42cd56fb44SMatthias Ringwaldall: build-coverage/gatt_client_test build-coverage/le_central build-asan/gatt_client_test build-asan/le_central 43cd56fb44SMatthias Ringwald 44cd56fb44SMatthias Ringwaldbuild-%: 45cd56fb44SMatthias Ringwald mkdir -p $@ 46f45e14b1S[email protected] 474d890b2dS[email protected]# compile .ble description 48cd56fb44SMatthias Ringwaldbuild-%/profile.h: profile.gatt | build-% 4975c13281SMatthias Ringwald python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ 504d890b2dS[email protected] 513d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 52cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 53f45e14b1S[email protected] 541d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 551d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 561d3bd1e5SMatthias Ringwald 57cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 58cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) $< -o $@ 593d87570fSMatthias Ringwald 601d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 611d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 621d3bd1e5SMatthias Ringwald 63cd56fb44SMatthias Ringwaldbuild-coverage/gatt_client_test: ${COMMON_OBJ_COVERAGE} build-coverage/profile.h build-coverage/gatt_client_test.o expected_results.h | build-coverage 641d3bd1e5SMatthias Ringwald ${CXX} $(filter-out build-coverage/profile.h expected_results.h,$^) ${LDFLAGS_COVERAGE} -o $@ 65cd56fb44SMatthias Ringwald 66cd56fb44SMatthias Ringwaldbuild-coverage/le_central: ${COMMON_OBJ_COVERAGE} build-coverage/le_central.o | build-coverage 671d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 68cd56fb44SMatthias Ringwald 69cd56fb44SMatthias Ringwaldbuild-asan/gatt_client_test: ${COMMON_OBJ_ASAN} build-asan/profile.h build-asan/gatt_client_test.o expected_results.h | build-asan 701d3bd1e5SMatthias Ringwald ${CXX} $(filter-out build-asan/profile.h expected_results.h,$^) ${LDFLAGS_ASAN} -o $@ 71cd56fb44SMatthias Ringwald 72cd56fb44SMatthias Ringwaldbuild-asan/le_central: ${COMMON_OBJ_ASAN} build-asan/le_central.o | build-asan 731d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 74ee988ca9S[email protected] 758e8dfe94SMatthias Ringwaldtest: all 76cd56fb44SMatthias Ringwald build-asan/gatt_client_test 77cd56fb44SMatthias Ringwald build-asan/le_central 783d87570fSMatthias Ringwald 793d87570fSMatthias Ringwaldcoverage: all 80cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 813d87570fSMatthias Ringwald build-coverage/gatt_client_test 823d87570fSMatthias Ringwald build-coverage/le_central 8357fe2af8SMatthias Ringwald 84f45e14b1S[email protected]clean: 85cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 86f45e14b1S[email protected] 87