#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk

ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
export CC=$(DEB_HOST_GNU_TYPE)-gcc
export PKG_CONFIG=$(DEB_HOST_GNU_TYPE)-pkg-config
endif

%:
	dh $@ --with bash-completion

override_dh_install:
	install -d debian/initramfs-tools-core/usr/sbin
	sed -e 's,@VERSION@,$(DEB_VERSION),' mkinitramfs > debian/initramfs-tools-core/usr/sbin/mkinitramfs
	chmod 755 debian/initramfs-tools-core/usr/sbin/mkinitramfs
	dh_install

override_dh_installinitramfs:
	@:

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
    ifeq (,$(filter i386,$(DEB_HOST_ARCH)))
	shellcheck hook-functions $$(find hooks scripts -type f) $$({ find . -maxdepth 1 -type f -executable; find debian -maxdepth 1 -type f; find debian/tests docs kernel tests -type f; } | xargs grep -l '^#!/bin/sh')
    endif
	tests/functions_test
endif
