Skip to content

Commit

Permalink
statically link to gcc windows runtimes when cross compiling windows …
Browse files Browse the repository at this point in the history
…binaries
  • Loading branch information
wsfulton committed May 29, 2016
1 parent 8eb9eeb commit 5cb545a
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Tools/mkwindows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ zip=

# options for configure
extraconfigureoptions=
compileflags="-O2"
extracompileflags=
compileflags="-O2 -Wall -Wextra"

if test x$1 != x; then
version=$1
Expand Down Expand Up @@ -45,13 +44,15 @@ else
fi
echo "Checking that mingw 32-bit gcc is installed/available"
if test -n "`which i686-w64-mingw32-gcc`" ; then
extraconfigureoptions="--host=i686-w64-mingw32"
i686-w64-mingw32-gcc --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
extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
i586-mingw32msvc-gcc --version || exit 1
i586-mingw32msvc-g++ --version || exit 1
extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
else
echo "Could not detect mingw gcc - please install mingw-w64 package."
exit 1;
Expand All @@ -62,14 +63,17 @@ else
if test x$zip = x; then
zip=zip
fi
compileflags="-O2 -mno-cygwin"
compileflags="$compileflags -mno-cygwin"
else
echo "Unknown platform. Requires either Linux or MinGW."
exit 1;
fi
fi
fi

export CFLAGS="$compileflags"
export CXXFLAGS="$compileflags"

swigbasename=swig-$version
swigwinbasename=swigwin-$version
tarball=$swigbasename.tar.gz
Expand Down Expand Up @@ -98,10 +102,10 @@ if test -f "$tarball"; then
tar -zxf ../$tarball
cd $swigbasename
(cd ../.. && cp $pcre_tarball $builddir/$swigbasename)
echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
echo Running: ./configure $extraconfigureoptions --without-alllang CFLAGS="$compileflags" CXXFLAGS="$compileflags"
./configure $extraconfigureoptions --without-alllang CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
echo Running: Tools/pcre-build.sh $extraconfigureoptions
./Tools/pcre-build.sh $extraconfigureoptions
echo Running: ./configure $extraconfigureoptions --without-alllang
./configure $extraconfigureoptions --without-alllang
echo "Compiling (quietly)..."
make > build.log
echo "Simple check to see if swig.exe runs..."
Expand Down

0 comments on commit 5cb545a

Please sign in to comment.