#! /usr/bin/make -f

include /usr/share/dpkg/default.mk

VERSION := $(shell LC_ALL=C dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
SHIM_VERSION := $(shell dpkg-query -f '$${Version}\n' -W shim)
export SHIM_VERSION

ifeq ($(DEB_TARGET_ARCH),amd64)
export EFI_ARCH := X64
endif
ifeq ($(DEB_TARGET_ARCH),arm64)
export EFI_ARCH := AA64
endif
export EFI_ARCH_LOWER := $(shell echo $(EFI_ARCH) | tr A-Z a-z)
export SHIM_BASE = shim$(EFI_ARCH_LOWER).efi
export FB_BASE = fb$(EFI_ARCH_LOWER).efi
export MM_BASE = mm$(EFI_ARCH_LOWER).efi

%:
	dh $@

docdir := debian/shim-signed/usr/share/doc/shim-signed

override_dh_installchangelogs:
	dh_installchangelogs
	# Quieten lintian, which otherwise gets confused by our odd version
	# number.
	ln $(docdir)/changelog $(docdir)/changelog.Debian

override_dh_gencontrol:
	dh_gencontrol -- -v$(VERSION)+$(SHIM_VERSION) \
		-Vshim:Version=$(SHIM_VERSION)
