configure changes to support cross compiling with mingw32
RFC PATCH 1/1 configure changes to support cross compiling with mingw32
--enable-mingw32 hasn't ever worked for me. The follow patch is a set of changes to configure so that --cross-prefix=i586-mingw32-msvc does the right thing.
It needs some testing. It works for me but I don't know if people have weird setups where the gcc cross prefix != the sdl cross prefix or something odd like that.
Regards,
Anthony Liguori
# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 157550eed1f5e456a0f43167bd21bc14ad164d51
# Parent bda9c89460daa713765b316ea8ef1bfe7fd79091
A number of fixes to configure while getting cross compiling with mingw32 to work.
Remove the --enable-mingw option. It hardcoded a cross-compile prefix and a different prefix is used on the mingw32 tools on some distros. Now:
./configure --cross-prefix=i586-mingw32msvc- ...
will do the Right Thing so --enable-mingw is no longer needed.
Add a check after $cc includes the cross-compile prefix so we can determine what the target really is (as opposed to using uname).
Remove the check for test -e for /usr/include/byteswap.h to a compile check. This breaks cross compiling.
Add a check for zlib so that we give a nice error if zlib-devel is missing.
Use ${cross_prefix}sdl-config
When we exit, make sure to remove TMP files.
configure +45 -21
@@ -213,8 +213,6 @@ for opt do ;; --fmod-inc=*) fmod_inc="$optarg" ;; - --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" ; user="no" - ;; --disable-slirp) slirp="no" ;; --enable-adlib) adlib="yes"
@@ -278,7 +276,6 @@ echo " --install=INSTALL use spe echo " --install=INSTALL use specified install [$install]" echo " --static enable static build [$static]" echo " --enable-cocoa enable COCOA (Mac OS X only)" -echo " --enable-mingw32 enable Win32 cross compilation with mingw32" echo " --enable-adlib enable Adlib emulation" echo " --enable-coreaudio enable Coreaudio audio driver" echo " --enable-alsa enable ALSA audio driver"
@@ -301,6 +298,23 @@ ar="${cross_prefix}${ar}" ar="${cross_prefix}${ar}" strip="${cross_prefix}${strip}" +# we really ought move the whole archecture check down here +targetos=`$cc -dumpmachine` +case $targetos in + *-mingw32msvc) + mingw32="yes" + oss="no" + user="no" + linux="no" # hack + EXESUF=".exe" + if [ "$cpu" = "i386" ] ; then + kqemu="yes" + fi + ;; + *) + ;; +esac + # check that the C compiler works. cat > $TMPC <<EOF int main(void) {}
@@ -311,15 +325,6 @@ else else echo "ERROR: \"$cc\" either does not exist or does not work" exit 1 -fi - -if test "$mingw32" = "yes" ; then - linux="no" - EXESUF=".exe" - oss="no" - if [ "$cpu" = "i386" ] ; then - kqemu="yes" - fi fi #
@@ -437,10 +442,29 @@ EOF echo "QEMU is known to have problems when compiled with gcc 4.x" echo "It is recommended that you use gcc 3.x to build QEMU" echo "To use this compiler anyway, configure with --disable-gcc-check" + rm -f $TMPO $TMPC $TMPE $TMPS exit 1; fi fi +# Check for zlib +cat > $TMPC <<EOF +#include <zlib.h> +int main(){(void)zlibVersion(); return 0;} +EOF +if $cc -o $TMPE $TMPC -lz 2>/dev/null; then + zlib="yes" +else + zlib="no" +fi + +if test "$zlib" = "no"; then + echo "ERROR: QEMU requires the zlib library. You may have to install" + echo "the development package." + rm -f $TMPO $TMPC $TMPE $TMPS + exit 1; +fi + ########################################## # SDL probe
@@ -448,15 +472,10 @@ sdl_too_old=no if test -z "$sdl" ; then -sdl_config="sdl-config" +sdl_config="${cross-prefix}sdl-config" sdl=no sdl_static=no -if test "$mingw32" = "yes" -a ! -z "$cross_prefix" ; then -# win32 cross compilation case - sdl_config="i386-mingw32msvc-sdl-config" - sdl=yes -else # normal SDL probe cat > $TMPC << EOF #include <SDL.h>
@@ -489,7 +508,6 @@ fi # static link fi # sdl compile test -fi # cross compilation fi # -z $sdl # Check if tools are available to build documentation.
@@ -540,7 +558,6 @@ if test "$sdl" != "no" ; then if test "$sdl" != "no" ; then echo "SDL static link $sdl_static" fi -echo "mingw32 support $mingw32" echo "Adlib support $adlib" echo "CoreAudio support $coreaudio" echo "ALSA support $alsa"
@@ -573,6 +590,13 @@ config_h="config-host.h" config_h="config-host.h" #echo "Creating $config_mak and $config_h" + +have_header() { + cat > $TMPC <<EOF +#include <$1> +EOF + $cc -c -o $TMPO $TMPC 2>/dev/null +} echo "# Automatically generated by configure - do not modify" > $config_mak echo "# Configured with: $0 $@" >> $config_mak
@@ -644,7 +668,7 @@ if test "$mingw32" = "yes" ; then if test "$mingw32" = "yes" ; then echo "CONFIG_WIN32=yes" >> $config_mak echo "#define CONFIG_WIN32 1" >> $config_h -elif test -f "/usr/include/byteswap.h" ; then +elif have_header "/usr/include/byteswap.h" ; then echo "#define HAVE_BYTESWAP_H 1" >> $config_h fi if test "$darwin" = "yes" ; then
configure sdl_too_old=no · line 475
Quoted 6 lines · Anthony Liguori
configure +1
-1@@ -448,15 +472,10 @@ sdl_too_old=no if test -z "$sdl" ; then -sdl_config="sdl-config" +sdl_config="${cross-prefix}sdl-config"
That should obviously be cross_prefix :-) Cross compiling SDL seems to be pretty darn nasty and the binary they provide assumes i386- After changing the sdl-config to report the right info, things seem to work for me though.
Regards,
Anthony Liguori