make mklib work with cross compilation
authorHelmut Grohne <helmut@subdivi.de>
Thu, 10 Aug 2017 12:00:39 +0000 (14:00 +0200)
committerPeter Michael Green <plugwash@raspbian.org>
Thu, 17 Aug 2017 19:49:55 +0000 (20:49 +0100)
The first hunk makes it use the compiler discovered by ./configure and thus
will work with cross compilers. Since Makefile.in exports CC and CXX, it seems
like mklib should be picking these up and not doing so is an upstream bug.

Then remove insertion of -m32, because this is not universally understood by
cross compilers. On Debian, the provided compiler will always choose the
correct ABI, so no -m32 or -m64 is necessary. This part likely is not
upstreamable.

Gbp-Pq: Name make-mklib-work-with-cross-compilation.patch

mklib

diff --git a/mklib b/mklib
index c900b3e63b6195eb66ad8638bb5dc2de4df72d50..bb070ac85c8bb67bccd36ac10489b6c2ce3fd053 100755 (executable)
--- a/mklib
+++ b/mklib
@@ -211,9 +211,9 @@ case $ARCH in
        if [ "x$LINK" = "x" ] ; then
            # -linker was not specified so set default link command now
             if [ $CPLUSPLUS = 1 ] ; then
-                LINK=g++
+                LINK=${CXX:-g++}
             else
-                LINK=gcc
+                LINK=${CC:-gcc}
             fi
        fi
 
@@ -228,14 +228,6 @@ 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`
-           if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
-               OPTS="-m32 ${OPTS}"
-           fi
-
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
             fi
@@ -281,13 +273,6 @@ 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`
-           if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
-               OPTS="-m32 ${OPTS}"
-           fi
             if [ "${ALTOPTS}" ] ; then
                 OPTS=${ALTOPTS}
             fi
@@ -355,15 +340,7 @@ case $ARCH in
                OPTS="-G"
            else
                # gcc linker
-               # 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`
-               if [ "${ABI32}" ] ; then
-                   OPTS="-m32 -shared -Wl,-Bdynamic"
-               else
-                   OPTS="-m64 -shared -Wl,-Bdynamic"
-               fi
+               OPTS="-shared -Wl,-Bdynamic"
            fi
 
            # Check if objects are SPARC v9