#! /usr/bin/make -f
%:
	dh $@

DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
CROSS :=
else
CROSS := CC=$(DEB_HOST_GNU_TYPE)-gcc STRIP=$(DEB_HOST_GNU_TYPE)-strip
endif

override_dh_auto_build:
	# Don't try to sync the mirror masterlist during the build:
	$(MAKE) small $(CROSS) ONLINE=n

override_dh_auto_clean:
	rm -rf debian/locales debian/sort-tmp
	$(MAKE) clean check-masterlist

override_dh_installdebconf:
	dh_installdebconf
	# Sort mirror countries (including translations)
	# MUST be after dh_installdebconf
	./sort-templates
	# Make sure templates are not obviously broken (#834383):
	[ ! -d debian/choose-mirror-bin/DEBIAN ] || grep -qs '^Template:' debian/choose-mirror-bin/DEBIAN/templates
