19a1fae91SMatthias RingwaldBTSTACK_ROOT = ../.. 298e87e77SMatthias Ringwald 398e87e77SMatthias Ringwald# CppuTest from pkg-config 498e87e77SMatthias RingwaldCFLAGS += ${shell pkg-config --cflags CppuTest} 598e87e77SMatthias RingwaldLDFLAGS += ${shell pkg-config --libs CppuTest} 69a1fae91SMatthias Ringwald 7cd56fb44SMatthias RingwaldCOMMON = \ 8*2b49e57bSMatthias Ringwald btstack_link_key_db_tlv.c \ 9cd56fb44SMatthias Ringwald btstack_util.c \ 10cd56fb44SMatthias Ringwald hci_dump.c \ 1131437b52SMatthias Ringwald hci_dump_posix_fs.c \ 12*2b49e57bSMatthias Ringwald hal_flash_bank_memory.c \ 139a1fae91SMatthias Ringwald 149a1fae91SMatthias RingwaldVPATH = \ 15d9f53676SMatthias Ringwald ${BTSTACK_ROOT}/src \ 161f5ff433SMatthias Ringwald ${BTSTACK_ROOT}/src/ble \ 17*2b49e57bSMatthias Ringwald ${BTSTACK_ROOT}/src/classic \ 18d9f53676SMatthias Ringwald ${BTSTACK_ROOT}/platform/embedded \ 1931437b52SMatthias Ringwald ${BTSTACK_ROOT}/platform/posix \ 209a1fae91SMatthias Ringwald 2198e87e77SMatthias RingwaldCFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null 22e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src 23e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/embedded 24e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/posix 25e0ff5d41SMatthias RingwaldCFLAGS += -I.. 269a1fae91SMatthias Ringwald 27cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 2871d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 29cd56fb44SMatthias Ringwald 309a1fae91SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 31cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 32cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 339a1fae91SMatthias Ringwald 34cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 35cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 369a1fae91SMatthias Ringwald 37*2b49e57bSMatthias Ringwaldall: build-coverage/tlv_test build-asan/tlv_test build-asan/tlv_test_write_once build-asan/tlv_test_delete_field 389a1fae91SMatthias Ringwald 39cd56fb44SMatthias Ringwaldbuild-%: 40cd56fb44SMatthias Ringwald mkdir -p $@ 419a1fae91SMatthias Ringwald 42cd56fb44SMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 43cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 44cd56fb44SMatthias Ringwald 451d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 461d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 471d3bd1e5SMatthias Ringwald 485bc527feSMatthias Ringwald 49cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 50cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) $< -o $@ 51cd56fb44SMatthias Ringwald 521d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 531d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 541d3bd1e5SMatthias Ringwald 55*2b49e57bSMatthias Ringwald 565bc527feSMatthias Ringwald# write once sets ENABLE_TLV_FLASH_WRITE_ONCE 575bc527feSMatthias Ringwaldbuild-asan/%_write_once.o: %.c | build-asan 585bc527feSMatthias Ringwald ${CC} -DENABLE_TLV_FLASH_WRITE_ONCE -c $(CFLAGS_ASAN) $< -o $@ 595bc527feSMatthias Ringwald 605bc527feSMatthias Ringwaldbuild-asan/%_write_once.o: %.cpp | build-asan 615bc527feSMatthias Ringwald ${CXX} -DENABLE_TLV_FLASH_WRITE_ONCE -c $(CFLAGS_ASAN) $< -o $@ 625bc527feSMatthias Ringwald 63*2b49e57bSMatthias Ringwald# delete field sets ENABLE_TLV_FLASH_DELETE_FIELD 64*2b49e57bSMatthias Ringwaldbuild-asan/%_delete_field.o: %.c | build-asan 65*2b49e57bSMatthias Ringwald ${CC} -DENABLE_TLV_FLASH_EXPLICIT_DELETE_FIELD -c $(CFLAGS_ASAN) $< -o $@ 665bc527feSMatthias Ringwald 67*2b49e57bSMatthias Ringwaldbuild-asan/%_delete_field.o: %.cpp | build-asan 68*2b49e57bSMatthias Ringwald ${CXX} -DENABLE_TLV_FLASH_EXPLICIT_DELETE_FIELD -c $(CFLAGS_ASAN) $< -o $@ 69*2b49e57bSMatthias Ringwald 70*2b49e57bSMatthias Ringwald 71*2b49e57bSMatthias Ringwald# targets 72*2b49e57bSMatthias Ringwaldbuild-coverage/tlv_test: ${COMMON_OBJ_COVERAGE} build-coverage/btstack_tlv_flash_bank.o build-coverage/tlv_test.o | build-coverage 731d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 74cd56fb44SMatthias Ringwald 75*2b49e57bSMatthias Ringwaldbuild-asan/tlv_test: ${COMMON_OBJ_ASAN} build-asan/btstack_tlv_flash_bank.o build-asan/tlv_test.o | build-asan 761d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 771f5ff433SMatthias Ringwald 78*2b49e57bSMatthias Ringwaldbuild-asan/tlv_test_write_once: ${COMMON_OBJ_ASAN} build-asan/btstack_tlv_flash_bank_write_once.o build-asan/tlv_test_write_once.o | build-asan 795bc527feSMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 805bc527feSMatthias Ringwald 81*2b49e57bSMatthias Ringwaldbuild-asan/tlv_test_delete_field: ${COMMON_OBJ_ASAN} build-asan/btstack_tlv_flash_bank_delete_field.o build-asan/tlv_test_delete_field.o | build-asan 82*2b49e57bSMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 83*2b49e57bSMatthias Ringwald 84*2b49e57bSMatthias Ringwald 859a1fae91SMatthias Ringwaldtest: all 86cd56fb44SMatthias Ringwald build-asan/tlv_test 875bc527feSMatthias Ringwald build-asan/tlv_test_write_once 88*2b49e57bSMatthias Ringwald build-asan/tlv_test_delete_field 899a1fae91SMatthias Ringwald 903d87570fSMatthias Ringwaldcoverage: all 91cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 923d87570fSMatthias Ringwald build-coverage/tlv_test 93cd56fb44SMatthias Ringwald 94cd56fb44SMatthias Ringwaldclean: 95cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 96