#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed


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

# main packaging script based on dh7 syntax
%:
	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 --dbgsym-migration='libval-dbg (<< 2.2-1~)' || dh_strip

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
