# Template file for 'efibootmgr'
pkgname=efibootmgr
version=18
revision=1
hostmakedepends="pkg-config"
makedepends="libefivar-devel popt-devel"
short_desc="Tool to modify UEFI Firmware Boot Manager Variables"
maintainer="André Cerqueira <acerqueira021@gmail.com>"
license="GPL-2.0-or-later"
homepage="https://github.com/rhboot/efibootmgr"
distfiles="https://github.com/rhboot/efibootmgr/archive/${version}.tar.gz"
checksum=442867d12f8525034a404fc8af3036dba8e1fc970998af2486c3b940dfad0874

conf_files="/etc/default/efibootmgr-kernel-hook"

case "$XBPS_TARGET_MACHINE" in
	x86_64*)
		EFI_LOADER="grubx64.efi" ;;
	i686*)
		EFI_LOADER="grub.efi" ;;
	aarch64*)
		EFI_LOADER="grubaa64.efi" ;;
	arm*)
		EFI_LOADER="grubarm.efi" ;;
	*)
		broken="unsupported UEFI for architecture ${XBPS_TARGET_MACHINE}" ;;
esac

do_configure() {
	sed -i 's/-Werror //' Make.defaults
}

do_build() {
	make EXTRA_CFLAGS="$CFLAGS" ${makejobs} EFIDIR="void" EFI_LOADER="${EFI_LOADER}"
}

do_install() {
	vbin src/efibootdump
	vman src/efibootdump.8
	vbin src/efibootmgr
	vman src/efibootmgr.8
}

post_install() {
	vdoc ${FILESDIR}/README.voidlinux
	vmkdir etc/
	vinstall "${FILESDIR}/efibootmgr-kernel-hook.confd" 644 etc/default efibootmgr-kernel-hook
	vinstall ${FILESDIR}/kernel.d/efibootmgr.post-install 744 \
		etc/kernel.d/post-install 50-efibootmgr
	vinstall ${FILESDIR}/kernel.d/efibootmgr.post-remove 744 \
		etc/kernel.d/post-remove 50-efibootmgr
}
