18e8dfe94SMatthias Ringwald# Requirements: cpputest.github.io 2fdcd1130S[email protected] 3fdcd1130S[email protected]BTSTACK_ROOT = ../.. 4fdcd1130S[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 1090fe6d5fSMatthias RingwaldCFLAGS += -I. -I.. -I${BTSTACK_ROOT}/src 1190fe6d5fSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/embedded 1231437b52SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/posix 1394d1976dSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/mbedtls/include 14af03003cSMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc 15f13fc290SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael 1657fe2af8SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 1757fe2af8SMatthias Ringwald 1857fe2af8SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src 193edc84c5SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble 2090fe6d5fSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/embedded 2131437b52SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 22af03003cSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc 23f13fc290SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/rijndael 24fdcd1130S[email protected] 25fdcd1130S[email protected]COMMON = \ 266894dd39SMatthias Ringwald btstack_crypto.c \ 274ab92137SMatthias Ringwald btstack_linked_list.c \ 2857fe2af8SMatthias Ringwald btstack_memory.c \ 29d2e6c4b7SMatthias Ringwald btstack_memory_pool.c \ 304ab92137SMatthias Ringwald btstack_run_loop.c \ 3190fe6d5fSMatthias Ringwald btstack_run_loop_embedded.c \ 3256042629SMatthias Ringwald hci_cmd.c \ 3357fe2af8SMatthias Ringwald hci_dump.c \ 3431437b52SMatthias Ringwald hci_dump_posix_fs.c \ 3557fe2af8SMatthias Ringwald le_device_db_memory.c \ 36a484130cSMatthias Ringwald mock.c \ 374ab92137SMatthias Ringwald rijndael.c \ 384ab92137SMatthias Ringwald sm.c \ 39eb886013SMatthias Ringwald btstack_util.c \ 40489a58deSMatthias Ringwald btstack_tlv.c \ 41fdcd1130S[email protected] 42cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 4371d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 44fdcd1130S[email protected] 45cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 46cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 47cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 4894d1976dSMatthias Ringwald 49e0ff5d41SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) build-coverage/uECC.o 50e0ff5d41SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) build-asan/uECC.o 51cd56fb44SMatthias Ringwald 52cd56fb44SMatthias Ringwaldall: build-coverage/security_manager build-asan/security_manager 53cd56fb44SMatthias Ringwald 54cd56fb44SMatthias Ringwaldbuild-%: 55cd56fb44SMatthias Ringwald mkdir -p $@ 56af03003cSMatthias Ringwald 573d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 58e0ff5d41SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 59cd56fb44SMatthias Ringwald 601d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 611d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 621d3bd1e5SMatthias Ringwald 63e0ff5d41SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 641d3bd1e5SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) $< -o $@ 65cd56fb44SMatthias Ringwald 66e0ff5d41SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 671d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 68e0ff5d41SMatthias Ringwald 69e2c00bfeSMatthias Ringwald 70e2c00bfeSMatthias Ringwaldbuild-coverage/security_manager: ${COMMON_OBJ_COVERAGE} build-coverage/security_manager.o | build-coverage 711d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 72cd56fb44SMatthias Ringwald 73e2c00bfeSMatthias Ringwaldbuild-asan/security_manager: ${COMMON_OBJ_ASAN} build-asan/security_manager.o | build-asan 741d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 75cd56fb44SMatthias Ringwald 76fdcd1130S[email protected] 778e8dfe94SMatthias Ringwaldtest: all 78cd56fb44SMatthias Ringwald build-asan/security_manager 793d87570fSMatthias Ringwald 803d87570fSMatthias Ringwaldcoverage: all 81cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 823d87570fSMatthias Ringwald build-coverage/security_manager 8357fe2af8SMatthias Ringwald 84fdcd1130S[email protected]clean: 85cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 86