From 7976a9580c95e1e376f9b685675d61d5699ab016 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 Apr 2006 11:18:03 +0000 Subject: [PATCH] fatbuild fixes: - A change to define CXX in fatbuild, which comforts the configure script a little, even if we don't use C++ anywhere. - Some code to see how many CPU cores exist and parallelize make across them. - CFLAGS that apply to both archs are specified seperately (-O3, -pipe, etc) - -fvisibility=hidden for the gcc4 builds - a "clean", "clean-ppc" and "clean-x86" command - Fix to SDL_config_macosx.h for the HAVE_ALLOCA_H thing. Now builds on an Intel Mac. --- build-scripts/fatbuild.sh | 49 ++++++++++++++++++++++++++++++++----- include/SDL_config_macosx.h | 5 ++++ 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/build-scripts/fatbuild.sh b/build-scripts/fatbuild.sh index ed0abad80..c7da85cbe 100755 --- a/build-scripts/fatbuild.sh +++ b/build-scripts/fatbuild.sh @@ -2,8 +2,17 @@ # # Build a fat binary on Mac OS X, thanks Ryan! +# Number of CPUs (for make -j) +#NCPU=1 +NCPU=`sysctl -n hw.ncpu` + +# !!! FIXME: other CFLAGS? +# Generic, cross-platform CFLAGS you always want go here. +CFLAGS="-O3 -g -pipe" + # PowerPC compiler flags (10.2 runtime compatibility) CC_PPC="gcc-3.3 -arch ppc" +CXX_PPC="g++-3.3 -arch ppc" CFLAGS_PPC="" CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \ -nostdinc \ @@ -19,9 +28,10 @@ LFLAGS_PPC="-arch ppc \ # Intel compiler flags (10.4 runtime compatibility) CC_X86="gcc-4.0 -arch i386" +CXX_X86="g++-4.0 -arch i386" CFLAGS_X86="-mmacosx-version-min=10.4" CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \ --nostdinc \ +-nostdinc -fvisibility=hidden \ -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \ -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \ -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include" @@ -44,6 +54,7 @@ cd $srcdir # configure, configure-ppc, configure-x86, # make, make-ppc, make-x86, merge # install +# clean if test x"$1" = x; then phase=all else @@ -103,8 +114,18 @@ case $phase in install-man) install_man="yes" ;; + clean) + clean_ppc="yes" + clean_x86="yes" + ;; + clean-ppc) + clean_ppc="yes" + ;; + clean-x86) + clean_x86="yes" + ;; *) - echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge]" + echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge|install|clean]" exit 1 ;; esac @@ -137,10 +158,10 @@ done # if test x$configure_ppc = xyes; then (cd build/ppc && \ - sh ../../configure --build=`uname -p`-apple-darwin --host=powerpc-apple-darwin CC="$CC_PPC" CFLAGS="$CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2 + sh ../../configure --build=`uname -p`-apple-darwin --host=powerpc-apple-darwin CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2 fi if test x$make_ppc = xyes; then - (cd build/ppc && make) || exit 3 + (cd build/ppc && make -j$NCPU) || exit 3 fi # @@ -148,10 +169,10 @@ fi # if test x$configure_x86 = xyes; then (cd build/x86 && \ - sh ../../configure --build=`uname -p`-apple-darwin --host=i686-apple-darwin CC="$CC_X86" CFLAGS="$CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2 + sh ../../configure --build=`uname -p`-apple-darwin --host=i686-apple-darwin CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2 fi if test x$make_x86 = xyes; then - (cd build/x86 && make) || exit 3 + (cd build/x86 && make -j$NCPU) || exit 3 fi # @@ -233,3 +254,19 @@ if test x$install_man = xyes; then do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \ done fi + +# +# Clean up +# +do_clean() +{ + echo $* + $* || exit 6 +} +if test x$clean_x86 = xyes; then + do_clean rm -r build/x86 +fi +if test x$clean_ppc = xyes; then + do_clean rm -r build/ppc +fi + diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index b4cc8ca4c..5fc332fb1 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -46,7 +46,12 @@ #define HAVE_CALLOC 1 #define HAVE_REALLOC 1 #define HAVE_FREE 1 + +/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ +#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) #define HAVE_ALLOCA 1 +#endif + #define HAVE_GETENV 1 #define HAVE_PUTENV 1 #define HAVE_UNSETENV 1