18e8dfe94SMatthias Ringwald# Requirements: cpputest.github.io 22412778bSmatthias.ringwald 32412778bSmatthias.ringwaldBTSTACK_ROOT = ../.. 4*98e87e77SMatthias Ringwald# CppuTest from pkg-config 5*98e87e77SMatthias RingwaldCFLAGS += ${shell pkg-config --cflags CppuTest} 6*98e87e77SMatthias RingwaldLDFLAGS += ${shell pkg-config --libs CppuTest} 72412778bSmatthias.ringwald 8*98e87e77SMatthias RingwaldCFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null -Ibuild-coverage -I./ 9e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src 10e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/include 11e0ff5d41SMatthias RingwaldCFLAGS += -I.. 1257fe2af8SMatthias Ringwald 133edc84c5SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble 1457fe2af8SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src 15dd9e275cSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 162412778bSmatthias.ringwald 172412778bSmatthias.ringwaldCOMMON = \ 184fd23d47SMatthias Ringwald btstack_linked_list.c \ 1969cb6dafSMatthias Ringwald hci_dump.c \ 2069cb6dafSMatthias Ringwald btstack_util.c \ 212412778bSmatthias.ringwald 22cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 2371d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 242412778bSmatthias.ringwald 25cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 26cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 27cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 282412778bSmatthias.ringwald 29cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 30cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 31cd56fb44SMatthias Ringwald 32cd56fb44SMatthias Ringwaldall: build-coverage/btstack_linked_list_test build-asan/btstack_linked_list_test 33cd56fb44SMatthias Ringwald 34cd56fb44SMatthias Ringwaldbuild-%: 35cd56fb44SMatthias Ringwald mkdir -p $@ 363d87570fSMatthias Ringwald 373d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 38cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 393d87570fSMatthias Ringwald 401d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 411d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 421d3bd1e5SMatthias Ringwald 43cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 44cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) $< -o $@ 45cd56fb44SMatthias Ringwald 461d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 471d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 481d3bd1e5SMatthias Ringwald 49cd56fb44SMatthias Ringwaldbuild-coverage/btstack_linked_list_test: ${COMMON_OBJ_COVERAGE} build-coverage/btstack_linked_list_test.o | build-coverage 501d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 51cd56fb44SMatthias Ringwald 52cd56fb44SMatthias Ringwaldbuild-asan/btstack_linked_list_test: ${COMMON_OBJ_ASAN} build-asan/btstack_linked_list_test.o | build-asan 531d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 542412778bSmatthias.ringwald 558e8dfe94SMatthias Ringwaldtest: all 56cd56fb44SMatthias Ringwald build-asan/btstack_linked_list_test 573d87570fSMatthias Ringwald 583d87570fSMatthias Ringwaldcoverage: all 59cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 603d87570fSMatthias Ringwald build-coverage/btstack_linked_list_test 6157fe2af8SMatthias Ringwald 622412778bSmatthias.ringwaldclean: 63cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 64