# Template file for 'LimeSuite'
pkgname=LimeSuite
version=23.11.0
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=fd8a448b92bc5ee4012f0ba58785f3c7e0a4d342b24e26275318802dfe00eb33
shlib_provides="libLimeSuite.so.${version%.*}-1"

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

# TODO: the cmake build system executes octave-config
# which needs additional care in crossbuilds
if [ -z "$CROSS_BUILD" ]; then
	build_options_default="octave"
fi

CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"

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
	}
}
