# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Mirco Tischler <mt-ml at gmx dot de>
# Contributor: Keshav Amburay <(the ddoott ridikulus ddoott rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>

pkgname="efitools"
pkgver=1.9.2
pkgrel=1
pkgdesc="Tools for manipulating UEFI secure boot platforms"
url="http://git.kernel.org/cgit/linux/kernel/git/jejb/efitools.git"
arch=('x86_64')
replaces=('prebootloader')
license=('GPL' 'LGPL2.1')
options=('!strip' '!makeflags')
makedepends=('gnu-efi-libs' 'help2man' 'sbsigntools' 'perl-file-slurp' 'git')
depends=('openssl')
_commit=392836a46ce3c92b55dc88a1aebbcfdfc5dcddce # master
source=("git+https://git.kernel.org/pub/scm/linux/kernel/git/jejb/$pkgname.git#commit=$_commit")
md5sums=('SKIP')

pkgver() {
	cd "${pkgname}"
	echo "$(git describe --tags)" | sed -e 's|-|\.|g' -e 's|^v||g'
}

prepare() {
	cd "${pkgname}"
	git clean -x -d -f
	sed -i "s/-O2/${CFLAGS} -Wno-pointer-sign/" Make.rules
}

build() {
	cd "${pkgname}"
	# fix PreLoader.efi building on x86_64 #49314
	export ARCH="${CARCH}"
	make
}

package() {
	# http://www.rodsbooks.com/efi-bootloaders/secureboot.html#prebootloader
	# http://blog.hansenpartnership.com/uefi-secure-boot/
	# http://blog.hansenpartnership.com/linux-foundation-secure-boot-system-released
	cd "${pkgname}"
	make DESTDIR="${pkgdir}" install
}
