From 29f6e663e06a79c630aee0392d9aeb3768c8ae2c Mon Sep 17 00:00:00 2001 From: Yasmin Bosch Date: Sun, 17 Mar 2024 16:23:10 +0100 Subject: [PATCH] ports/unix/Makefile: Move up "HAVE_LIBUSB" code to be effective. There is a code that evaluates "HAVE_LIBUSB" and then sets "MICROPY_BLUETOOTH_BTSTACK_USB" and "MICROPY_BLUETOOTH_BTSTACK_H4" accordingly. That code has been moved before "include $(TOP)/extmod/extmod.mk" to be effective. Details: "include $(TOP)/extmod/extmod.mk" will "include $(TOP)/extmod/btstack/btstack.mk" and that in turn sets "MICROPY_BLUETOOTH_BTSTACK_USB ?= 0" "MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1" Signed-off-by: Yasmin Bosch --- ports/unix/Makefile | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index d5bd6d4098..3687755bfd 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -33,6 +33,25 @@ QSTR_GLOBAL_DEPENDENCIES += $(VARIANT_DIR)/mpconfigvariant.h # OS name, for simple autoconfig UNAME_S := $(shell uname -s) +# If the variant enables it, enable modbluetooth. +ifeq ($(MICROPY_PY_BLUETOOTH),1) +ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) +HAVE_LIBUSB := $(shell (which pkg-config > /dev/null && pkg-config --exists libusb-1.0) 2>/dev/null && echo '1') + +# Figure out which BTstack transport to use. +ifeq ($(HAVE_LIBUSB),1) +# Default to btstack-over-usb. +MICROPY_BLUETOOTH_BTSTACK_USB ?= 1 +MICROPY_BLUETOOTH_BTSTACK_H4 ?= 0 +else +# Fallback to HCI controller via a H4 UART (e.g. Zephyr on nRF) over a /dev/tty serial port. +MICROPY_BLUETOOTH_BTSTACK_USB ?= 0 +MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1 +endif + +endif +endif + # include py core make definitions include $(TOP)/py/py.mk include $(TOP)/extmod/extmod.mk @@ -144,20 +163,8 @@ ifeq ($(MICROPY_SSL_AXTLS),1) endif endif -# If the variant enables it, enable modbluetooth. ifeq ($(MICROPY_PY_BLUETOOTH),1) ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) -HAVE_LIBUSB := $(shell (which pkg-config > /dev/null && pkg-config --exists libusb-1.0) 2>/dev/null && echo '1') - -# Figure out which BTstack transport to use. -ifeq ($(HAVE_LIBUSB),1) -# Default to btstack-over-usb. -MICROPY_BLUETOOTH_BTSTACK_USB ?= 1 -else -# Fallback to HCI controller via a H4 UART (e.g. Zephyr on nRF) over a /dev/tty serial port. -MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1 -endif - SRC_BTSTACK_C += lib/btstack/platform/embedded/btstack_run_loop_embedded.c endif endif