build-scripts/gcc-fat.sh
branchSDL-1.2
changeset 8914 3984998ee330
child 10132 000274d62b7e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build-scripts/gcc-fat.sh	Mon Jun 23 11:29:53 2014 -0400
     1.3 @@ -0,0 +1,102 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Build Universal binaries on Mac OS X, thanks Ryan!
     1.7 +#
     1.8 +# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf x86 x64
     1.9 +
    1.10 +DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
    1.11 +
    1.12 +# Intel 32-bit compiler flags (10.5 runtime compatibility)
    1.13 +GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.5 \
    1.14 +-I/usr/local/include"
    1.15 +
    1.16 +GCC_LINK_X86="-mmacosx-version-min=10.5"
    1.17 +
    1.18 +# Intel 64-bit compiler flags (10.6 runtime compatibility)
    1.19 +GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \
    1.20 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
    1.21 +-I/usr/local/include"
    1.22 +
    1.23 +GCC_LINK_X64="-mmacosx-version-min=10.6"
    1.24 +
    1.25 +# Output both PowerPC and Intel object files
    1.26 +args="$*"
    1.27 +compile=yes
    1.28 +link=yes
    1.29 +while test x$1 != x; do
    1.30 +    case $1 in
    1.31 +        --version) exec gcc $1;;
    1.32 +        -v) exec gcc $1;;
    1.33 +        -V) exec gcc $1;;
    1.34 +        -print-prog-name=*) exec gcc $1;;
    1.35 +        -print-search-dirs) exec gcc $1;;
    1.36 +        -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
    1.37 +            GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
    1.38 +            compile=no; link=no;;
    1.39 +        -c) link=no;;
    1.40 +        -o) output=$2;;
    1.41 +        *.c|*.cc|*.cpp|*.S) source=$1;;
    1.42 +    esac
    1.43 +    shift
    1.44 +done
    1.45 +if test x$link = xyes; then
    1.46 +    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
    1.47 +    GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
    1.48 +fi
    1.49 +if test x"$output" = x; then
    1.50 +    if test x$link = xyes; then
    1.51 +        output=a.out
    1.52 +    elif test x$compile = xyes; then
    1.53 +        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
    1.54 +    fi
    1.55 +fi
    1.56 +
    1.57 +# Compile X86 32-bit
    1.58 +if test x"$output" != x; then
    1.59 +    dir=x86/`dirname $output`
    1.60 +    if test -d $dir; then
    1.61 +        :
    1.62 +    else
    1.63 +        mkdir -p $dir
    1.64 +    fi
    1.65 +fi
    1.66 +set -- $args
    1.67 +while test x$1 != x; do
    1.68 +    if test -f "x86/$1" && test "$1" != "$output"; then
    1.69 +        x86_args="$x86_args x86/$1"
    1.70 +    else
    1.71 +        x86_args="$x86_args $1"
    1.72 +    fi
    1.73 +    shift
    1.74 +done
    1.75 +$GCC_COMPILE_X86 $x86_args || exit $?
    1.76 +if test x"$output" != x; then
    1.77 +    cp $output x86/$output
    1.78 +fi
    1.79 +
    1.80 +# Compile X86 32-bit
    1.81 +if test x"$output" != x; then
    1.82 +    dir=x64/`dirname $output`
    1.83 +    if test -d $dir; then
    1.84 +        :
    1.85 +    else
    1.86 +        mkdir -p $dir
    1.87 +    fi
    1.88 +fi
    1.89 +set -- $args
    1.90 +while test x$1 != x; do
    1.91 +    if test -f "x64/$1" && test "$1" != "$output"; then
    1.92 +        x64_args="$x64_args x64/$1"
    1.93 +    else
    1.94 +        x64_args="$x64_args $1"
    1.95 +    fi
    1.96 +    shift
    1.97 +done
    1.98 +$GCC_COMPILE_X64 $x64_args || exit $?
    1.99 +if test x"$output" != x; then
   1.100 +    cp $output x64/$output
   1.101 +fi
   1.102 +
   1.103 +if test x"$output" != x; then
   1.104 +    lipo -create -o $output x86/$output x64/$output
   1.105 +fi