# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=hackrf
pkgver=2023.01.1
pkgrel=1
pkgdesc="Driver for HackRF, allowing general purpose software defined radio"
url="https://github.com/greatscottgadgets/hackrf"
arch="all"
license="GPL-2.0-only"
options="!check"  # no test suite
makedepends="
	cmake
	fftw-dev
	libusb-dev
	ninja
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	$pkgname-firmware:firmware:noarch
	$pkgname-libs
	"
source="$pkgname-$pkgver.tar.xz::https://github.com/greatscottgadgets/hackrf/releases/download/v$pkgver/hackrf-$pkgver.tar.xz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DUDEV_RULES_PATH=/usr/lib/udev/rules.d \
		host
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

firmware() {
	pkgdesc="$pkgdesc (firmware)"

	find "$builddir/firmware-bin" -type f -exec install -Dm644 -t "$subpkgdir/usr/share/hackrf/" {} \;
}

sha512sums="
7c2ef9c5c050e258a0d1695240f9163955cb3ea9ab9163aad6bdbdebfdb82cde9925818ced3323342fe9c4ddb80dcedbc5a7986caaa4e0b7036e8e07bec0296e  hackrf-2023.01.1.tar.xz
"
