# Contributor: <xmingske@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=dnssec-tools
pkgver=2.2
pkgrel=0
pkgdesc="Set of tools that will help ease the deployment of DNSSEC"
url="https://www.dnssec-tools.org/"
arch="all"
license="GPL-3.0"
makedepends="autoconf automake bind-dev libtool libressl-dev perl-graphviz perl-crypt-openssl-random
	     perl-net-dns perl-net-dns-sec perl-xml-simple perl-dev sed chrpath"
source="http://dev.alpinelinux.org/archive/dnssec-tools/dnssec-tools-$pkgver.tar.gz"
subpackages="$pkgname-dev $pkgname-doc"

builddir="${srcdir}/${pkgname}-${pkgver}"

prepare() {
	local pf
	cd "$builddir"
	update_config_guess
	default_prepare
	sed -e '/^maninstall:/,+3s:$(MKPATH) $(mandir)/$(man1dir):$(MKPATH) $(DESTDIR)/$(mandir)/$(man1dir):' \
		-i Makefile.in || die
	sed -e 's:/usr/local/etc:/etc:g' \
		-e 's:/usr/local:/usr:g' \
		-i tools/donuts/donuts \
		-i tools/etc/dnssec-tools/dnssec-tools.conf \
		-i tools/scripts/genkrf || die
}

build() {
	cd "$builddir"
	CFLAGS="$CFLAGS -D_LARGEFILE64_SOURCE=1"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-bind-checks \
		--with-validator \
		--with-perl-build-args=INSTALLDIRS=vendor
	make || return 1
}

package() {
	cd "$builddir"
	mkdir -p "$pkgdir"/usr/share/man/man1
	make DESTDIR="$pkgdir" install || return 1
	chrpath -d "$pkgdir"/usr/bin/dt-*
}

sha512sums="5d0d936a2dabc648033cbd74ff6f1b309ae66bf3f2ab1223c8be5879fa4385bfdfd8cee2b4005b0d0e7ed85eeb1b81a9a4092d300fa725d4b19a84bf2619a280  dnssec-tools-2.2.tar.gz"
