xref: /btstack/test/maths/Makefile (revision 98e87e7776ef9a7fe55135aea8cddc761fe3a7a5)
140e1e61cSMilanka Ringwald# Requirements: cpputest.github.io
240e1e61cSMilanka Ringwald
340e1e61cSMilanka RingwaldBTSTACK_ROOT =  ../..
4*98e87e77SMatthias Ringwald# CppuTest from pkg-config
5*98e87e77SMatthias RingwaldCFLAGS  += ${shell pkg-config --cflags CppuTest}
6*98e87e77SMatthias RingwaldLDFLAGS += ${shell pkg-config --libs   CppuTest}
740e1e61cSMilanka Ringwald
8*98e87e77SMatthias RingwaldCFLAGS += -DUNIT_TEST -g -Wall -Wnarrowing -Wconversion-null -Ibuild-coverage -I./
9*98e87e77SMatthias Ringwald
1040e1e61cSMilanka RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
1140e1e61cSMilanka Ringwald
12cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
1371d52576SMatthias RingwaldCFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
1440e1e61cSMilanka Ringwald
15cd56fb44SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
16cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
17cd56fb44SMatthias RingwaldLDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
1840e1e61cSMilanka Ringwald
19cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
20cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o))
21cd56fb44SMatthias Ringwald
22cd56fb44SMatthias Ringwaldall: build-coverage/sqrt_test build-asan/sqrt_test
23cd56fb44SMatthias Ringwald
24cd56fb44SMatthias Ringwaldbuild-%:
25cd56fb44SMatthias Ringwald	mkdir -p $@
263d87570fSMatthias Ringwald
273d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage
28cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
293d87570fSMatthias Ringwald
301d3bd1e5SMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage
311d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_COVERAGE) $< -o $@
321d3bd1e5SMatthias Ringwald
33cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan
34cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_ASAN) $< -o $@
35cd56fb44SMatthias Ringwald
361d3bd1e5SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan
371d3bd1e5SMatthias Ringwald	${CXX} -c $(CFLAGS_ASAN) $< -o $@
381d3bd1e5SMatthias Ringwald
39cd56fb44SMatthias Ringwald
40cd56fb44SMatthias Ringwaldbuild-coverage/sqrt_test: ${COMMON_OBJ_COVERAGE} build-coverage/sqrt_test.o | build-coverage
411d3bd1e5SMatthias Ringwald	${CXX} $^ ${LDFLAGS_COVERAGE} -o $@
42cd56fb44SMatthias Ringwald
43cd56fb44SMatthias Ringwaldbuild-asan/sqrt_test: ${COMMON_OBJ_ASAN} build-asan/sqrt_test.o | build-asan
441d3bd1e5SMatthias Ringwald	${CXX} $^ ${LDFLAGS_ASAN} -o $@
4540e1e61cSMilanka Ringwald
4640e1e61cSMilanka Ringwaldtest: all
47cd56fb44SMatthias Ringwald	build-asan/sqrt_test
483d87570fSMatthias Ringwald
493d87570fSMatthias Ringwaldcoverage: all
50cd56fb44SMatthias Ringwald	rm -f build-coverage/*.gcda
513d87570fSMatthias Ringwald	build-coverage/sqrt_test
5240e1e61cSMilanka Ringwald
5340e1e61cSMilanka Ringwaldclean:
54cd56fb44SMatthias Ringwald	rm -rf build-coverage build-asan
5540e1e61cSMilanka Ringwald
56