1344f488cSMilanka Ringwald# Requirements: cpputest.github.io 2344f488cSMilanka Ringwald 3344f488cSMilanka RingwaldBTSTACK_ROOT = ../.. 4344f488cSMilanka Ringwald 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 13344f488cSMilanka RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 14344f488cSMilanka Ringwald 15344f488cSMilanka RingwaldVPATH += ${BTSTACK_ROOT}/src/ble 16344f488cSMilanka RingwaldVPATH += ${BTSTACK_ROOT}/src 177c006017SMilanka RingwaldVPATH += ${BTSTACK_ROOT}/src/classic 18344f488cSMilanka RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 19344f488cSMilanka Ringwald 20344f488cSMilanka RingwaldCOMMON = \ 21344f488cSMilanka Ringwald btstack_util.c \ 227c006017SMilanka Ringwald obex_message_builder.c \ 23ac9a0d84SMatthias Ringwald obex_parser.c 24344f488cSMilanka Ringwald 25cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 2671d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 27344f488cSMilanka Ringwald 28cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 29cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 30cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 31344f488cSMilanka Ringwald 32cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 33cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 34cd56fb44SMatthias Ringwald 35ac9a0d84SMatthias Ringwaldall: build-coverage/obex_message_builder_test build-asan/obex_message_builder_test \ 36ac9a0d84SMatthias Ringwald build-coverage/obex_parser_test build-asan/obex_parser_test 37cd56fb44SMatthias Ringwald 38cd56fb44SMatthias Ringwaldbuild-%: 39cd56fb44SMatthias Ringwald mkdir -p $@ 403d87570fSMatthias Ringwald 413d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 42cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 433d87570fSMatthias Ringwald 441d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 451d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 461d3bd1e5SMatthias Ringwald 47cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 48cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) $< -o $@ 49cd56fb44SMatthias Ringwald 501d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 511d3bd1e5SMatthias Ringwald ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 52ac9a0d84SMatthias Ringwald 53cd56fb44SMatthias Ringwald 54cd56fb44SMatthias Ringwaldbuild-coverage/obex_message_builder_test: ${COMMON_OBJ_COVERAGE} build-coverage/obex_message_builder_test.o | build-coverage 551d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 56cd56fb44SMatthias Ringwald 57cd56fb44SMatthias Ringwaldbuild-asan/obex_message_builder_test: ${COMMON_OBJ_ASAN} build-asan/obex_message_builder_test.o | build-asan 581d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 59344f488cSMilanka Ringwald 601d3bd1e5SMatthias Ringwaldbuild-coverage/obex_parser_test: ${COMMON_OBJ_COVERAGE} build-coverage/obex_parser_test.o | build-coverage 611d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 62ac9a0d84SMatthias Ringwald 631d3bd1e5SMatthias Ringwaldbuild-asan/obex_parser_test: ${COMMON_OBJ_ASAN} build-asan/obex_parser_test.o | build-asan 641d3bd1e5SMatthias Ringwald ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 65ac9a0d84SMatthias Ringwald 66344f488cSMilanka Ringwaldtest: all 67cd56fb44SMatthias Ringwald build-asan/obex_message_builder_test 68ac9a0d84SMatthias Ringwald build-asan/obex_parser_test 693d87570fSMatthias Ringwald 703d87570fSMatthias Ringwaldcoverage: all 71cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 723d87570fSMatthias Ringwald build-coverage/obex_message_builder_test 73ac9a0d84SMatthias Ringwald build-coverage/obex_parser_test 74344f488cSMilanka Ringwald 75344f488cSMilanka Ringwaldclean: 76cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 77344f488cSMilanka Ringwald 78