# Contributor: George Hopkins <george-hopkins@null.net>
# Maintainer: George Hopkins <george-hopkins@null.net>
pkgname=kismet
_pkgver=2023-07-R1
pkgver=${_pkgver/-R/.}
pkgver=0.${pkgver/-/}
pkgrel=7
pkgdesc="Wireless network and device detector"
url="https://www.kismetwireless.net/"
arch="all"
license="GPL-2.0-only"
makedepends="
	abseil-cpp-dev
	libnl3-dev
	libpcap-dev
	linux-headers
	openssl-dev
	pcre2-dev
	protobuf-c-dev
	protobuf-dev
	sqlite-dev
	zlib-dev
	"
subpackages="$pkgname-logtools
	$pkgname-linux-bluetooth:linux_bluetooth
	$pkgname-linux-wifi:linux_wifi
	$pkgname-nrf-51822:nrf_51822
	$pkgname-nxp-kw41z:nxp_kw41z
	"
options="!check" # no test-suite available
source="$pkgname-$pkgver.tar.xz::https://www.kismetwireless.net/code/kismet-$_pkgver.tar.xz"
builddir="$srcdir/kismet-$_pkgver"

prepare() {
	default_prepare
	update_config_sub
	sed -i "s/@VERSION@/$pkgver/" packaging/kismet.pc.in
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/kismet \
		--disable-libusb \
		--disable-libwebsockets \
		--disable-python-tools \
		--disable-wifi-coconut
	make -j $((JOBS < 16 ? JOBS : 16))
}

package() {
	make DESTDIR="$pkgdir" install
	rm "$pkgdir"/usr/bin/kismet_discovery # example
}

logtools() {
	pkgdesc="$pkgdesc - log tools"

	amove usr/bin/kismetdb_*
}

linux_bluetooth() {
	pkgdesc="$pkgdesc - Bluetooth capture support"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/kismet_cap_linux_bluetooth
}

linux_wifi() {
	pkgdesc="$pkgdesc - Wi-Fi capture support"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/kismet_cap_linux_wifi
}

nrf_51822() {
	pkgdesc="$pkgdesc - nRF51822 capture support"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/kismet_cap_nrf_51822
}

nxp_kw41z() {
	pkgdesc="$pkgdesc - NXP KW41Z capture support"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/kismet_cap_nxp_kw41z
}

sha512sums="
b8b320b8e09be5be582848ce8a1a66f71a96eccc3c78f52d3f1f18122abbe614ff3b5a55b5fcedf3e6a1fc959a72838adc0d7278ffd6c25a1c179a1caf5584ce  kismet-0.202307.1.tar.xz
"
