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
This commit is contained in:
Matthias Mohr 2017-01-15 12:53:13 +01:00 committed by Gerrit Rockbox
parent a724dbbe91
commit 955be5b34a

85
tools/configure vendored
View file

@ -160,16 +160,41 @@ findtool(){
# scan the $PATH for sdl-config - check whether for a (cross-)win32 # scan the $PATH for sdl-config - check whether for a (cross-)win32
# sdl as requested # sdl as requested
findsdl(){ findsdl(){
files=sdl-config
if [ -n "$CROSS_COMPILE" ]; then
# sdl-config might (not) be prefixed for cross compiles so try both. # sdl-config might (not) be prefixed for cross compiles so try both.
files="${CROSS_COMPILE}sdl-config:sdl-config" files="${CROSS_COMPILE}sdl-config:${files}"
fi
winbuild="$1" 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=":" 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 path in $paths2check
do
for file in $files for file in $files
do do
for path in $PATH
do
#echo "checks for $file in $path" >&2
if test -f "$path/$file"; then if test -f "$path/$file"; then
if [ "0" != `$path/$file --libs |grep -c mwindows` ]; then if [ "0" != `$path/$file --libs |grep -c mwindows` ]; then
if [ "yes" = "${winbuild}" ]; then if [ "yes" = "${winbuild}" ]; then
@ -258,10 +283,35 @@ simcc () {
if [ "$win32crosscompile" = "yes" ]; then if [ "$win32crosscompile" = "yes" ]; then
# We are crosscompiling # We are crosscompiling
# add cross-compiler option(s) # add cross-compiler option(s)
GCCOPTS="$GCCOPTS -Wno-format"
LDOPTS="$LDOPTS -mconsole -static" LDOPTS="$LDOPTS -mconsole -static"
output="$output.exe" output="$output.exe"
winbuild="yes" 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='' SHARED_CFLAGS=''
prefixtools "$CROSS_COMPILE" prefixtools "$CROSS_COMPILE"
fibers=`check_fiber` fibers=`check_fiber`
@ -343,14 +393,18 @@ simcc () {
echo "re-run configure!" echo "re-run configure!"
exit 2 exit 2
else else
echo Using $sdl
# generic sdl-config checker # generic sdl-config checker
GCCOPTS="$GCCOPTS `$sdl --cflags`" sdlccopts=$($sdl --cflags)
if sdl-config --static-libs > /dev/null 2>&1 ; then if $sdl --static-libs > /dev/null 2>&1 ; then
LDOPTS="$LDOPTS `$sdl --static-libs`" sdlldopts=$($sdl --static-libs)
else else
echo "Your sdl-config does not know about static libs, falling back to shared library" echo "Your sdl-config does not know about static libs, falling back to shared library"
LDOPTS="$LDOPTS `$sdl --libs`" sdlldopts=$($sdl --libs)
fi fi
GCCOPTS="$GCCOPTS ${sdlccopts}"
LDOPTS="$LDOPTS ${sdlldopts}"
fi fi
fi fi
@ -812,7 +866,7 @@ whichadvanced () {
echo "" echo ""
printf "Enter your developer options (press only enter when done)\n\ 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\ (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 if [ "$modelname" = "archosplayer" ]; then
printf ", Use (A)TA poweroff" printf ", Use (A)TA poweroff"
fi fi
@ -910,8 +964,14 @@ whichadvanced () {
fi fi
;; ;;
[Ww]) [Ww])
echo "Enabling Windows 32 cross-compiling" echo "Enabling Windows cross-compiling (32-bit)"
win32crosscompile="yes" win32crosscompile="yes"
win64=""
;;
[6])
echo "Enabling Windows cross-compiling (64-bit)"
win32crosscompile="yes"
win64="yes"
;; ;;
"") # Match enter press when finished with advanced options "") # Match enter press when finished with advanced options
cont=0 cont=0
@ -4272,6 +4332,9 @@ DLLTOOL=`findtool ${DLLTOOL} --lit`
DLLWRAP=`findtool ${DLLWRAP} --lit` DLLWRAP=`findtool ${DLLWRAP} --lit`
RANLIB=`findtool ${RANLIB} --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 if [ -z "$arch" ]; then
cpp_defines=$(echo "" | $CPP $GCCOPTS -dD) cpp_defines=$(echo "" | $CPP $GCCOPTS -dD)