11fbe4564SMatthias Ringwald # Makefile for libusb based examples 21fbe4564SMatthias RingwaldBTSTACK_ROOT = ../.. 31fbe4564SMatthias Ringwald 4752b29f3SMilanka RingwaldATT += \ 5752b29f3SMilanka Ringwald att_dispatch.c \ 6752b29f3SMilanka Ringwald att_db.c \ 7752b29f3SMilanka Ringwald att_server.c \ 8752b29f3SMilanka Ringwald gatt_bearer.c \ 9752b29f3SMilanka Ringwald mesh_proxy_service_server.c \ 10752b29f3SMilanka Ringwald 111fbe4564SMatthias RingwaldCORE += \ 121fbe4564SMatthias Ringwald adv_bearer.c \ 131fbe4564SMatthias Ringwald beacon.c \ 141fbe4564SMatthias Ringwald btstack_link_key_db_fs.c \ 151fbe4564SMatthias Ringwald btstack_run_loop_posix.c \ 161fbe4564SMatthias Ringwald btstack_stdin_posix.c \ 17*f8da99a8SMatthias Ringwald btstack_uart_posix_pty.c \ 181fbe4564SMatthias Ringwald hci_transport_h2_libusb.c \ 191fbe4564SMatthias Ringwald hci_transport_h4.c \ 201fbe4564SMatthias Ringwald btstack_tlv_posix.c \ 2104875b11SMatthias Ringwald mesh_iv_index_seq_number.c \ 220e329b41SMatthias Ringwald mesh_node.c \ 231fbe4564SMatthias Ringwald le_device_db_fs.c \ 241fbe4564SMatthias Ringwald l2cap.c \ 251fbe4564SMatthias Ringwald uECC.c \ 261fbe4564SMatthias Ringwald rijndael.c \ 27d61023b2SMilanka Ringwald 281fbe4564SMatthias Ringwald 2939018edaSMilanka Ringwald 301fbe4564SMatthias Ringwald# examples 311fbe4564SMatthias Ringwaldinclude ${BTSTACK_ROOT}/example/Makefile.inc 32777f7d8dSMilanka Ringwaldinclude ${BTSTACK_ROOT}/src/ble/gatt-service/Makefile.inc 331fbe4564SMatthias Ringwald 3439018edaSMilanka Ringwald 3526ecb624SMilanka RingwaldCFLAGS += -g -DUNIT_TEST -Wall \ 361fbe4564SMatthias Ringwald -I$(BTSTACK_ROOT)/platform/embedded \ 371fbe4564SMatthias Ringwald -I$(BTSTACK_ROOT)/platform/posix \ 381fbe4564SMatthias Ringwald -I$(BTSTACK_ROOT)/3rd-party/tinydir \ 39f13fc290SMatthias Ringwald -I$(BTSTACK_ROOT)/3rd-party/rijndael \ 401fbe4564SMatthias Ringwald 4113753703SMatthias RingwaldCFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wunused-parameter -Wredundant-decls -Wsign-compare 42497cc682SMatthias Ringwald 43f13fc290SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/3rd-party/rijndael 4477ba3d3fSMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/mesh 451fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/src/classic 461fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/posix 471fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/embedded 481fbe4564SMatthias RingwaldVPATH += ${BTSTACK_ROOT}/platform/libusb 49777f7d8dSMilanka RingwaldVPATH += ${BTSTACK_ROOT}/src/ble/gatt-service 501fbe4564SMatthias Ringwald 511fbe4564SMatthias Ringwald# cpputest 521fbe4564SMatthias RingwaldCC_UNIT = g++ 531fbe4564SMatthias Ringwald 541fbe4564SMatthias Ringwald# libusb 551fbe4564SMatthias RingwaldCFLAGS += $(shell pkg-config libusb-1.0 --cflags) 561fbe4564SMatthias RingwaldLDFLAGS += $(shell pkg-config libusb-1.0 --libs) 571fbe4564SMatthias Ringwald 58cd56fb44SMatthias RingwaldCFLAGS_COVERAGE = ${CFLAGS} -fprofile-arcs -ftest-coverage 5971d52576SMatthias RingwaldCFLAGS_ASAN = ${CFLAGS} -fsanitize=address -DHAVE_ASSERT 60cd56fb44SMatthias Ringwald 61c956179dSMatthias Ringwald# cppUTest 62c956179dSMatthias RingwaldLDFLAGS += -lCppUTest -lCppUTestExt 63c956179dSMatthias Ringwald 64cd56fb44SMatthias RingwaldLDFLAGS_COVERAGE = ${LDFLAGS} -fprofile-arcs -ftest-coverage 65cd56fb44SMatthias RingwaldLDFLAGS_ASAN = ${LDFLAGS} -fsanitize=address 66c956179dSMatthias Ringwald 67cd56fb44SMatthias RingwaldCOMMON_OBJ_COVERAGE = $(addprefix build-coverage/,$(COMMON_OBJ)) 68cd56fb44SMatthias RingwaldCORE_OBJ_COVERAGE = $(addprefix build-coverage/,$(CORE_OBJ)) 69cd56fb44SMatthias RingwaldATT_OBJ_COVERAGE = $(addprefix build-coverage/,$(ATT_OBJ)) 70cd56fb44SMatthias RingwaldGATT_SERVER_OBJ_COVERAGE = $(addprefix build-coverage/,$(GATT_SERVER_OBJ)) 71cd56fb44SMatthias RingwaldSM_OB_COVERAGE = $(addprefix build-coverage/,$(SM_OB)) 72cd56fb44SMatthias RingwaldMESH_OBJ_COVERAGE = $(addprefix build-coverage/,$(MESH_OBJ)) 731fbe4564SMatthias Ringwald 74cd56fb44SMatthias RingwaldCOMMON_OBJ_ASAN = $(addprefix build-asan/,$(COMMON_OBJ)) 75cd56fb44SMatthias RingwaldCORE_OBJ_ASAN = $(addprefix build-asan/,$(CORE_OBJ)) 76cd56fb44SMatthias RingwaldATT_OBJ_ASAN = $(addprefix build-asan/,$(ATT_OBJ)) 77cd56fb44SMatthias RingwaldGATT_SERVER_OBJ_ASAN = $(addprefix build-asan/,$(GATT_SERVER_OBJ)) 78cd56fb44SMatthias RingwaldSM_OB_ASAN = $(addprefix build-asan/,$(SM_OB)) 79cd56fb44SMatthias RingwaldMESH_OBJ_ASAN = $(addprefix build-asan/,$(MESH_OBJ)) 80777f7d8dSMilanka Ringwald 813d87570fSMatthias RingwaldTESTS_SRCS = mesh_message_test provisioning_device_test provisioning_provisioner_test mesh_configuration_composition_data_message_test 823d87570fSMatthias RingwaldEXAMPLES = mesh_pts provisioner sniffer 831fbe4564SMatthias Ringwald 84cd56fb44SMatthias Ringwald 85cd56fb44SMatthias Ringwaldall: $(addprefix build-asan/,$(EXAMPLES)) 86cd56fb44SMatthias Ringwaldtests: $(addprefix build-asan/,$(TESTS_SRCS)) 87cd56fb44SMatthias Ringwald 88cd56fb44SMatthias Ringwaldbuild-%: 89cd56fb44SMatthias Ringwald mkdir -p $@ 90cd56fb44SMatthias Ringwald 911fbe4564SMatthias Ringwald 923d87570fSMatthias Ringwaldbuild-coverage/%.o: %.c | build-coverage 93cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) ${CPPFLAGS} $< -o $@ 943d87570fSMatthias Ringwald 953d87570fSMatthias Ringwaldbuild-coverage/%.o: %.cpp | build-coverage 96cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_COVERAGE) ${CPPFLAGS} $< -o $@ 973d87570fSMatthias Ringwald 98cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.c | build-asan 99cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) ${CPPFLAGS} $< -o $@ 100cd56fb44SMatthias Ringwald 101cd56fb44SMatthias Ringwaldbuild-asan/%.o: %.cpp | build-asan 102cd56fb44SMatthias Ringwald ${CC} -c $(CFLAGS_ASAN) ${CPPFLAGS} $< -o $@ 103cd56fb44SMatthias Ringwald 104cd56fb44SMatthias Ringwald 105cd56fb44SMatthias Ringwaldbuild-asan/mesh_pts: mesh_pts.h ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${GATT_SERVER_OBJ_ASAN} ${SM_OBJ_ASAN} ${MESH_OBJ_ASAN} build-asan/main.o build-asan/mesh_pts.o 106cd56fb44SMatthias Ringwald ${CC} $(filter-out mesh_pts.h,$^) ${LDFLAGS_ASAN} -o $@ 107cd56fb44SMatthias Ringwald 108cd56fb44SMatthias Ringwaldbuild-asan/provisioner: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${SM_OBJ_ASAN} build-asan/main.o build-asan/pb_adv.o build-asan/mesh_crypto.o build-asan/provisioning_provisioner.o build-asan/mesh_keys.o build-asan/mesh_foundation.o build-asan/mesh_network.o build-asan/provisioner.o 109cd56fb44SMatthias Ringwald ${CC} $^ ${LDFLAGS_ASAN} -o $@ 110cd56fb44SMatthias Ringwald 111cd56fb44SMatthias Ringwaldbuild-asan/sniffer: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${SM_OBJ_ASAN} build-asan/main.o build-asan/mesh_keys.o build-asan/mesh_network.o build-asan/mesh_foundation.o build-asan/sniffer.o 112cd56fb44SMatthias Ringwald ${CC} $^ ${LDFLAGS_ASAN} -o $@ 113cd56fb44SMatthias Ringwald 114cd56fb44SMatthias Ringwald 115cd56fb44SMatthias Ringwaldbuild-asan/mesh_message_test: $(addprefix build-asan/, mesh_message_test.o mesh_foundation.o mesh_node.o mesh_iv_index_seq_number.o mesh_network.o mesh_peer.o mesh_lower_transport.o mesh_upper_transport.o mesh_virtual_addresses.o mesh_keys.o mesh_crypto.o btstack_memory.o btstack_memory_pool.o btstack_util.o btstack_crypto.o btstack_linked_list.o hci_dump.o uECC.o mock.o rijndael.o hci_cmd.o) | build-asan 116cd56fb44SMatthias Ringwald g++ $^ ${CFLAGS} ${LDFLAGS_ASAN} -o $@ 117cd56fb44SMatthias Ringwald 118cd56fb44SMatthias Ringwaldbuild-asan/provisioning_device_test: $(addprefix build-asan/, provisioning_device_test.o uECC.o mesh_crypto.o provisioning_device.o btstack_crypto.o btstack_util.o btstack_linked_list.o mesh_node.o mock.o rijndael.o hci_cmd.o hci_dump.o) | build-asan 119cd56fb44SMatthias Ringwald ${CC_UNIT} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@ 120cd56fb44SMatthias Ringwald 121cd56fb44SMatthias Ringwaldbuild-asan/provisioning_provisioner_test: $(addprefix build-asan/, provisioning_provisioner_test.o uECC.o mesh_crypto.o provisioning_provisioner.o btstack_crypto.o btstack_util.o btstack_linked_list.o mock.o rijndael.o hci_cmd.o hci_dump.o) | build-asan 122cd56fb44SMatthias Ringwald ${CC_UNIT} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@ 123cd56fb44SMatthias Ringwald 124cd56fb44SMatthias Ringwaldbuild-asan/mesh_configuration_composition_data_message_test: ${CORE_OBJ_ASAN} ${COMMON_OBJ_ASAN} ${ATT_OBJ_ASAN} ${MESH_OBJ_ASAN} build-asan/mesh_configuration_composition_data_message_test.o | build-asan 125cd56fb44SMatthias Ringwald ${CC_UNIT} ${LDFLAGS_ASAN} $^ -lCppUTest -lCppUTestExt -o $@ 126cd56fb44SMatthias Ringwald 1273d87570fSMatthias Ringwald 1283d87570fSMatthias Ringwaldtest: tests 129c9fe0d9fSMatthias Ringwald # Ignore leaks in mesh message test as tests stop before all PDUs are fully processed 130cd56fb44SMatthias Ringwald ASAN_OPTIONS=detect_leaks=0 build-asan/mesh_message_test 131cd56fb44SMatthias Ringwald build-asan/provisioning_device_test 132cd56fb44SMatthias Ringwald build-asan/provisioning_provisioner_test 133cd56fb44SMatthias Ringwald build-asan/mesh_configuration_composition_data_message_test 1343d87570fSMatthias Ringwald 1353d87570fSMatthias Ringwaldcoverage: tests 136cd56fb44SMatthias Ringwald rm -f build-coverage/*.gcda 137cd56fb44SMatthias Ringwald @echo "no coverage here" 138d491c1eaSMatthias Ringwald 139777f7d8dSMilanka Ringwaldclean: 140cd56fb44SMatthias Ringwald rm -rf build-coverage build-asan 141