#!/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

# include python modules in main package
export PYKRES_DESTDIR=debian/knot-resolver6/

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


%:
	dh $@ --with python3 --buildsystem=meson

override_dh_auto_configure:
	dh_auto_configure -- \
		--buildtype=plain \
		--prefix=/usr \
		--libdir=lib \
		-Dinstall_root_keys=disabled \
		-Dsystemd_files=enabled \
		-Ddnstap=enabled \
		-Dkeyfile_default=/usr/share/dns/root.key \
		-Droot_hints=/usr/share/dns/root.hints \
		-Dmalloc=jemalloc

override_dh_auto_build:
	# disabled due to missing python3-json-schema-for-humans
	#dh_auto_build -- doc
	dh_auto_build
	PYBUILD_NAME=knot_resolver PYBUILD_DESTDIR="$${PYKRES_DESTDIR}" \
		dh_auto_build --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	PYBUILD_NAME=knot_resolver PYBUILD_DESTDIR="$${PYKRES_DESTDIR}" \
		dh_auto_install --buildsystem=pybuild
	install -m 644 -D etc/config/config.yaml debian/tmp/etc/knot-resolver/config.yaml

override_dh_auto_clean:
	rm -rf .pybuild/
	rm -rf build/
	rm -rf python/knot_resolver.egg-info
	dh_auto_clean
