From 3b2d473eb1e9dec10533d36f303083b6f50b4691 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 1 Jun 2013 12:53:06 -0700 Subject: [PATCH] The standard fat gcc scripts work well with SDL 2.0 --- build-scripts/fatbuild.sh | 294 -------------------------------------- build-scripts/g++-fat.sh | 103 +++++++++++++ build-scripts/gcc-fat.sh | 103 +++++++++++++ 3 files changed, 206 insertions(+), 294 deletions(-) delete mode 100755 build-scripts/fatbuild.sh create mode 100755 build-scripts/g++-fat.sh create mode 100755 build-scripts/gcc-fat.sh diff --git a/build-scripts/fatbuild.sh b/build-scripts/fatbuild.sh deleted file mode 100755 index 807238f4b..000000000 --- a/build-scripts/fatbuild.sh +++ /dev/null @@ -1,294 +0,0 @@ -#!/bin/sh -# -# Build a fat binary on Mac OS X, thanks Ryan! - -# Number of CPUs (for make -j) -NCPU=`sysctl -n hw.ncpu` -if test x$NJOB = x; then - NJOB=$NCPU -fi - -# Generic, cross-platform CFLAGS you always want go here. -CFLAGS="-O3 -g -pipe" - -# We dynamically load X11, so using the system X11 headers is fine. -BASE_CONFIG_FLAGS="--build=`uname -p`-apple-darwin \ ---x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib" - -# PowerPC 32-bit compiler flags -CONFIG_PPC="--host=powerpc-apple-darwin" -CC_PPC="gcc-4.0" -CXX_PPC="g++-4.0" -BUILD_FLAGS_PPC="-arch ppc -mmacosx-version-min=10.4" - -# Intel 32-bit compiler flags -CONFIG_X86="--host=i386-apple-darwin" -CC_X86="gcc" -CXX_X86="g++" -BUILD_FLAGS_X86="-arch i386 -mmacosx-version-min=10.4" - -# Intel 64-bit compiler flags -CONFIG_X64="--host=x86_64-apple-darwin" -CC_X64="gcc" -CXX_X64="g++" -BUILD_FLAGS_X64="-arch x86_64 -mmacosx-version-min=10.6" - -# -# Find the configure script -# -srcdir=`dirname $0`/.. -srcdir=`cd $srcdir && pwd` -auxdir=$srcdir/build-scripts -cd $srcdir - -allow_ppc="yes" -which gcc-4.0 >/dev/null 2>/dev/null -if [ "x$?" = "x1" ]; then - #echo "WARNING: Can't find gcc-4.0, which means you don't have Xcode 3." - #echo "WARNING: Therefore, we can't do PowerPC support." - allow_ppc="no" -fi - -# -# Figure out which phase to build: -# all, -# configure, configure-ppc, configure-x86, configure-x64 -# make, make-ppc, make-x86, make-x64, merge -# install -# clean -if test x"$1" = x; then - phase=all -else - phase="$1" -fi -case $phase in - all) - configure_ppc="$allow_ppc" - configure_x86="yes" - configure_x64="yes" - make_ppc="$allow_ppc" - make_x86="yes" - make_x64="yes" - merge="yes" - ;; - configure) - configure_ppc="$allow_ppc" - configure_x86="yes" - configure_x64="yes" - ;; - configure-ppc) - configure_ppc="$allow_ppc" - ;; - configure-x86) - configure_x86="yes" - ;; - configure-x64) - configure_x64="yes" - ;; - make) - make_ppc="$allow_ppc" - make_x86="yes" - make_x64="yes" - merge="yes" - ;; - make-ppc) - make_ppc="$allow_ppc" - ;; - make-x86) - make_x86="yes" - ;; - make-x64) - make_x64="yes" - ;; - merge) - merge="yes" - ;; - install) - install_bin="yes" - install_hdrs="yes" - install_lib="yes" - install_data="yes" - ;; - install-bin) - install_bin="yes" - ;; - install-hdrs) - install_hdrs="yes" - ;; - install-lib) - install_lib="yes" - ;; - install-data) - install_data="yes" - ;; - clean) - clean_ppc="yes" - clean_x86="yes" - clean_x64="yes" - ;; - clean-ppc) - clean_ppc="yes" - ;; - clean-x86) - clean_x86="yes" - ;; - clean-x64) - clean_x64="yes" - ;; - *) - echo "Usage: $0 [all|configure[-ppc|-x86|-x64]|make[-ppc|-x86|-x64]|merge|install|clean[-ppc|-x86|-x64]]" - exit 1 - ;; -esac -case `uname -p` in - *86) - native_path=x86 - ;; - *powerpc) - native_path=ppc - ;; - x86_64) - native_path=x64 - ;; - *) - echo "Couldn't figure out native architecture path" - exit 1 - ;; -esac - -# -# Create the build directories -# -for dir in build build/ppc build/x86 build/x64; do - if test -d $dir; then - : - else - mkdir $dir || exit 1 - fi -done - - -# -# Build the PowerPC 32-bit binary -# -if test x$configure_ppc = xyes; then - (cd build/ppc && \ - sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $BUILD_FLAGS_PPC $CFLAGS_PPC" LDFLAGS="$BUILD_FLAGS_PPC $LFLAGS_PPC") || exit 2 -fi -if test x$make_ppc = xyes; then - (cd build/ppc && make -j$NJOB) || exit 3 -fi -# -# Build the Intel 32-bit binary -# -if test x$configure_x86 = xyes; then - (cd build/x86 && \ - sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $BUILD_FLAGS_X86 $CFLAGS_X86" LDFLAGS="$BUILD_FLAGS_X86 $LFLAGS_X86") || exit 2 -fi -if test x$make_x86 = xyes; then - (cd build/x86 && make -j$NJOB) || exit 3 -fi - -# -# Build the Intel 64-bit binary -# -if test x$configure_x64 = xyes; then - (cd build/x64 && \ - sh ../../configure $BASE_CONFIG_FLAGS $CONFIG_X64 CC="$CC_X64" CXX="$CXX_X64" CFLAGS="$CFLAGS $BUILD_FLAGS_X64 $CFLAGS_X64" LDFLAGS="$BUILD_FLAGS_X64 $LFLAGS_X64") || exit 2 -fi -if test x$make_x64 = xyes; then - (cd build/x64 && make -j$NJOB) || exit 3 -fi - -# -# Combine into fat binary -# -if test x$merge = xyes; then - output=.libs - sh $auxdir/mkinstalldirs build/$output - cd build - target=`find . -mindepth 4 -maxdepth 4 -type f -name '*.dylib' | head -1 | sed 's|.*/||'` - (lipo -create -o $output/$target `find . -mindepth 4 -maxdepth 4 -type f -name "*.dylib"` && - ln -sf $target $output/libSDL2.dylib && - lipo -create -o $output/libSDL2.a */build/.libs/libSDL2.a && - cp $native_path/build/.libs/libSDL2.la $output && - cp $native_path/build/.libs/libSDL2.lai $output && - cp $native_path/build/libSDL2.la . && - lipo -create -o libSDL2main.a */build/libSDL2main.a && - lipo -create -o libSDL2_test.a */build/libSDL2_test.a && - echo "Build complete!" && - echo "Files can be found in the build directory.") || exit 4 - cd .. -fi - -# -# Install -# -do_install() -{ - echo $* - $* || exit 5 -} -if test x$prefix = x; then - prefix=/usr/local -fi -if test x$exec_prefix = x; then - exec_prefix=$prefix -fi -if test x$bindir = x; then - bindir=$exec_prefix/bin -fi -if test x$libdir = x; then - libdir=$exec_prefix/lib -fi -if test x$includedir = x; then - includedir=$prefix/include -fi -if test x$datadir = x; then - datadir=$prefix/share -fi -if test x$mandir = x; then - mandir=$prefix/man -fi -if test x$install_bin = xyes; then - do_install sh $auxdir/mkinstalldirs $bindir - do_install /usr/bin/install -c -m 755 build/$native_path/sdl2-config $bindir/sdl2-config -fi -if test x$install_hdrs = xyes; then - do_install sh $auxdir/mkinstalldirs $includedir/SDL2 - for src in $srcdir/include/*.h; do \ - file=`echo $src | sed -e 's|^.*/||'`; \ - do_install /usr/bin/install -c -m 644 $src $includedir/SDL2/$file; \ - done - do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL2/SDL_config.h -fi -if test x$install_lib = xyes; then - do_install sh $auxdir/mkinstalldirs $libdir - do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c build/libSDL2.la $libdir/libSDL2.la - do_install /usr/bin/install -c -m 644 build/libSDL2main.a $libdir/libSDL2main.a - do_install ranlib $libdir/libSDL2main.a - do_install /usr/bin/install -c -m 644 build/libSDL2_test.a $libdir/libSDL2_test.a - do_install ranlib $libdir/libSDL2_test.a -fi -if test x$install_data = xyes; then - do_install sh $auxdir/mkinstalldirs $datadir/aclocal - do_install /usr/bin/install -c -m 644 $srcdir/sdl2.m4 $datadir/aclocal/sdl2.m4 -fi - -# -# Clean up -# -do_clean() -{ - echo $* - $* || exit 6 -} -if test x$clean_ppc = xyes; then - do_clean rm -r build/ppc -fi -if test x$clean_x86 = xyes; then - do_clean rm -r build/x86 -fi -if test x$clean_x64 = xyes; then - do_clean rm -r build/x64 -fi diff --git a/build-scripts/g++-fat.sh b/build-scripts/g++-fat.sh new file mode 100755 index 000000000..3c4cab717 --- /dev/null +++ b/build-scripts/g++-fat.sh @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Build Universal binaries on Mac OS X, thanks Ryan! +# +# Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64 + +DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer" + +# Intel 32-bit compiler flags (10.6 runtime compatibility) +GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \ +-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \ +-I/usr/local/include" + +GCC_LINK_X86="-mmacosx-version-min=10.6" + +# Intel 64-bit compiler flags (10.6 runtime compatibility) +GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \ +-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \ +-I/usr/local/include" + +GCC_LINK_X64="-mmacosx-version-min=10.6" + +# Output both PowerPC and Intel object files +args="$*" +compile=yes +link=yes +while test x$1 != x; do + case $1 in + --version) exec g++ $1;; + -v) exec g++ $1;; + -V) exec g++ $1;; + -print-prog-name=*) exec g++ $1;; + -print-search-dirs) exec g++ $1;; + -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E" + GCC_COMPILE_X64="$GCC_COMPILE_X64 -E" + compile=no; link=no;; + -c) link=no;; + -o) output=$2;; + *.c|*.cc|*.cpp|*.S) source=$1;; + esac + shift +done +if test x$link = xyes; then + GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86" + GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64" +fi +if test x"$output" = x; then + if test x$link = xyes; then + output=a.out + elif test x$compile = xyes; then + output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o + fi +fi + +# Compile X86 32-bit +if test x"$output" != x; then + dir=x86/`dirname $output` + if test -d $dir; then + : + else + mkdir -p $dir + fi +fi +set -- $args +while test x$1 != x; do + if test -f "x86/$1" && test "$1" != "$output"; then + x86_args="$x86_args x86/$1" + else + x86_args="$x86_args $1" + fi + shift +done +$GCC_COMPILE_X86 $x86_args || exit $? +if test x"$output" != x; then + cp $output x86/$output +fi + +# Compile X86 32-bit +if test x"$output" != x; then + dir=x64/`dirname $output` + if test -d $dir; then + : + else + mkdir -p $dir + fi +fi +set -- $args +while test x$1 != x; do + if test -f "x64/$1" && test "$1" != "$output"; then + x64_args="$x64_args x64/$1" + else + x64_args="$x64_args $1" + fi + shift +done +$GCC_COMPILE_X64 $x64_args || exit $? +if test x"$output" != x; then + cp $output x64/$output +fi + +if test x"$output" != x; then + lipo -create -o $output x86/$output x64/$output +fi diff --git a/build-scripts/gcc-fat.sh b/build-scripts/gcc-fat.sh new file mode 100755 index 000000000..1601c9db8 --- /dev/null +++ b/build-scripts/gcc-fat.sh @@ -0,0 +1,103 @@ +#!/bin/sh +# +# Build Universal binaries on Mac OS X, thanks Ryan! +# +# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf x86 x64 + +DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer" + +# Intel 32-bit compiler flags (10.6 runtime compatibility) +GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.6 \ +-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \ +-I/usr/local/include" + +GCC_LINK_X86="-mmacosx-version-min=10.6" + +# Intel 64-bit compiler flags (10.6 runtime compatibility) +GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \ +-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \ +-I/usr/local/include" + +GCC_LINK_X64="-mmacosx-version-min=10.6" + +# Output both PowerPC and Intel object files +args="$*" +compile=yes +link=yes +while test x$1 != x; do + case $1 in + --version) exec gcc $1;; + -v) exec gcc $1;; + -V) exec gcc $1;; + -print-prog-name=*) exec gcc $1;; + -print-search-dirs) exec gcc $1;; + -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E" + GCC_COMPILE_X64="$GCC_COMPILE_X64 -E" + compile=no; link=no;; + -c) link=no;; + -o) output=$2;; + *.c|*.cc|*.cpp|*.S) source=$1;; + esac + shift +done +if test x$link = xyes; then + GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86" + GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64" +fi +if test x"$output" = x; then + if test x$link = xyes; then + output=a.out + elif test x$compile = xyes; then + output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o + fi +fi + +# Compile X86 32-bit +if test x"$output" != x; then + dir=x86/`dirname $output` + if test -d $dir; then + : + else + mkdir -p $dir + fi +fi +set -- $args +while test x$1 != x; do + if test -f "x86/$1" && test "$1" != "$output"; then + x86_args="$x86_args x86/$1" + else + x86_args="$x86_args $1" + fi + shift +done +$GCC_COMPILE_X86 $x86_args || exit $? +if test x"$output" != x; then + cp $output x86/$output +fi + +# Compile X86 32-bit +if test x"$output" != x; then + dir=x64/`dirname $output` + if test -d $dir; then + : + else + mkdir -p $dir + fi +fi +set -- $args +while test x$1 != x; do + if test -f "x64/$1" && test "$1" != "$output"; then + x64_args="$x64_args x64/$1" + else + x64_args="$x64_args $1" + fi + shift +done +$GCC_COMPILE_X64 $x64_args || exit $? +if test x"$output" != x; then + cp $output x64/$output +fi + +if test x"$output" != x; then + lipo -create -o $output x86/$output x64/$output +fi