statically link to gcc windows runtimes when cross compiling windows binaries

This commit is contained in:
William S Fulton 2016-05-29 12:17:06 +01:00
commit 5cb545aefa

View file

@ -11,8 +11,7 @@ zip=
# options for configure # options for configure
extraconfigureoptions= extraconfigureoptions=
compileflags="-O2" compileflags="-O2 -Wall -Wextra"
extracompileflags=
if test x$1 != x; then if test x$1 != x; then
version=$1 version=$1
@ -45,13 +44,15 @@ else
fi fi
echo "Checking that mingw 32-bit gcc is installed/available" echo "Checking that mingw 32-bit gcc is installed/available"
if test -n "`which i686-w64-mingw32-gcc`" ; then if test -n "`which i686-w64-mingw32-gcc`" ; then
extraconfigureoptions="--host=i686-w64-mingw32"
i686-w64-mingw32-gcc --version || exit 1 i686-w64-mingw32-gcc --version || exit 1
i686-w64-mingw32-g++ --version || exit 1 i686-w64-mingw32-g++ --version || exit 1
extraconfigureoptions="--host=i686-w64-mingw32 --build=i686-linux"
# Statically link so that libstdc++-6.dll and libgcc_s_sjlj-1.dll don't have to be shipped
compileflags="$compileflags -static-libgcc -static-libstdc++"
elif test -n "`which i586-mingw32msvc-gcc`" ; then elif test -n "`which i586-mingw32msvc-gcc`" ; then
extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
i586-mingw32msvc-gcc --version || exit 1 i586-mingw32msvc-gcc --version || exit 1
i586-mingw32msvc-g++ --version || exit 1 i586-mingw32msvc-g++ --version || exit 1
extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
else else
echo "Could not detect mingw gcc - please install mingw-w64 package." echo "Could not detect mingw gcc - please install mingw-w64 package."
exit 1; exit 1;
@ -62,7 +63,7 @@ else
if test x$zip = x; then if test x$zip = x; then
zip=zip zip=zip
fi fi
compileflags="-O2 -mno-cygwin" compileflags="$compileflags -mno-cygwin"
else else
echo "Unknown platform. Requires either Linux or MinGW." echo "Unknown platform. Requires either Linux or MinGW."
exit 1; exit 1;
@ -70,6 +71,9 @@ else
fi fi
fi fi
export CFLAGS="$compileflags"
export CXXFLAGS="$compileflags"
swigbasename=swig-$version swigbasename=swig-$version
swigwinbasename=swigwin-$version swigwinbasename=swigwin-$version
tarball=$swigbasename.tar.gz tarball=$swigbasename.tar.gz
@ -98,10 +102,10 @@ if test -f "$tarball"; then
tar -zxf ../$tarball tar -zxf ../$tarball
cd $swigbasename cd $swigbasename
(cd ../.. && cp $pcre_tarball $builddir/$swigbasename) (cd ../.. && cp $pcre_tarball $builddir/$swigbasename)
echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" echo Running: Tools/pcre-build.sh $extraconfigureoptions
./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1 ./Tools/pcre-build.sh $extraconfigureoptions
echo Running: ./configure $extraconfigureoptions --without-alllang CFLAGS="$compileflags" CXXFLAGS="$compileflags" echo Running: ./configure $extraconfigureoptions --without-alllang
./configure $extraconfigureoptions --without-alllang CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1 ./configure $extraconfigureoptions --without-alllang
echo "Compiling (quietly)..." echo "Compiling (quietly)..."
make > build.log make > build.log
echo "Simple check to see if swig.exe runs..." echo "Simple check to see if swig.exe runs..."