From b720b6029597c606da96145b69aff4ded22e4615 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Fri, 22 Mar 2013 13:49:50 +0000 Subject: [PATCH] Move cross-make-mingw.sh's functionality to the Makefile and remove it --- Makefile | 26 +++++++++++++++++++++++++- README | 14 +++++--------- build-test.sh | 7 +++---- cross-make-mingw.sh | 45 --------------------------------------------- jenkins-ci-build.sh | 13 ++----------- 5 files changed, 35 insertions(+), 70 deletions(-) delete mode 100755 cross-make-mingw.sh diff --git a/Makefile b/Makefile index bd9230dd..e0f7cab6 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README b/README index fd4dac90..1f4cf49c 100644 --- a/README +++ b/README @@ -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: diff --git a/build-test.sh b/build-test.sh index d3b7f656..83d463b9 100755 --- a/build-test.sh +++ b/build-test.sh @@ -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 diff --git a/cross-make-mingw.sh b/cross-make-mingw.sh deleted file mode 100755 index f78aa264..00000000 --- a/cross-make-mingw.sh +++ /dev/null @@ -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 $* diff --git a/jenkins-ci-build.sh b/jenkins-ci-build.sh index eb09a37a..33c17e95 100755 --- a/jenkins-ci-build.sh +++ b/jenkins-ci-build.sh @@ -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 $?