18e8dfe94SMatthias Ringwald# Requirements: cpputest.github.io 2f45e14b1S[email protected] 3f45e14b1S[email protected]BTSTACK_ROOT = ../.. 4f45e14b1S[email protected] 5*1d3bd1e5SMatthias RingwaldCFLAGS = -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null -I. -Ibuild-coverage -I${BTSTACK_ROOT}/src 6f45e14b1S[email protected] 7cbe987fbSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src 83edc84c5SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble 96bdecec7SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble/gatt-service 10dd9e275cSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 11cbe987fbSMatthias Ringwald 12f45e14b1S[email protected]COMMON = \ 13a484130cSMatthias Ringwald ad_parser.c \ 147b4ad037SMatthias Ringwald ancs_client.c \ 15591423b2SMatthias Ringwald att_db.c \ 16a484130cSMatthias Ringwald att_dispatch.c \ 174fd23d47SMatthias Ringwald btstack_linked_list.c \ 18cbe987fbSMatthias Ringwald btstack_memory.c \ 19489a58deSMatthias Ringwald btstack_memory_pool.c \ 20489a58deSMatthias Ringwald btstack_util.c \ 21a484130cSMatthias Ringwald gatt_client.c \ 2256042629SMatthias Ringwald hci_cmd.c \ 23cbe987fbSMatthias Ringwald hci_dump.c \ 2457fe2af8SMatthias Ringwald le_device_db_memory.c \ 259796ebeaSMatthias Ringwald mock.c \ 267bdc6798S[email protected] 27cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 2871d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 29f45e14b1S[email protected] 30cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 31cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 32cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 333d87570fSMatthias Ringwald 34cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 35cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 36cd56fb44SMatthias Ringwald 37cd56fb44SMatthias Ringwaldall: build-coverage/gatt_client_test build-coverage/le_central build-asan/gatt_client_test build-asan/le_central 38cd56fb44SMatthias Ringwald 39cd56fb44SMatthias Ringwaldbuild-%: 40cd56fb44SMatthias Ringwald mkdir -p $@ 41f45e14b1S[email protected] 424d890b2dS[email protected]# compile .ble description 43cd56fb44SMatthias Ringwaldbuild-%/profile.h: profile.gatt | build-% 4475c13281SMatthias Ringwald python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ 454d890b2dS[email protected] 463d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 47cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 48f45e14b1S[email protected] 49*1d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 50*1d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 51*1d3bd1e5SMatthias Ringwald 52cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 53cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) $< -o $@ 543d87570fSMatthias Ringwald 55*1d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 56*1d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 57*1d3bd1e5SMatthias Ringwald 58cd56fb44SMatthias Ringwaldbuild-coverage/gatt_client_test: ${COMMON_OBJ_COVERAGE} build-coverage/profile.h build-coverage/gatt_client_test.o expected_results.h | build-coverage 59*1d3bd1e5SMatthias Ringwald ${CXX} $(filter-out build-coverage/profile.h expected_results.h,$^) ${LDFLAGS_COVERAGE} -o $@ 60cd56fb44SMatthias Ringwald 61cd56fb44SMatthias Ringwaldbuild-coverage/le_central: ${COMMON_OBJ_COVERAGE} build-coverage/le_central.o | build-coverage 62*1d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 63cd56fb44SMatthias Ringwald 64cd56fb44SMatthias Ringwaldbuild-asan/gatt_client_test: ${COMMON_OBJ_ASAN} build-asan/profile.h build-asan/gatt_client_test.o expected_results.h | build-asan 65*1d3bd1e5SMatthias Ringwald ${CXX} $(filter-out build-asan/profile.h expected_results.h,$^) ${LDFLAGS_ASAN} -o $@ 66cd56fb44SMatthias Ringwald 67cd56fb44SMatthias Ringwaldbuild-asan/le_central: ${COMMON_OBJ_ASAN} build-asan/le_central.o | build-asan 68*1d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 69ee988ca9S[email protected] 708e8dfe94SMatthias Ringwaldtest: all 71cd56fb44SMatthias Ringwald build-asan/gatt_client_test 72cd56fb44SMatthias Ringwald build-asan/le_central 733d87570fSMatthias Ringwald 743d87570fSMatthias Ringwaldcoverage: all 75cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 763d87570fSMatthias Ringwald build-coverage/gatt_client_test 773d87570fSMatthias Ringwald build-coverage/le_central 7857fe2af8SMatthias Ringwald 79f45e14b1S[email protected]clean: 80cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 81f45e14b1S[email protected] 82