kumquat-buildroot/package/gnuradio/gnuradio.mk
Gwenhael Goavec-Merou e22b450692 package/gnuradio: fix gnuradio python libraries for cross-compile
By default, module libraries have a suffix based on cpython version + host
architecture: this is fine for a native compile when these libraries are used on
the same computer (or similar computers). But when target architecture is not
the same python is unable to find libraries due to the wrong suffix and produces
unclear errors messages:

# python3
Python 3.11.3 (main, Jun 19 2023, 14:15:44) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gnuradio import blocks
Traceback (most recent call last):
  File "/home/xxx/buildroot/output/build/gnuradio-3.10.4.0/gr-blocks/python/blocks/__init__.py", line 18, in <module>
ModuleNotFoundError: No module named 'gnuradio.blocks.blocks_python'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxx/buildroot/output/build/gnuradio-3.10.4.0/gr-blocks/python/blocks/__init__.py", line 22, in <module>
ModuleNotFoundError: No module named 'gnuradio.blocks.blocks_python'
>>>

By adding _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" at configure time, sysconfig will
return correct informations (target architecture) instead of host architecture.

Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-07-22 23:14:22 +02:00

171 lines
4.3 KiB
Makefile

################################################################################
#
# gnuradio
#
################################################################################
GNURADIO_VERSION = 3.10.7.0
GNURADIO_SITE = $(call github,gnuradio,gnuradio,v$(GNURADIO_VERSION))
GNURADIO_LICENSE = GPL-3.0+
GNURADIO_LICENSE_FILES = COPYING
GNURADIO_SUPPORTS_IN_SOURCE_BUILD = NO
GNURADIO_DEPENDENCIES = \
host-python3 \
boost \
log4cpp \
gmp \
spdlog \
volk
GNURADIO_CONF_OPTS = \
-DPYTHON_EXECUTABLE=$(HOST_DIR)/bin/python3 \
-DENABLE_DEFAULT=OFF \
-DENABLE_EXAMPLES=OFF \
-DENABLE_GNURADIO_RUNTIME=ON \
-DENABLE_TESTING=OFF \
-DXMLTO_EXECUTABLE=NOTFOUND
# For third-party blocks, the gnuradio libraries are mandatory at
# compile time.
GNURADIO_INSTALL_STAGING = YES
ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
GNURADIO_CONF_OPTS += -DCMAKE_EXE_LINKER_FLAGS=-latomic
endif
ifeq ($(BR2_PACKAGE_GNURADIO_ANALOG),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_ANALOG=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_ANALOG=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_AUDIO),y)
ifeq ($(BR2_PACKAGE_ALSA_LIB),y)
GNURADIO_DEPENDENCIES += alsa-lib
endif
ifeq ($(BR2_PACKAGE_PORTAUDIO),y)
GNURADIO_DEPENDENCIES += portaudio
endif
GNURADIO_CONF_OPTS += -DENABLE_GR_AUDIO=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_AUDIO=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_BLOCKS),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_BLOCKS=ON
ifeq ($(BR2_PACKAGE_LIBSNDFILE),y)
GNURADIO_DEPENDENCIES += libsndfile
endif
else
GNURADIO_CONF_OPTS += -DENABLE_GR_BLOCKS=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_CHANNELS),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_CHANNELS=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_CHANNELS=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_CTRLPORT),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_CTRLPORT=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_CTRLPORT=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_DIGITAL),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_DIGITAL=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_DIGITAL=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_DTV),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_DTV=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_DTV=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_FEC),y)
GNURADIO_DEPENDENCIES += gsl
GNURADIO_CONF_OPTS += -DENABLE_GR_FEC=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_FEC=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_FFT),y)
GNURADIO_DEPENDENCIES += fftw-single
GNURADIO_CONF_OPTS += -DENABLE_GR_FFT=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_FFT=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_FILTER),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_FILTER=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_FILTER=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_NETWORK),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_NETWORK=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_NETWORK=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_PYTHON),y)
GNURADIO_DEPENDENCIES += python3 python-pybind \
host-python-numpy host-python-packaging
GNURADIO_CONF_OPTS += -DENABLE_PYTHON=ON
# mandatory to avoid pybind11 to overwrite variables provided
# by gnuradio and buildroot
GNURADIO_CONF_OPTS += -DPYBIND11_PYTHONLIBS_OVERWRITE=OFF
# mandatory to avoid pybind11 to force libraries extensions
# with a name based on host architecture
GNURADIO_CONF_ENV += _PYTHON_SYSCONFIGDATA_NAME="$(PKG_PYTHON_SYSCONFIGDATA_NAME)" \
PYTHONPATH=$(PYTHON3_PATH)
# mandatory to install python modules in site-packages and to use
# correct path for python libraries
GNURADIO_CONF_OPTS += -DGR_PYTHON_RELATIVE=ON \
-DGR_PYTHON_DIR=lib/python$(PYTHON3_VERSION_MAJOR)/site-packages
else
GNURADIO_CONF_OPTS += -DENABLE_PYTHON=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_QTGUI),y)
GNURADIO_DEPENDENCIES += qt5base python-pyqt5 qwt
GNURADIO_CONF_OPTS += -DENABLE_GR_QTGUI=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_QTGUI=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_TRELLIS),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_TRELLIS=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_TRELLIS=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_UHD),y)
GNURADIO_DEPENDENCIES += uhd
GNURADIO_CONF_OPTS += -DENABLE_GR_UHD=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_UHD=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_UTILS),y)
GNURADIO_CONF_OPTS += -DENABLE_GR_UTILS=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_UTILS=OFF
endif
ifeq ($(BR2_PACKAGE_GNURADIO_ZEROMQ),y)
GNURADIO_DEPENDENCIES += cppzmq
ifeq ($(BR2_PACKAGE_GNURADIO_PYTHON),y)
GNURADIO_DEPENDENCIES += python-pyzmq
endif
GNURADIO_CONF_OPTS += -DENABLE_GR_ZEROMQ=ON
else
GNURADIO_CONF_OPTS += -DENABLE_GR_ZEROMQ=OFF
endif
$(eval $(cmake-package))