Skip to content

Commit

Permalink
fatbuild fixes:
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
icculus committed Apr 27, 2006
1 parent 5f37564 commit 7976a95
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
49 changes: 43 additions & 6 deletions build-scripts/fatbuild.sh
Expand Up @@ -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 \
Expand All @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -137,21 +158,21 @@ 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

#
# Build the Intel binary
#
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

#
Expand Down Expand Up @@ -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

5 changes: 5 additions & 0 deletions include/SDL_config_macosx.h
Expand Up @@ -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
Expand Down

0 comments on commit 7976a95

Please sign in to comment.