#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

ANCHOR=$(shell cat /usr/share/dns/root.ds)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)

%:
	dh $@  --with autotools-dev --with autoreconf

override_dh_auto_clean:
	dh_auto_clean
	-[ -f etc/dnsval.conf.dh ] && mv etc/dnsval.conf.dh etc/dnsval.conf
	rm -f debian/dnsval.conf

override_dh_auto_configure:
	-[ ! -f etc/dnsval.conf.dh ] && mv etc/dnsval.conf etc/dnsval.conf.dh
	sed -e "s/@ANCHOR@/$(ANCHOR)/" \
	  < etc/dnsval.conf.dh \
	  > etc/dnsval.conf
	dh_auto_configure -- \
	  --with-nsec3 \
	  --without-dlv \
	  --with-ipv6 \
	  --with-root-hints=/usr/share/dns/root.hints \
	  --with-resolv-conf=/etc/resolv.conf \
	  --without-inline-confs \
	  --with-cflags="$(CFLAGS)"

override_dh_strip:
	dh_strip --dbg-package=libval-dbg

override_dh_install:
	for bin in debian/tmp/usr/bin/dt-*; do \
	  chrpath -d $$bin; \
	done
	dh_install --list-missing -X.la

override_dh_auto_test:
	echo test would require network - disabled
