xref: /btstack/test/hid_parser/Makefile (revision 98e87e7776ef9a7fe55135aea8cddc761fe3a7a5)
112ccb71bSMatthias Ringwald# Requirements: cpputest.github.io
212ccb71bSMatthias Ringwald
312ccb71bSMatthias RingwaldBTSTACK_ROOT =  ../..
412ccb71bSMatthias 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 -x c++ -g -Wall -Wnarrowing -Wconversion-null
10b338ca60SMatthias Ringwald
11e0ff5d41SMatthias RingwaldCFLAGS += -I.
12e0ff5d41SMatthias RingwaldCFLAGS += -I ${BTSTACK_ROOT}/src
13e0ff5d41SMatthias RingwaldCFLAGS += -I ${BTSTACK_ROOT}/platform/posix
14e0ff5d41SMatthias Ringwald
1531437b52SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src ${BTSTACK_ROOT}/platform/posix
1612ccb71bSMatthias Ringwald
1712ccb71bSMatthias RingwaldCOMMON = \
183d87570fSMatthias Ringwald	btstack_util.c \
193d87570fSMatthias Ringwald	btstack_hid_parser.c \
2031437b52SMatthias Ringwald	hci_dump.c \
2131437b52SMatthias Ringwald	hci_dump_posix_fs.c \
2212ccb71bSMatthias Ringwald
23cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
2471d52576SMatthias RingwaldCFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
2512ccb71bSMatthias Ringwald
26cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
27cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
28cd56fb44SMatthias RingwaldLDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
2912ccb71bSMatthias Ringwald
30cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
31cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o))
32cd56fb44SMatthias Ringwald
33cd56fb44SMatthias Ringwaldall: build-coverage/hid_parser_test build-asan/hid_parser_test
34cd56fb44SMatthias Ringwald
35cd56fb44SMatthias Ringwaldbuild-%:
36cd56fb44SMatthias Ringwald	mkdir -p $@
3712ccb71bSMatthias Ringwald
383d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage
39cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
403d87570fSMatthias Ringwald
411d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage
421d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
431d3bd1e5SMatthias Ringwald
44cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan
45cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_ASAN) $< -o $@
46cd56fb44SMatthias Ringwald
471d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan
481d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_ASAN) $< -o $@
49cd56fb44SMatthias Ringwald
50cd56fb44SMatthias Ringwaldbuild-coverage/hid_parser_test: ${COMMON_OBJ_COVERAGE} build-coverage/hid_parser_test.o | build-coverage
511d3bd1e5SMatthias Ringwald	${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
52cd56fb44SMatthias Ringwald
53cd56fb44SMatthias Ringwaldbuild-asan/hid_parser_test: ${COMMON_OBJ_ASAN} build-asan/hid_parser_test.o | build-asan
541d3bd1e5SMatthias Ringwald	${CXX} $^ ${LDFLAGS_ASAN} -o $@
55cd56fb44SMatthias Ringwald
5612ccb71bSMatthias Ringwald
5712ccb71bSMatthias Ringwaldtest: all
58cd56fb44SMatthias Ringwald	build-asan/hid_parser_test
593d87570fSMatthias Ringwald
603d87570fSMatthias Ringwaldcoverage: all
61cd56fb44SMatthias Ringwald	rm -f build-coverage/*.gcda
623d87570fSMatthias Ringwald	build-coverage/hid_parser_test
6312ccb71bSMatthias Ringwald
6412ccb71bSMatthias Ringwaldclean:
65cd56fb44SMatthias Ringwald	rm -rf build-coverage build-asan
6612ccb71bSMatthias Ringwald
67