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


export DEB_BUILD_MAINT_OPTIONS := qa=+bug hardening=+all reproducible=+all


%:
	dh $@ --without single-binary


override_dh_auto_configure:
	dh_auto_configure -- --auto-features=enabled \
	                     -Ddocs=$(if $(filter nodoc,$(DEB_BUILD_OPTIONS) $(DEB_BUILD_PROFILES)),disabled,enabled) \
	                     -Dwerror=false \
	                     $(empty)

# The tests are all interactive and/or require root privileges
override_dh_auto_test:

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

override_dh_installchangelogs:
	dh_installchangelogs NEWS

# dh_installsystemd does not enable template units, so build maintscripts
# manually from autoscripts.
# deb-systemd-helper will honor WantedBy=getty.target by running
# systemctl preset on first install, but it will not register it in its
# own database. This will be fixed once the patch for #801822 lands.
override_dh_installsystemd:
	printf '#!/bin/sh\nset -e\n\n#DEBHELPER#\n\n' | tee debian/kmscon.postinst debian/kmscon.postrm > /dev/null
	sed 's/#UNITFILE#/kmsconvt@.service/g' /usr/share/debhelper/autoscripts/postinst-systemd-enable >> debian/kmscon.postinst
	sed 's/#UNITFILES#/kmsconvt@.service/g' /usr/share/debhelper/autoscripts/postrm-systemd >> debian/kmscon.postrm
	cat /usr/share/debhelper/autoscripts/postrm-systemd-reload-only >> debian/kmscon.postrm

override_dh_gencontrol:
	dh_gencontrol -- -Vunifont:Version=$$(dpkg-query --showformat='$${Version}' --show unifont)
