# Template file for 'readsb'
pkgname=readsb
version=3.16.15
revision=1
build_style=gnu-makefile
build_helper="qemu"
make_use_env=yes
make_build_args="
 RTLSDR=yes
 BLADERF=no
 HACKRF=yes
 PLUTOSDR=no
 SOAPYSDR=yes
 HISTORY=yes"
hostmakedepends="pkg-config help2man"
makedepends="SoapySDR-devel libhackrf-devel librtlsdr-devel libusb-devel
 libzstd-devel ncurses-devel zlib-devel"
short_desc="ADS-B decoder swiss knife"
maintainer="Duncaen <duncaen@voidlinux.org>"
license="GPL-3.0-or-later AND BSD-2-Clause"
homepage="https://github.com/wiedehopf/readsb"
distfiles="https://github.com/wiedehopf/readsb/archive/refs/tags/v${version}.tar.gz"
checksum=7a8c3886c6c548578e9a65f7b45a993bcd49aa52f70d5bffe1e76b4cbca9998f

system_accounts="_readsb"
_readsb_groups="plugdev"

conf_files="/etc/default/readsb"

post_patch() {
	vsed -e 's/\bgit\b/false/g' -e 's/\bncurses\b/ncursesw/g' -i Makefile
	vsed -e 's/User=readsb/User=_readsb/' -i debian/readsb.service
}

do_install() {
	vbin readsb
	vbin viewadsb
	if [ "$CROSS_BUILD" ]; then
		help2man -N --no-discard-stderr -- "/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE} ./readsb" >readsb.1
		help2man -N --no-discard-stderr -- "/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE} ./viewadsb" >viewadsb.1
	else
		help2man -N --no-discard-stderr -- ./readsb >readsb.1
		help2man -N --no-discard-stderr -- ./viewadsb >viewadsb.1
	fi
	vman readsb.1
	vman viewadsb.1
	vinstall debian/readsb.service 644 usr/lib/systemd/system
	vinstall debian/readsb.default 644 etc/default readsb
	vsv readsb
	vlicense LICENSE
}
