#!/usr/bin/make -f

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

DEB_BUILD_MAINT_OPTIONS = hardening=+all
DEB_CFLAGS_MAINT_APPEND = -Wall -Wextra
DEB_CPPFLAGS_MAINT_APPEND = -D_XOPEN_SOURCE=600
DPKG_EXPORT_BUILDFLAGS = 1
-include /usr/share/dpkg/buildflags.mk

%:
	dh $@ --with=autoreconf --with=systemd

override_dh_auto_configure:
	dh_auto_configure -- \
	       --with-configdir=/etc/nsd		\
	       --with-nsd_conf_file=/etc/nsd/nsd.conf	\
	       --with-pidfile=/run/nsd/nsd.pid		\
	       --with-dbfile=/var/lib/nsd/nsd.db	\
	       --with-zonesdir=/etc/nsd			\
	       --with-difffile=/var/lib/nsd/ixfr.db	\
	       --with-xfrdfile=/var/lib/nsd/xfrd.state	\
	       --with-max-ips=1024			\
	       --disable-largefile			\
	       --disable-recvmmsg			\
	       --enable-root-server			\
	       --enable-mmap				\
	       --enable-ratelimit

override_dh_auto_clean:
	dh_auto_clean

override_dh_auto_install:
	dh_auto_install -- DESTDIR=$(CURDIR)/debian/nsd
	rmdir $(CURDIR)/debian/nsd/run/nsd
	rmdir $(CURDIR)/debian/nsd/run
	mv $(CURDIR)/debian/nsd/etc/nsd/nsd.conf.sample $(CURDIR)/debian/nsd/usr/share/doc/nsd/examples/nsd.conf
	install -m 640 debian/nsd.conf $(CURDIR)/debian/nsd/etc/nsd/

override_dh_installchangelogs:
	dh_installchangelogs doc/ChangeLog

override_dh_compress:
	dh_compress -X/usr/share/doc/nsd/examples/nsd.conf
