18e8dfe94SMatthias Ringwald# Requirements: cpputest.github.io 260c84a44S[email protected] 360c84a44S[email protected]BTSTACK_ROOT = ../.. 460c84a44S[email protected] 5*98e87e77SMatthias Ringwald# CppuTest from pkg-config 6*98e87e77SMatthias RingwaldCFLAGS += ${shell pkg-config --cflags CppuTest} 7*98e87e77SMatthias RingwaldLDFLAGS += ${shell pkg-config --libs CppuTest} 8*98e87e77SMatthias Ringwald 9*98e87e77SMatthias RingwaldCFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null 10e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src 11e0ff5d41SMatthias RingwaldCFLAGS += -I. 12e0ff5d41SMatthias Ringwald 13cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 1471d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 15cd56fb44SMatthias Ringwald 16a35c9b93SMilanka RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 17cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 18cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 1960c84a44S[email protected] 203edc84c5SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble 21cbe987fbSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src 22dd9e275cSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 23cbe987fbSMatthias Ringwald 2460c84a44S[email protected]COMMON = \ 254fd23d47SMatthias Ringwald btstack_linked_list.c \ 26cbe987fbSMatthias Ringwald btstack_memory.c \ 27f032a441SMatthias Ringwald btstack_memory_pool.c \ 28f032a441SMatthias Ringwald btstack_run_loop.c \ 29f032a441SMatthias Ringwald btstack_run_loop_posix.c \ 30f032a441SMatthias Ringwald btstack_util.c \ 31a484130cSMatthias Ringwald hci.c \ 3256042629SMatthias Ringwald hci_cmd.c \ 33cbe987fbSMatthias Ringwald hci_dump.c \ 3460c84a44S[email protected] 35cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 36cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 3760c84a44S[email protected] 38cd56fb44SMatthias Ringwaldall: build-coverage/ad_parser_test build-asan/ad_parser_test 3960c84a44S[email protected] 40cd56fb44SMatthias Ringwaldbuild-%: 41cd56fb44SMatthias Ringwald mkdir -p $@ 423d87570fSMatthias Ringwald 43cd56fb44SMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 44cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 45cd56fb44SMatthias Ringwald 461d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 471d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 481d3bd1e5SMatthias 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 55cd56fb44SMatthias Ringwaldbuild-coverage/ad_parser_test: ${COMMON_OBJ_COVERAGE} build-coverage/ad_parser_test.o | build-coverage 561d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 57cd56fb44SMatthias Ringwald 58cd56fb44SMatthias Ringwaldbuild-asan/ad_parser_test: ${COMMON_OBJ_ASAN} build-asan/ad_parser_test.o | build-asan 591d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 6060c84a44S[email protected] 618e8dfe94SMatthias Ringwaldtest: all 62cd56fb44SMatthias Ringwald build-asan/ad_parser_test 633d87570fSMatthias Ringwald 643d87570fSMatthias Ringwaldcoverage: all 65cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 663d87570fSMatthias Ringwald build-coverage/ad_parser_test 6757fe2af8SMatthias Ringwald 6860c84a44S[email protected]clean: 69cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 70