---
 gx86/eclass/multilib-build.eclass | 41 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/gx86/eclass/multilib-build.eclass 
b/gx86/eclass/multilib-build.eclass
index dbaed70..fdaed6b 100644
--- a/gx86/eclass/multilib-build.eclass
+++ b/gx86/eclass/multilib-build.eclass
@@ -25,10 +25,22 @@ esac
 
 inherit multibuild multilib
 
+# @ECLASS-VARIABLE: MULTILIB_ABI
+# @DEFAULT-UNSET
+# @DESCRIPTION:
+# The current ABI, in form of base arch and sub-ABI, joined using
+# an underscore. It's equal to the flag name with 'abi_' prefix
+# stripped.
+#
+# Exported by multilib_foreach_abi, multilib_parallel_foreach_abi,
+# multilib_for_best_abi.
+#
+# Example values: x86_32, mips_n32
+
 # @ECLASS-VARIABLE: _MULTILIB_FLAGS
 # @INTERNAL
 # @DESCRIPTION:
-# The list of multilib flags and corresponding ABI values.
+# The list of corresponding USE flags and ABI values.
 _MULTILIB_FLAGS=(
        abi_x86_32:x86
        abi_x86_64:amd64
@@ -56,6 +68,7 @@ _multilib_build_set_globals() {
 _multilib_build_set_globals
 
 # @FUNCTION: multilib_get_enabled_abis
+# @INTERNAL
 # @DESCRIPTION:
 # Return the ordered list of enabled ABIs if multilib builds
 # are enabled. The best (most preferred) ABI will come last.
@@ -74,7 +87,7 @@ multilib_get_enabled_abis() {
                        local m_flag=${i%:*}
 
                        if [[ ${m_abi} == ${abi} ]] && use "${m_flag}"; then
-                               echo "${abi}"
+                               echo "${m_flag#abi_}"
                                found=1
                        fi
                done
@@ -87,7 +100,7 @@ multilib_get_enabled_abis() {
 
                debug-print "${FUNCNAME}: no ABIs enabled, fallback to ${abi}"
                debug-print "${FUNCNAME}: ABI=${ABI}, 
DEFAULT_ABI=${DEFAULT_ABI}"
-               echo ${abi}
+               echo default
        fi
 }
 
@@ -99,8 +112,26 @@ multilib_get_enabled_abis() {
 _multilib_multibuild_wrapper() {
        debug-print-function ${FUNCNAME} "${@}"
 
-       local ABI=${MULTIBUILD_VARIANT}
-       multilib_toolchain_setup "${ABI}"
+       local MULTILIB_ABI=${MULTIBUILD_VARIANT}
+       local i
+
+       if [[ ${MULTILIB_ABI} != default ]]; then
+               local ABI
+
+               for i in "${_MULTILIB_FLAGS[@]}"; do
+                       local m_abi=${i#*:}
+                       local m_flag=${i%:*}
+
+                       if [[ ${MULTILIB_ABI} == ${m_flag#abi_} ]]; then
+                               local -x ABI=${m_abi}
+                               break
+                       fi
+               done
+
+               [[ ${ABI} ]] || die "Unable to match ${MULTILIB_ABI} to an ABI!"
+               multilib_toolchain_setup "${ABI}"
+       fi
+
        "${@}"
 }
 
-- 
1.8.1.5


Reply via email to