sys-boot/gnu-efi: Support building ia32 EFI libs on amd64
authorMike Gilbert <floppym@gentoo.org>
Sun, 6 Sep 2015 02:28:29 +0000 (22:28 -0400)
committerMike Gilbert <floppym@gentoo.org>
Sun, 6 Sep 2015 02:28:40 +0000 (22:28 -0400)
Package-Manager: portage-2.2.20

sys-boot/gnu-efi/gnu-efi-3.0.3.ebuild

index f79b3b2961d5746257157390b242b5981ca31084..9c6a09fcff1d591027c75aed86d2dbd4cfb92111 100644 (file)
@@ -13,7 +13,7 @@ SRC_URI="mirror://sourceforge/gnu-efi/${P}.tar.bz2"
 LICENSE="GPL-2"
 SLOT="0"
 KEYWORDS="-* ~amd64 ~ia64 ~x86"
-IUSE=""
+IUSE="abi_x86_32 abi_x86_64"
 
 DEPEND="sys-apps/pciutils"
 RDEPEND=""
@@ -21,29 +21,48 @@ RDEPEND=""
 # These objects get run early boot (i.e. not inside of Linux),
 # so doing these QA checks on them doesn't make sense.
 QA_EXECSTACK="usr/*/lib*efi.a:* usr/*/crt*.o"
+RESTRICT="strip"
 
-_emake() {
-       emake \
-               prefix=${CHOST}- \
-               ARCH=${iarch} \
-               PREFIX="${EPREFIX}/usr" \
-               LIBDIR='$(PREFIX)/'"$(get_libdir)" \
-               "$@"
+efimake() {
+       local arch=
+       case ${CHOST} in
+               arm*) arch=arm ;;
+               aarch64*) arch=aarch64 ;;
+               ia64*) arch=ia64 ;;
+               i?86*) arch=ia32 ;;
+               x86_64*) arch=x86_64 ;;
+               *) die "Unknown CHOST" ;;
+       esac
+
+       local args=(
+               ARCH="${arch}"
+               HOSTCC="${BUILD_CC}"
+               CC="${CC}"
+               AS="${AS}"
+               LD="${LD}"
+               AR="${AR}"
+               PREFIX="${EPREFIX}/usr"
+               LIBDIR='$(PREFIX)'/$(get_libdir)
+       )
+       emake -j1 "${args[@]}" "$@"
 }
 
 src_compile() {
-       case ${ARCH} in
-               ia64)  iarch=ia64 ;;
-               x86)   iarch=ia32 ;;
-               amd64) iarch=x86_64 ;;
-               *)     die "unknown architecture: $ARCH" ;;
-       esac
-       # The lib subdir uses unsafe archive targets, and
-       # the apps subdir needs gnuefi subdir
-       _emake -j1
+       tc-export BUILD_CC AR AS CC LD
+       if [[ ${CHOST} == x86_64* ]]; then
+               use abi_x86_32 && CHOST=i686 ABI=x86 efimake
+               use abi_x86_64 && efimake
+       else
+               efimake
+       fi
 }
 
 src_install() {
-       _emake install PREFIX=/usr INSTALLROOT="${D}"
+       if [[ ${CHOST} == x86_64* ]]; then
+               use abi_x86_32 && CHOST=i686 ABI=x86 efimake INSTALLROOT="${D}" install
+               use abi_x86_64 && efimake INSTALLROOT="${D}" install
+       else
+               efimake INSTALLROOT="${D}" install
+       fi
        dodoc README* ChangeLog
 }