#!/usr/bin/make -f

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

# We need to embed debconf_helper.py in the config script because the config
# script can be run before the package is unpacked, so it doesn't have access
# to the installed copy of debconf_helper.py.
debian/%: debian/%.in apt_listchanges/debconf_helper.py debian/rules
	sed -e '/#DEBCONF_HELPER_PY#/ { ' -e 'r apt_listchanges/debconf_helper.py' -ed -e' }' < $< > $@.tmp
	chmod 555 $@.tmp
	mv $@.tmp $@

override_dh_auto_test::
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(MAKE) test
endif

execute_before_dh_auto_build:: debian/config
	$(MAKE) all

execute_after_dh_auto_install::
	$(MAKE) install DESTDIR=$(shell pwd)/debian/apt-listchanges

execute_after_dh_clean::
	rm -f debian/config
	$(MAKE) dh_clean
