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

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

ifeq ($(DEB_HOST_ARCH_OS),linux)
DEFAULT_FS=ext4
endif
ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
DEFAULT_FS=ufs
endif
ifeq ($(DEB_HOST_ARCH_OS),hurd)
DEFAULT_FS=ext2
endif

PROVIDES=made-filesystems, mounted-partitions, partitioned-harddrives, created-fstab

MENUITEMNUM=4200

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
override_dh_auto_build:
	dh_auto_build -- CC=$(DEB_HOST_GNU_TYPE)-gcc
endif

override_dh_installdebconf:
	dh_installdebconf
	sed -i '/^Template: partman\/default_filesystem/,/^$$/s/^Default: .*/Default: $(DEFAULT_FS)/' \
		debian/partman-base/DEBIAN/templates

# TODO: This is a bit gratuitous since all the "variables" are constant
# right now. Do we still need this flexibility?
override_dh_gencontrol:
	dh_gencontrol -- -Vmenuitemnum=$(MENUITEMNUM) -Vprovides='$(PROVIDES)'
