xref: /btstack/test/embedded/Makefile (revision c9f0088dec2161e29c20339e11f9068b16b23ee2)
1353d71a9SMatthias RingwaldCC = g++
2353d71a9SMatthias Ringwald
3353d71a9SMatthias Ringwald# Requirements: cpputest.github.io
4353d71a9SMatthias Ringwald
5353d71a9SMatthias RingwaldBTSTACK_ROOT =  ../..
6353d71a9SMatthias Ringwald
7e0ff5d41SMatthias RingwaldCFLAGS  = -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null
8e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/src
9e0ff5d41SMatthias RingwaldCFLAGS += -I${BTSTACK_ROOT}/platform/embedded
10e0ff5d41SMatthias RingwaldCFLAGS += -I.
11353d71a9SMatthias Ringwald
12713ac744SMatthias RingwaldCFLAGS += -DHAVE_HAL_AUDIO
13713ac744SMatthias Ringwald
14cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage
1571d52576SMatthias RingwaldCFLAGS_ASAN     = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT
16cd56fb44SMatthias Ringwald
17353d71a9SMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt
18cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage
19cd56fb44SMatthias RingwaldLDFLAGS_ASAN     = ${LDFLAGS} -fsanitize=address
20353d71a9SMatthias Ringwald
21353d71a9SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src
22353d71a9SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/ble
23353d71a9SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/embedded
24713ac744SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/freertos
25353d71a9SMatthias Ringwald
26353d71a9SMatthias RingwaldCOMMON = \
271f56122cSMatthias Ringwald    btstack_linked_list.c  \
28516e2db7SMilanka Ringwald	btstack_memory.c \
29a288e044SMatthias Ringwald	btstack_run_loop.c \
301f56122cSMatthias Ringwald	btstack_run_loop_embedded.c \
31a288e044SMatthias Ringwald    btstack_util.c		  \
32353d71a9SMatthias Ringwald    hci_dump.c    \
33*c9f0088dSMilanka Ringwald    l2cap_signaling.c \
341f56122cSMatthias Ringwald
351f56122cSMatthias Ringwald# not used yet
361f56122cSMatthias Ringwald#	btstack_em9304_spi_embedded.c \
371f56122cSMatthias Ringwald#	btstack_stdin_embedded.c \
381f56122cSMatthias Ringwald#	btstack_tlv_flash_bank.c \
391f56122cSMatthias Ringwald#	btstack_uart_block_embedded.c \
401f56122cSMatthias Ringwald#	hal_flash_bank_memory.c \
411f56122cSMatthias Ringwald#   btstack_audio.c \
421f56122cSMatthias Ringwald#   btstack_audio_embedded.c \
431f56122cSMatthias Ringwald#   btstack_resample.c \
441f56122cSMatthias Ringwald#   btstack_ring_buffer.c \
451f56122cSMatthias Ringwald#   btstack_slip.c \
461f56122cSMatthias Ringwald#   hci_transport_em9304_spi.c \
471f56122cSMatthias Ringwald#   hci_transport_h4.c \
481f56122cSMatthias Ringwald#   hci_transport_h5.c \
49353d71a9SMatthias Ringwald
50cd56fb44SMatthias RingwaldFREERTOS = \
51cd56fb44SMatthias Ringwald	btstack_run_loop_freertos.c \
521f56122cSMatthias Ringwald#	btstack_uart_block_freertos.c \
53353d71a9SMatthias Ringwald
54cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON:.c=.o))
55cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN     = $(addprefix build-asan/,    $(COMMON:.c=.o))
56713ac744SMatthias Ringwald
57cd56fb44SMatthias RingwaldFREERTOS_OBJ_COVERAGE = $(addprefix build-coverage/,$(FREERTOS:.c=.o))
58cd56fb44SMatthias RingwaldFREERTOS_OBJ_ASAN     = $(addprefix build-asan/,    $(FREERTOS:.c=.o))
59353d71a9SMatthias Ringwald
60cd56fb44SMatthias Ringwaldall: build-coverage/embedded_test build-coverage/freertos_test build-asan/embedded_test build-asan/freertos_test
613d87570fSMatthias Ringwald
62cd56fb44SMatthias Ringwaldbuild-%:
63cd56fb44SMatthias Ringwald	mkdir -p $@
64353d71a9SMatthias Ringwald
65cd56fb44SMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage
66cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_COVERAGE) $< -o $@
67cd56fb44SMatthias Ringwald
68cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan
69cd56fb44SMatthias Ringwald	${CC} -c $(CFLAGS_ASAN) $< -o $@
70cd56fb44SMatthias Ringwald
71cd56fb44SMatthias Ringwald
7238b632b5SMatthias Ringwaldbuild-coverage/embedded_test: ${COMMON_OBJ_COVERAGE} build-coverage/embedded_test.o | build-coverage
73cd56fb44SMatthias Ringwald	${CC} $^ ${LDFLAGS_COVERAGE} -o $@
74cd56fb44SMatthias Ringwald
7538b632b5SMatthias Ringwaldbuild-coverage/freertos_test: ${COMMON_OBJ_COVERAGE} ${FREERTOS_OBJS} build-coverage/freertos_test.o | build-coverage
76cd56fb44SMatthias Ringwald	${CC} $^ ${LDFLAGS_COVERAGE} -o $@
77cd56fb44SMatthias Ringwald
7838b632b5SMatthias Ringwaldbuild-asan/embedded_test: ${COMMON_OBJ_ASAN} build-asan/embedded_test.o | build-asan
79cd56fb44SMatthias Ringwald	${CC} $^ ${LDFLAGS_ASAN} -o $@
80cd56fb44SMatthias Ringwald
8138b632b5SMatthias Ringwaldbuild-asan/freertos_test: ${COMMON_OBJ_ASAN} ${FREERTOS_OBJS} build-asan/freertos_test.o | build-asan
82cd56fb44SMatthias Ringwald	${CC} $^ ${LDFLAGS_ASAN} -o $@
83713ac744SMatthias Ringwald
84353d71a9SMatthias Ringwaldtest: all
85cd56fb44SMatthias Ringwald	build-asan/embedded_test
86cd56fb44SMatthias Ringwald	build-asan/freertos_test
873d87570fSMatthias Ringwald
883d87570fSMatthias Ringwaldcoverage: all
89cd56fb44SMatthias Ringwald	rm -f build-coverage/*.gcda
903d87570fSMatthias Ringwald	build-coverage/embedded_test
913d87570fSMatthias Ringwald	build-coverage/freertos_test
92353d71a9SMatthias Ringwald
93353d71a9SMatthias Ringwaldclean:
94cd56fb44SMatthias Ringwald	rm -rf build-coverage build-asan
95