fatbuild fixes:
authorRyan C. Gordon <icculus@icculus.org>
Thu, 27 Apr 2006 11:18:03 +0000
changeset 1741d67622addf51
parent 1740 db7e15a99cb3
child 1742 af4352da64d8
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
include/SDL_config_macosx.h
     1.1 --- a/build-scripts/fatbuild.sh	Thu Apr 27 10:44:43 2006 +0000
     1.2 +++ b/build-scripts/fatbuild.sh	Thu Apr 27 11:18:03 2006 +0000
     1.3 @@ -2,8 +2,17 @@
     1.4  #
     1.5  # Build a fat binary on Mac OS X, thanks Ryan!
     1.6  
     1.7 +# Number of CPUs (for make -j)
     1.8 +#NCPU=1
     1.9 +NCPU=`sysctl -n hw.ncpu`
    1.10 +
    1.11 +# !!! FIXME: other CFLAGS?
    1.12 +# Generic, cross-platform CFLAGS you always want go here.
    1.13 +CFLAGS="-O3 -g -pipe"
    1.14 +
    1.15  # PowerPC compiler flags (10.2 runtime compatibility)
    1.16  CC_PPC="gcc-3.3 -arch ppc"
    1.17 +CXX_PPC="g++-3.3 -arch ppc"
    1.18  CFLAGS_PPC=""
    1.19  CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
    1.20  -nostdinc \
    1.21 @@ -19,9 +28,10 @@
    1.22  
    1.23  # Intel compiler flags (10.4 runtime compatibility)
    1.24  CC_X86="gcc-4.0 -arch i386"
    1.25 +CXX_X86="g++-4.0 -arch i386"
    1.26  CFLAGS_X86="-mmacosx-version-min=10.4"
    1.27  CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
    1.28 --nostdinc \
    1.29 +-nostdinc -fvisibility=hidden \
    1.30  -F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
    1.31  -I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
    1.32  -isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
    1.33 @@ -44,6 +54,7 @@
    1.34  # configure, configure-ppc, configure-x86,
    1.35  # make, make-ppc, make-x86, merge
    1.36  # install
    1.37 +# clean
    1.38  if test x"$1" = x; then
    1.39      phase=all
    1.40  else
    1.41 @@ -103,8 +114,18 @@
    1.42      install-man)
    1.43          install_man="yes"
    1.44          ;;
    1.45 +    clean)
    1.46 +        clean_ppc="yes"
    1.47 +        clean_x86="yes"
    1.48 +        ;;
    1.49 +    clean-ppc)
    1.50 +        clean_ppc="yes"
    1.51 +        ;;
    1.52 +    clean-x86)
    1.53 +        clean_x86="yes"
    1.54 +        ;;
    1.55      *)
    1.56 -        echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge]"
    1.57 +        echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge|install|clean]"
    1.58          exit 1
    1.59          ;;
    1.60  esac
    1.61 @@ -137,10 +158,10 @@
    1.62  #
    1.63  if test x$configure_ppc = xyes; then
    1.64      (cd build/ppc && \
    1.65 -     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
    1.66 +     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
    1.67  fi
    1.68  if test x$make_ppc = xyes; then
    1.69 -    (cd build/ppc && make) || exit 3
    1.70 +    (cd build/ppc && make -j$NCPU) || exit 3
    1.71  fi
    1.72  
    1.73  #
    1.74 @@ -148,10 +169,10 @@
    1.75  #
    1.76  if test x$configure_x86 = xyes; then
    1.77      (cd build/x86 && \
    1.78 -     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
    1.79 +     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
    1.80  fi
    1.81  if test x$make_x86 = xyes; then
    1.82 -    (cd build/x86 && make) || exit 3
    1.83 +    (cd build/x86 && make -j$NCPU) || exit 3
    1.84  fi
    1.85  
    1.86  #
    1.87 @@ -233,3 +254,19 @@
    1.88          do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
    1.89      done
    1.90  fi
    1.91 +
    1.92 +#
    1.93 +# Clean up
    1.94 +#
    1.95 +do_clean()
    1.96 +{
    1.97 +    echo $*
    1.98 +    $* || exit 6
    1.99 +}
   1.100 +if test x$clean_x86 = xyes; then
   1.101 +    do_clean rm -r build/x86
   1.102 +fi
   1.103 +if test x$clean_ppc = xyes; then
   1.104 +    do_clean rm -r build/ppc
   1.105 +fi
   1.106 +
     2.1 --- a/include/SDL_config_macosx.h	Thu Apr 27 10:44:43 2006 +0000
     2.2 +++ b/include/SDL_config_macosx.h	Thu Apr 27 11:18:03 2006 +0000
     2.3 @@ -46,7 +46,12 @@
     2.4  #define HAVE_CALLOC	1
     2.5  #define HAVE_REALLOC	1
     2.6  #define HAVE_FREE	1
     2.7 +
     2.8 +/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */
     2.9 +#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) )
    2.10  #define HAVE_ALLOCA	1
    2.11 +#endif
    2.12 +
    2.13  #define HAVE_GETENV	1
    2.14  #define HAVE_PUTENV	1
    2.15  #define HAVE_UNSETENV	1