1# Makefile for libusb based PTS tests 2BTSTACK_ROOT = ../.. 3 4# CppuTest from pkg-config 5CFLAGS += ${shell pkg-config --cflags CppuTest} 6LDFLAGS += ${shell pkg-config --libs CppuTest} 7 8CORE += \ 9 btstack_memory.c \ 10 btstack_linked_list.c \ 11 btstack_memory_pool.c \ 12 btstack_run_loop.c \ 13 btstack_util.c \ 14 main.c \ 15 btstack_stdin_posix.c \ 16 btstack_tlv.c \ 17 btstack_tlv_posix.c \ 18 rijndael.c \ 19 20COMMON += \ 21 hci.c \ 22 ad_parser.c \ 23 hci_cmd.c \ 24 hci_event_builder.c \ 25 hci_dump.c \ 26 hci_dump_posix_fs.c \ 27 l2cap.c \ 28 l2cap_signaling.c \ 29 hci_transport_h2_libusb.c \ 30 btstack_crypto.c \ 31 btstack_run_loop_posix.c \ 32 le_device_db_tlv.c \ 33 sm.c \ 34 uECC.c \ 35 btstack_chipset_zephyr.c \ 36 37ATT += \ 38 att_dispatch.c \ 39 40GATT_SERVER += \ 41 att_db.c \ 42 att_server.c \ 43 44GATT_CLIENT += \ 45 gatt_client.c \ 46 47SM += \ 48 sm.c \ 49 50CFLAGS += -g -std=c99 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-parameter -Wredundant-decls -Wsign-compare 51CFLAGS += -D ENABLE_TESTING_SUPPORT 52CFLAGS += -DCOVERAGE 53CFLAGS += -I. 54CFLAGS += -Ibuild-coverage 55CFLAGS += -I${BTSTACK_ROOT}/src 56CFLAGS += -I${BTSTACK_ROOT}/3rd-party/micro-ecc 57CFLAGS += -I${BTSTACK_ROOT}/3rd-party/rijndael 58CFLAGS += -I${BTSTACK_ROOT}/3rd-party/tinydir 59CFLAGS += -I${BTSTACK_ROOT}/chipset/zephyr 60CFLAGS += -I${BTSTACK_ROOT}/platform/posix 61CFLAGS += -I${BTSTACK_ROOT}/platform/embedded 62 63VPATH += ${BTSTACK_ROOT}/src 64VPATH += ${BTSTACK_ROOT}/src/ble 65VPATH += ${BTSTACK_ROOT}/platform/posix 66VPATH += ${BTSTACK_ROOT}/platform/libusb 67VPATH += ${BTSTACK_ROOT}/3rd-party/micro-ecc 68VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael 69VPATH += ${BTSTACK_ROOT}/chipset/zephyr 70 71# coverage 72CFLAGS += -fprofile-arcs -ftest-coverage 73LDFLAGS += -fprofile-arcs -ftest-coverage 74 75# use pkg-config for libusb 76CFLAGS += $(shell pkg-config libusb-1.0 --cflags) 77LDFLAGS += $(shell pkg-config libusb-1.0 --libs) 78 79CORE_OBJ = $(addprefix build-coverage/,$(CORE:.c=.o)) 80COMMON_OBJ = $(addprefix build-coverage/,$(COMMON:.c=.o)) 81ATT_OBJ = $(addprefix build-coverage/,$(ATT:.c=.o)) 82SM_OBJ = $(addprefix build-coverage/,$(SM:.c=.o)) 83GATT_CLIENT_OBJ = $(addprefix build-coverage/,$(GATT_CLIENT:.c=.o)) 84GATT_SERVER_OBJ = $(addprefix build-coverage/,$(GATT_SERVER:.c=.o)) 85 86# compile .gatt descriptions 87build-coverage/%.h: %.gatt 88 python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ 89 90.PHONY: all coverage test 91 92all: build-coverage/sm_test 93 94build-%: 95 mkdir -p $@ 96 97build-coverage/sm_test.h: sm_test.gatt | build-coverage 98 python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ 99 100build-coverage/%.o: %.c | build-coverage 101 ${CC} -c $(CFLAGS) ${CPPFLAGS} $< -o $@ 102 103build-coverage/sm_test: build-coverage/sm_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${GATT_CLIENT_OBJ} ${SM_OBJ} build-coverage/sm_test.o | build-coverage 104 ${CC} $(filter-out build-coverage/sm_test.h,$^) ${LDFLAGS} -o $@ 105 106myclean: 107 rm -rf build-coverage 108 rm -f *.o 109 rm -rf *.dSYM 110 rm -f *.gcno *.gcda 111 rm -rf SM_* 112 113clean: myclean 114 115test: build-coverage/sm_test 116 rm -rf SM_* 117 python3 ./sm_test.py 118 119coverage: build-coverage/sm_test 120 # delete trace data 121 rm -f build-coverage/*.gcda 122 # run tests 123 make test 124 # collect traces 125 lcov --capture --rc lcov_branch_coverage=1 --directory . --exclude "/Applications/*" --exclude "/Library/*" --exclude "/usr/*" --exclude "*/test/*" --output-file coverage-sm-sc.info 126 # demangle 127 python3 ../coverage_demangle.py coverage-sm-sc.info 128