#!/usr/bin/make -f

# 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 -fno-omit-frame-pointer
# package maintainers to append LDFLAGS
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

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

ifneq (,$(findstring arm64,$(DEB_TARGET_ARCH)))
	CONFIG_TESTS=disabled
else
	CONFIG_TESTS=enabled
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-Dkeyfile_default=/usr/share/dns/root.key \
		-Dinstall_root_keys=disabled \
		-Dmanaged_ta=disabled \
		-Droot_hints=/usr/share/dns/root.hints \
		-Dinstall_kresd_conf=enabled \
		-Dsystemd_files=enabled \
		-Dclient=enabled \
		-Dutils=enabled \
		-Ddoc=enabled \
		-Ddnstap=enabled \
		-Dunit_tests=enabled \
		-Dconfig_tests=$(CONFIG_TESTS) \
		-Dextra_tests=disabled

override_dh_auto_build:
	dh_auto_build -- doc
	dh_auto_build

override_dh_auto_install:
	sed -e's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' <debian/knot-resolver.postinst.in >debian/knot-resolver.postinst
	dh_auto_install

override_dh_installinit:
	dh_installinit -pknot-resolver --name=kresd --no-start

override_dh_missing:
	dh_missing --fail-missing

override_dh_installchangelogs:
	dh_installchangelogs NEWS
