From 61611e108cb789f3495ebed01712df412e658942 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Wed, 25 Sep 2019 22:51:12 -0400 Subject: [PATCH] Linux cross-compiling. --- lib/bin/build_lib | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/bin/build_lib b/lib/bin/build_lib index 9d03024f..d75baec0 100755 --- a/lib/bin/build_lib +++ b/lib/bin/build_lib @@ -169,7 +169,7 @@ _target_prepare() { # --enable-pic --disable-pie to ensure the resulting library can be linked again. target_configure() { _target_configure "$@"; } _target_configure() { - local prefix=$1 platform=$2 arch=$3; shift 3 + local prefix=$1 platform=$2 arch=$3 host=$arch-$platform; shift 3 case "$platform" in 'windows') @@ -188,7 +188,7 @@ _target_configure() { ;; esac - ./configure ${host:+--host="$host"} --enable-pic --disable-pie --prefix="$prefix/$arch" "$@" + ./configure --build="$(./build-aux/config.guess)" ${host:+--host="$host"} --enable-pic --disable-pie --prefix="$prefix/$arch" "$@" } # target_build @@ -305,11 +305,12 @@ _build() { 'ios') archs=( 'i386' 'x86_64' 'armv7' 'armv7s' 'arm64' ) ;; 'android') archs=( 'arm' 'arm64' 'x86' 'x86_64' ) ;; 'windows') archs=( 'Win32' 'x64' ) ;; - *) archs=( 'i386' 'x86_64' ) ;; + *) archs=( 'x86' 'x86_64' ) ;; esac fi local prefix="$PWD/build-$platform~" + echo " # $name ($platform: ${archs[*]}) into $prefix ..." initialize "$prefix" "$platform" # "clean" argument wipes the lib clean and exits. If .success exists in prefix output, skip build. @@ -373,8 +374,19 @@ _build() { # x86 CFLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32" # x86_64 CFLAGS="-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel" ;; + *) + case "$arch" in + x86) + export CFLAGS="-m32" + ;; + x86_64) + export CFLAGS="-m64" + ;; + esac + ;; esac + echo " # $name ($platform: $arch) ..." target "$prefix" "$platform" "$arch" ); done