# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=nftables
pkgver=0.8.3
pkgrel=0
pkgdesc="Netfilter tables userspace tools"
url="http://netfilter.org/projects/nftables"
arch="all"
license="GPL-2.0-or-later"
makedepends="libmnl-dev libnftnl-dev gmp-dev readline-dev
	ncurses-dev bison flex docbook2x"
subpackages="$pkgname-doc"
source="http://netfilter.org/projects/$pkgname/files/$pkgname-$pkgver.tar.bz2
	nftables.confd
	nftables.initd"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare
	sed -i '1i#include "config.h"' "$builddir"/src/proto.c
}

build() {
	cd "$builddir"

	CONFIG_MAN=y DB2MAN=docbook2x-man ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var
	make
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="d3d97be10c2dcd1f15b9998e01254ff11438a2d83922e8b5207b641375ea12bb86ecbe4f9cb21cdf5998ddeb7c42b9e424dcb40a359cf42e06b9437a5ce4f72c  nftables-0.8.3.tar.bz2
f709e203d949380dce8ffdaed616c047280d3fe7448bb024a6f6c01a17c11bf7caaa5f67b412bc90c9bff4ce91a6fd5e5270d259dc30fdcda81dd2f6221ad0d8  nftables.confd
40a91ef2cff9a8fd5b88888fc601cfbdf30ab0d16bb37997ebee53b7b528de7adc26eca1adfd885fa5b17cc7abf7d4fd30a40385002042d6796aea9c820c3bc6  nftables.initd"
