Move cross-make-mingw.sh's functionality to the Makefile and remove it

This commit is contained in:
Tim Angus 2013-03-22 13:49:50 +00:00
parent e4151c1d55
commit b720b60295
5 changed files with 35 additions and 70 deletions

View file

@ -478,7 +478,7 @@ else # ifeq darwin
ifeq ($(PLATFORM),mingw32)
# Some MinGW installations define CC to cc, but don't actually provide cc,
# so explicitly use gcc instead (which is the only option anyway)
# so check that CC points to a real binary and use gcc if it doesn't
ifeq ($(call bin_path, $(CC)),)
CC=gcc
endif
@ -487,6 +487,30 @@ ifeq ($(PLATFORM),mingw32)
WINDRES=windres
endif
ifeq ($(CROSS_COMPILING),1)
# If CC is already set to something generic, we probably want to use
# something more specific
ifneq ($(findstring $(CC),cc gcc),)
CC=
endif
# We need to figure out the correct compiler
ifeq ($(CC),)
ifeq ($(ARCH),x86_64)
MINGW_PREFIXES=amd64-mingw32msvc x86_64-w64-mingw32
endif
ifeq ($(ARCH),x86)
MINGW_PREFIXES=i586-mingw32msvc i686-w64-mingw32
endif
CC=$(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \
$(call bin_path, $(MINGW_PREFIX)-gcc)))
WINDRES=$(strip $(foreach MINGW_PREFIX, $(MINGW_PREFIXES), \
$(call bin_path, $(MINGW_PREFIX)-windres)))
endif
endif
BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
-DUSE_ICON

14
README
View file

@ -64,15 +64,11 @@ Installation, for *nix
point releases.
2. Run 'make copyfiles'.
It is also possible to cross compile for Windows under *nix using MinGW. A
script is available to build a cross compilation environment from
http://www.libsdl.org/extras/win32/cross/build-cross.sh. The gcc/binutils
version numbers that the script downloads may need to be altered.
Alternatively, your distribution may have mingw32 packages available. On
debian/Ubuntu, these are mingw32, mingw32-runtime and mingw32-binutils. Cross
compiling is simply a case of using './cross-make-mingw.sh' in place of 'make',
though you may find you need to change the value of the variables in this
script to match your environment.
It is also possible to cross compile for Windows under *nix using MinGW. Your
distribution may have mingw32 packages available. On debian/Ubuntu, you need to
install 'mingw-w64'. Thereafter cross compiling is simply a case running
'PLATFORM=mingw32 ARCH=x86 make' in place of 'make'. ARCH may also be set to
x86_64.
The following variables may be set, either on the command line or in
Makefile.local:

View file

@ -4,19 +4,18 @@ failed=0;
# check if testing mingw
if [ "$CC" = "i686-w64-mingw32-gcc" ]; then
MAKE=./cross-make-mingw.sh
export PLATFORM=mingw32
haveExternalLibs=0
else
MAKE=make
haveExternalLibs=1
fi
# Default Build
($MAKE clean release) || failed=1;
(make clean release) || failed=1;
# Test additional options
if [ $haveExternalLibs -eq 1 ]; then
($MAKE clean release USE_CODEC_VORBIS=1 USE_FREETYPE=1) || failed=1;
(make clean release USE_CODEC_VORBIS=1 USE_FREETYPE=1) || failed=1;
fi
if [ $failed -eq 1 ]; then

View file

@ -1,45 +0,0 @@
#!/bin/sh
# Note: This works in Linux and cygwin
if [ "$ARCH" = "x86_64" ];
then
CMD_PREFIX="amd64-mingw32msvc x86_64-w64-mingw32"
else
CMD_PREFIX="i586-mingw32msvc i686-w64-mingw32"
export ARCH=x86
fi
if [ "$CC" = "cc" ] || [ "$CC" = "gcc" ];
then
CC=
fi
if [ "X$CC" = "X" ]; then
for check in $CMD_PREFIX; do
full_check="${check}-gcc"
which "$full_check" > /dev/null 2>&1
if [ "$?" = "0" ]; then
export CC="$full_check"
fi
done
fi
if [ "X$WINDRES" = "X" ]; then
for check in $CMD_PREFIX; do
full_check="${check}-windres"
which "$full_check" > /dev/null 2>&1
if [ "$?" = "0" ]; then
export WINDRES="$full_check"
fi
done
fi
if [ "X$WINDRES" = "X" -o "X$CC" = "X" ]; then
echo "Error: Must define or find WINDRES and CC"
exit 1
fi
export PLATFORM=mingw32
exec make $*

View file

@ -9,17 +9,8 @@ then
export USE_FREETYPE=1
fi
if [ "$PLATFORM" = "mingw32" ];
then
MAKE=./cross-make-mingw.sh
else
MAKE=make
fi
CORES=`awk '/^processor/ { N++} END { print N }' /proc/cpuinfo`
# Default Build
($MAKE -j${CORES} clean ${BUILD_TYPE})
SUCCESS=$?
make -j${CORES} clean ${BUILD_TYPE}
exit ${SUCCESS}
exit $?