# Template file for 'gnuradio'
pkgname=gnuradio
version=3.10.5.1
revision=1
build_style=cmake
conf_files="/etc/gnuradio/conf.d/*"
configure_args="-DMATHJAX2_USE_ROOT=/usr/share/mathjax
 -DZEROMQ_INCLUDE_DIRS=${XBPS_CROSS_BASE}/usr/include
 -Dpybind11_DIR=${XBPS_CROSS_BASE}/${py3_sitelib}/pybind11/share/cmake/pybind11"
_pydeps="python3-Mako python3-cairo python3-click python3-click-plugins python3-gobject
 python3-jsonschema python3-numpy python3-pyqtgraph python3-pyzmq python3-scipy python3-yaml"
hostmakedepends="pkg-config doxygen mathjax2 python3-Sphinx python3-pygccxml
 qt5-host-tools qt5-qmake ${_pydeps}"
makedepends="SDL-devel SoapySDR-devel boost-devel codec2-devel cppzmq fftw-devel gmpxx-devel
 gsl-devel gtk+3-devel jack-devel libgsm-devel libiio-devel libsndfile-devel
 python3-devel python3-gobject-devel python3-pybind11 python3-pygccxml qwt-devel spdlog
 fmt-devel uhd-devel volk-devel"
depends="${_pydeps} python3-cheetah3 python3-lxml python3-matplotlib"
checkdepends="python3-pytest"
short_desc="Framework for software defined radio"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-3.0-or-later"
homepage="https://www.gnuradio.org"
distfiles="https://github.com/gnuradio/gnuradio/archive/v${version}.tar.gz"
checksum=85d90147f7f28450bff75eeefd2b44adc88b231d29fe8e86cc3a65437dba6d9f
python_version=3

if [ "$CROSS_BUILD" ]; then
	# CMake fails when cross-compiling.
	configure_args+=" -DENABLE_TESTING=OFF"
fi

if [ "${XBPS_TARGET_MACHINE%-musl}" = "i686" ]; then
	make_check=ci-skip  # See https://github.com/gnuradio/gnuradio/issues/5973
fi

if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
	makedepends+=" libatomic-devel"
	configure_args+=" -DCMAKE_CXX_STANDARD_LIBRARIES=-latomic"
fi

post_install() {
	rm ${DESTDIR}/usr/share/gnuradio/examples/audio/dial_tone \
		${DESTDIR}/usr/share/gnuradio/examples/qt-gui/display_qt \
		${DESTDIR}/usr/share/gnuradio/examples/uhd/tags_demo
	vinstall grc/scripts/freedesktop/gnuradio-grc.desktop 644 \
		usr/share/applications
	vinstall grc/scripts/freedesktop/gnuradio_logo_icon-square.svg 644 \
		usr/share/pixmaps gnuradio-grc.svg
}

gnuradio-doc_package() {
	short_desc+=" - documentation"
	depends="mathjax2"
	pkg_install() {
		vmove usr/share/doc
	}
}

gnuradio-devel_package() {
	short_desc+=" - development files"
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/include
		vmove "usr/lib/*.so"
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
	}
}
