# Contributor: Kaarle Ritvanen <kunkku@alpinelinux.org>
# Maintainer: Kaarle Ritvanen <kunkku@alpinelinux.org>
pkgname=captagent
pkgver=6.4.1
pkgrel=1
pkgdesc="HEP Capture Agent for HOMER"
url="https://github.com/sipcapture/captagent"
arch="all"
license="GPL-3.0-or-later"
makedepends="autoconf automake bison expat-dev flex flex-dev json-c-dev
	libgcrypt-dev libpcap-dev libtool libuv-dev linux-headers openssl-dev>3
	pcre-dev"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/sipcapture/captagent/archive/$pkgver.tar.gz
	$pkgname.initd
	autoconf-2.71.patch
	"

prepare() {
	default_prepare
	./build.sh
}

build() {
	CFLAGS="$CFLAGS -fcommon" \
	LEXLIB="-lfl" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc
	make
}

check() {
	./src/captagent -v
}

package() {
	make install DESTDIR="$pkgdir"
	rm "$pkgdir"/usr/lib/$pkgname/modules/*.a

	install -Dm775 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
}

sha512sums="
6e8331aaa150aa435e0b4863535651268f9600eb4958ac56e9879eeca4480db73e4c184efe445bcd0b102ca62afe06993fb9d3ed04bc5b2ee0d43dcd4fecd85f  captagent-6.4.1.tar.gz
fdd3de15ffd46c5fe08e94533628809373f0afd64c249d308ff4cd649ffa249ff0412c83668f882db71a1bd23879e27528b6ee4a1abccf09b545b92aea4ab646  captagent.initd
29840ca17118efde6e9c99a1f9c509112b384c13d490fe85fdb5fa3bfec6fe588de8efabb2be2f20350bd2028a9fc54cdf20d6263d7abb6916d0578b9960d7d6  autoconf-2.71.patch
"
