diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-09-11 01:57:25 -0400 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2012-09-14 15:27:16 -0700 |
commit | 8f9bae615db5c058e3b6ce7f3f8e2262d59640bf (patch) | |
tree | a4ea6ba9808632e175d323f5b27b04badff303aa /bin | |
parent | 88b0790b1ae8864d4ec6196b3939498bbffdbb5f (diff) | |
download | external_mesa3d-8f9bae615db5c058e3b6ce7f3f8e2262d59640bf.zip external_mesa3d-8f9bae615db5c058e3b6ce7f3f8e2262d59640bf.tar.gz external_mesa3d-8f9bae615db5c058e3b6ce7f3f8e2262d59640bf.tar.bz2 |
mklib: clean up abi flags for x86 targets
The current code is duplicated in two places and relies on `uname` to
detect the flags. This is no good for cross-compiling, and the current
logic uses -m64 for the x32 ABI which breaks things.
Unify the code in one place, avoid `uname` completely, and add support
for the new x32 ABI.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mklib | 42 |
1 files changed, 24 insertions, 18 deletions
@@ -319,6 +319,25 @@ case $ARCH in fi fi + # Check if objects are 32-bit and we're running in 64-bit + # environment. If so, pass -m32 flag to linker. + add_abi_flag_to_opts() { + case $(file $1) in + *32-bit*x86-64*) + # x86_64 x32 ABI. + OPTS="-mx32 ${OPTS}" + ;; + *64-bit*x86-64*) + # x86_64 64-bit ABI. + OPTS="-m64 ${OPTS}" + ;; + *32-bit*Intel*) + # x86 32-bit ABI. + OPTS="-m32 ${OPTS}" + ;; + esac + } + if [ $NOPREFIX = 1 ] ; then # No "lib" or ".so" part echo "mklib: Making" $ARCH "shared library: " ${LIBNAME} @@ -330,15 +349,8 @@ case $ARCH in ;; esac - # Check if objects are 32-bit and we're running in 64-bit - # environment. If so, pass -m32 flag to linker. - set ${OBJECTS} - ABI32=`file $1 | grep 32-bit` - ARM=`file $1 | grep ARM` - # Do not add "-m32" option for arm. - if [ -z "$ARM" -a "${ABI32}" -a `uname -m` = "x86_64" ] ; then - OPTS="-m32 ${OPTS}" - fi + # Check to see if we are building for a different ABI. + add_abi_flag_to_opts ${OBJECTS} if [ "${ALTOPTS}" ] ; then OPTS=${ALTOPTS} @@ -389,15 +401,9 @@ case $ARCH in # exptmp is removed below fi - # Check if objects are 32-bit and we're running in 64-bit - # environment. If so, pass -m32 flag to linker. - set ${OBJECTS} - ABI32=`file $1 | grep 32-bit` - ARM=`file $1 | grep ARM` - # Do not add "-m32" option for arm. - if [ -z "$ARM" -a "${ABI32}" -a `uname -m` = "x86_64" ] ; then - OPTS="-m32 ${OPTS}" - fi + # Check to see if we are building for a different ABI. + add_abi_flag_to_opts ${OBJECTS} + if [ "${ALTOPTS}" ] ; then OPTS=${ALTOPTS} fi |