#!/usr/bin/make -f
# SPDX-License-Identifier: GPL-3.0-or-later

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

include /usr/share/dpkg/default.mk

# python payload destination
export PYBUILD_NAME = knot_resolver
export PYBUILD_DESTDIR = $(CURDIR)/debian/knot-resolver6

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

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 \
		-Dunit_tests=enabled \
		-Dmalloc=jemalloc

override_dh_auto_build:
	dh_auto_build
	dh_auto_build --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	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
