# Template file for 'LimeSuite'
pkgname=LimeSuite
version=22.09.1
revision=1
build_style=cmake
build_helper=cmake-wxWidgets-gtk3
configure_args="
 -DENABLE_SIMD_FLAGS=none
 -DENABLE_UTILITIES=True
 -DENABLE_LIME_UTIL=True
 -DCMAKE_SKIP_RPATH=True
 -DENABLE_DESKTOP=False
 -DENABLE_SOAPY_LMS7=True
 -DENABLE_PCIE_XILLYBUS=True
 -DENABLE_QUICKTEST=True
 -DENABLE_MCU_TESTBENCH=True
 -DENABLE_FTDI=True
 -DENABLE_FX3=True
 -DENABLE_STREAM_UNITE=True
 -DENABLE_EXAMPLES=True
 -DENABLE_HEADERS=True
 -DENABLE_GUI=True
 -DENABLE_API_DOXYGEN=True
 $(vopt_bool octave ENABLE_OCTAVE)
 -DLIME_SUITE_EXTVER=${version}_${revision}"
hostmakedepends="doxygen"
makedepends="gnuplot wxWidgets-gtk3-devel libusb-devel SoapySDR-devel libfreeglut-devel
 fltk-devel glew-devel sqlite-devel libgomp-devel $(vopt_if octave octave)"
depends="wget"
short_desc="Driver and GUI for LimeSDR/LMS7002M-based SDR platforms"
maintainer="classabbyamp <void@placeviolette.net>"
license="Apache-2.0"
homepage="https://myriadrf.org/projects/lime-suite/"
changelog="https://raw.githubusercontent.com/myriadrf/LimeSuite/master/Changelog.txt"
distfiles="https://github.com/myriadrf/LimeSuite/archive/refs/tags/v${version}.tar.gz"
checksum=a90e112004bcf2b3eec1ab80321bc345824aaceff00e31ca5e2b8e8ac35ecd26
shlib_provides="libLimeSuite.so.22.09-1"

build_options="octave"
desc_option_octave="Enable the LimeSuite Octave plugin"

# Octave is not built on arm, so don't enable the build option by default on those archs
case "$XBPS_TARGET_MACHINE" in
	arm*|aarch64*) build_options_default="" ;;
	*) build_options_default="octave" ;;
esac

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

post_install() {
	vinstall udev-rules/64-limesuite.rules 644 usr/lib/udev/rules.d

	for res in 16 22 32 48 64 128; do
		_icon_dir="usr/share/icons/hicolor/${res}x${res}/apps"
		vmkdir $_icon_dir
		vinstall Desktop/lime-suite-$res.png 644 $_icon_dir lime-suite.png
	done
	vinstall Desktop/lime-suite.desktop 755 usr/share/applications
}

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

LimeSuite-doc_package() {
	short_desc+=" - documentation"
	pkg_install() {
		vdoc docs/lms7_api_quick_start_guide.pdf
		vdoc docs/StreamProtocol.pdf
		vcopy docs/LMS_API_Documentation usr/share/doc/$pkgname
	}
}

SoapyLMS7_package() {
	short_desc="SoapySDR module for LimeSDR/LMS7002M"
	pkg_install() {
		vmove usr/lib/SoapySDR
	}
}
