1# Requirements: cpputest.github.io 2 3BTSTACK_ROOT = ../.. 4 5# CppuTest from pkg-config 6CFLAGS += ${shell pkg-config --cflags CppuTest} 7LDFLAGS += ${shell pkg-config --libs CppuTest} 8 9CFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null 10CFLAGS += -I${BTSTACK_ROOT}/src 11CFLAGS += -I.. 12 13VPATH += ${BTSTACK_ROOT}/src 14VPATH += ${BTSTACK_ROOT}/src/classic 15VPATH += ${BTSTACK_ROOT}/platform/posix 16 17COMMON = \ 18 btstack_util.c \ 19 btstack_linked_list.c \ 20 hci_dump.c \ 21 avdtp_util.c \ 22 23 24CFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 25CFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 26 27LDFLAGS += -lCppUTest -lCppUTestExt 28LDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 29LDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 30 31COMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o)) 32COMMON_OBJ_ASAN = $(addprefix build-asan/, $(COMMON:.c=.o)) 33 34all: build-coverage/avdtp_util_test build-asan/avdtp_util_test 35 36build-%: 37 mkdir -p $@ 38 39build-coverage/%.o: %.c | build-coverage 40 ${CC} -c $(CFLAGS_COVERAGE) $< -o $@ 41 42build-coverage/%.o: %.cpp | build-coverage 43 ${CXX} -c $(CFLAGS_COVERAGE) $< -o $@ 44 45build-asan/%.o: %.c | build-asan 46 ${CC} -c $(CFLAGS_ASAN) $< -o $@ 47 48build-asan/%.o: %.cpp | build-asan 49 ${CXX} -c $(CFLAGS_ASAN) $< -o $@ 50 51build-coverage/avdtp_util_test: ${COMMON_OBJ_COVERAGE} build-coverage/avdtp_util_test.o | build-coverage 52 ${CXX} $^ ${LDFLAGS_COVERAGE} -o $@ 53 54build-asan/avdtp_util_test: ${COMMON_OBJ_ASAN} build-asan/avdtp_util_test.o | build-asan 55 ${CXX} $^ ${LDFLAGS_ASAN} -o $@ 56 57test: all 58 build-asan/avdtp_util_test 59 60coverage: all 61 rm -f build-coverage/*.gcda 62 build-coverage/avdtp_util_test 63 64clean: 65 rm -rf build-coverage build-asan 66 67