# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Keshav Amburay <(the ddoott ridikulus ddoott rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
# Contributor: Alessio 'mOLOk' Bolognino <themolok@gmail.com>

[[ "${CARCH}" == "x86_64" ]] && _EFI_ARCH="x86_64"
[[ "${CARCH}" == "i686" ]] && _EFI_ARCH="ia32"

_pkgver="3.0"
pkgname="gnu-efi-libs"
pkgver="${_pkgver}v"
pkgrel="2"
pkgdesc="Library for building UEFI Applications using GNU toolchain"
url="http://sourceforge.net/projects/gnu-efi/"
license=('GPL')
arch=('x86_64' 'i686')
options=('!strip' '!makeflags' 'staticlibs')
makedepends=('pciutils')

source=("http://download.sourceforge.net/gnu-efi/gnu-efi_${pkgver}.orig.tar.gz"
        'gnu-efi-3.0v-revert-makefile-commit.patch')

prepare() {
	cd "${srcdir}/gnu-efi-${_pkgver}/"
	patch -Np1 -R -i "${srcdir}/gnu-efi-3.0v-revert-makefile-commit.patch"
}

build() {
	
	cd "${srcdir}/gnu-efi-${_pkgver}/"
	
	## Unset all compiler FLAGS
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS
	
	make -j1
	make -j1 -C apps all
	
}

package() {
	
	cd "${srcdir}/gnu-efi-${_pkgver}/"
	
	make INSTALLROOT="${pkgdir}" PREFIX="/usr" LIBDIR="/usr/lib" install
	
	install -d "${pkgdir}/usr/share/gnu-efi/apps/${_EFI_ARCH}/"
	install -D -m0644 "${srcdir}/gnu-efi-${_pkgver}/apps"/*.efi "${pkgdir}/usr/share/gnu-efi/apps/${_EFI_ARCH}/"
	
}

md5sums=('57f0a308c0e939e5d18e40840a5484a9'
         '97ef85cd3d4aba2349aa1fab706568ab')
