From 955be5b34af2e6cf374162ea8b4d4451b1644952 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Sun, 15 Jan 2017 12:53:13 +0100 Subject: Fix configure for windows simulator builds in cygwin / mingw cross-compiling environments. Fixes and Changes to configure the Windows simulator builds mostly for cygwin / mingw cross-compiling environments: - fix CROSS_COMPILE values including detection for old and newer mingw environments - fix detection of sdl-config by searching inside CROSS_COMPILE sys-root - fix call of sdl-config and use correct (found) version - add possibility to build a 64-bit simulator - added several -Wno- options to GCCOPTS to prevent annoying compiler warnings - use cross-compiler as HOST_CC if no "native" HOST_CC is available Change-Id: Ib5dd288c3f9a11be9b66e53e3406eadfa65f7604 --- tools/configure | 89 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 13 deletions(-) diff --git a/tools/configure b/tools/configure index a9fe058cbd..11ff981fdb 100755 --- a/tools/configure +++ b/tools/configure @@ -160,16 +160,41 @@ findtool(){ # scan the $PATH for sdl-config - check whether for a (cross-)win32 # sdl as requested findsdl(){ - # sdl-config might (not) be prefixed for cross compiles so try both. - files="${CROSS_COMPILE}sdl-config:sdl-config" + files=sdl-config + if [ -n "$CROSS_COMPILE" ]; then + # sdl-config might (not) be prefixed for cross compiles so try both. + files="${CROSS_COMPILE}sdl-config:${files}" + fi winbuild="$1" + paths2check="$PATH" + + if [ -n "$CROSS_COMPILE" ]; then + # add cross compile sys-root-directories to search in: + sysroot=$($CPP --print-sysroot 2>&1) + if [ $? -eq 0 ]; + then + subdirs="bin:mingw/bin:sbin:mingw/sbin" + IFS=":" + for subdir in $subdirs + do + if [ -e "${sysroot}/${subdir}" ]; then + paths2check="${sysroot}/${subdir}:${paths2check}" + fi + done + else + echo "WARNING: unable to get sys-root directory from your cross-compiler" >&2 + echo "WARNING: $CPP --print-sysroot returns" >&2 + echo "WARNING: ${sysroot}" >&2 + fi + fi + + # search for the correct sdl-config IFS=":" - for file in $files + for path in $paths2check do - for path in $PATH + for file in $files do - #echo "checks for $file in $path" >&2 if test -f "$path/$file"; then if [ "0" != `$path/$file --libs |grep -c mwindows` ]; then if [ "yes" = "${winbuild}" ]; then @@ -258,10 +283,35 @@ simcc () { if [ "$win32crosscompile" = "yes" ]; then # We are crosscompiling # add cross-compiler option(s) + GCCOPTS="$GCCOPTS -Wno-format" LDOPTS="$LDOPTS -mconsole -static" output="$output.exe" winbuild="yes" - CROSS_COMPILE=${CROSS_COMPILE:-"i586-mingw32msvc-"} + + if [ -z "$CROSS_COMPILE" ]; then + if [ "$win64" = "yes" ]; then + CROSS_COMPILE=${CROSS_COMPILE:-"x86_64-w64-mingw32-"} + else + # different possible names; try to find the correct one: + names="i686-w64-mingw32 i686-pc-mingw32 i586-mingw32msvc" + + for name in $names + do + if which "${name}-gcc" >/dev/null 2>&1 ; then + CROSS_COMPILE="${name}-" + break + fi + done + + if [ -z "$CROSS_COMPILE" ]; then + echo "WARNING: unable to find cross-compiler for 32-bit Windows environment!" + echo "WARNING: it's none of \"$names\"." + echo "WARNING: set your compiler prefix with CROSS_COMPILE=\"your-prefix-\" and" + echo "WARNING: re-run configure again!" + exit 2 + fi + fi + fi SHARED_CFLAGS='' prefixtools "$CROSS_COMPILE" fibers=`check_fiber` @@ -343,14 +393,18 @@ simcc () { echo "re-run configure!" exit 2 else + echo Using $sdl + # generic sdl-config checker - GCCOPTS="$GCCOPTS `$sdl --cflags`" - if sdl-config --static-libs > /dev/null 2>&1 ; then - LDOPTS="$LDOPTS `$sdl --static-libs`" + sdlccopts=$($sdl --cflags) + if $sdl --static-libs > /dev/null 2>&1 ; then + sdlldopts=$($sdl --static-libs) else - echo "Your sdl-config does not know about static libs, falling back to shared library" - LDOPTS="$LDOPTS `$sdl --libs`" + echo "Your sdl-config does not know about static libs, falling back to shared library" + sdlldopts=$($sdl --libs) fi + GCCOPTS="$GCCOPTS ${sdlccopts}" + LDOPTS="$LDOPTS ${sdlldopts}" fi fi @@ -812,7 +866,7 @@ whichadvanced () { echo "" printf "Enter your developer options (press only enter when done)\n\ (D)EBUG, (L)ogf, Boot(c)hart, (S)imulator, (P)rofiling, (V)oice, (W)in32 crosscompile,\n\ -(T)est plugins, S(m)all C lib, Logf to Ser(i)al port:" +Win(6)4 crosscompile, (T)est plugins, S(m)all C lib, Logf to Ser(i)al port:" if [ "$modelname" = "archosplayer" ]; then printf ", Use (A)TA poweroff" fi @@ -910,8 +964,14 @@ whichadvanced () { fi ;; [Ww]) - echo "Enabling Windows 32 cross-compiling" + echo "Enabling Windows cross-compiling (32-bit)" + win32crosscompile="yes" + win64="" + ;; + [6]) + echo "Enabling Windows cross-compiling (64-bit)" win32crosscompile="yes" + win64="yes" ;; "") # Match enter press when finished with advanced options cont=0 @@ -4272,6 +4332,9 @@ DLLTOOL=`findtool ${DLLTOOL} --lit` DLLWRAP=`findtool ${DLLWRAP} --lit` RANLIB=`findtool ${RANLIB} --lit` +# in pure cross-compiler environments without own native compiler this helps: +HOSTCC=${HOSTCC:-${CC}} +HOSTAR=${HOSTAR:-${AR}} if [ -z "$arch" ]; then cpp_defines=$(echo "" | $CPP $GCCOPTS -dD) -- cgit v1.2.3