gcc-fat.sh
changeset 131 df3a2df8ccc0
child 132 1cfe0957a376
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gcc-fat.sh	Sun Apr 30 08:56:00 2006 +0000
     1.3 @@ -0,0 +1,110 @@
     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 ppc x86
     1.9 +
    1.10 +# PowerPC compiler flags (10.2 runtime compatibility)
    1.11 +GCC_COMPILE_PPC="gcc-3.3 -arch ppc \
    1.12 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
    1.13 +-nostdinc \
    1.14 +-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
    1.15 +-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
    1.16 +-isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
    1.17 +
    1.18 +GCC_LINK_PPC="\
    1.19 +-L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
    1.20 +-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
    1.21 +-Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
    1.22 +
    1.23 +# Intel compiler flags (10.4 runtime compatibility)
    1.24 +GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
    1.25 +-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
    1.26 +-nostdinc \
    1.27 +-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
    1.28 +-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
    1.29 +-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
    1.30 +
    1.31 +GCC_LINK_X86="\
    1.32 +-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
    1.33 +-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
    1.34 +
    1.35 +# Output both PowerPC and Intel object files
    1.36 +args="$*"
    1.37 +compile=yes
    1.38 +link=yes
    1.39 +while test x$1 != x; do
    1.40 +    case $1 in
    1.41 +        --version) exec gcc $1;;
    1.42 +        -v) exec gcc $1;;
    1.43 +        -V) exec gcc $1;;
    1.44 +        -print-prog-name=*) exec gcc $1;;
    1.45 +        -print-search-dirs) exec gcc $1;;
    1.46 +        -E) GCC_COMPILE_PPC="$GCC_COMPILE_PPC -E"
    1.47 +            GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
    1.48 +            compile=no; link=no;;
    1.49 +        -c) link=no;;
    1.50 +        -o) output=$2;;
    1.51 +        *.c) source=$1;;
    1.52 +    esac
    1.53 +    shift
    1.54 +done
    1.55 +if test x$link = xyes; then
    1.56 +    GCC_COMPILE_PPC="$GCC_COMPILE_PPC $GCC_LINK_PPC"
    1.57 +    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
    1.58 +fi
    1.59 +if test x"$output" = x; then
    1.60 +    if test x$link = xyes; then
    1.61 +        output=a.out
    1.62 +    elif test x$compile = xyes; then
    1.63 +        output=`basename $source .c`.o
    1.64 +    fi
    1.65 +fi
    1.66 +
    1.67 +if test x"$output" != x; then
    1.68 +    dir=ppc/`dirname $output`
    1.69 +    if test -d $dir; then
    1.70 +        :
    1.71 +    else
    1.72 +        mkdir -p $dir
    1.73 +    fi
    1.74 +fi
    1.75 +set -- $args
    1.76 +while test x$1 != x; do
    1.77 +    if test -f "ppc/$1"; then
    1.78 +        ppc_args="$ppc_args ppc/$1"
    1.79 +    else
    1.80 +        ppc_args="$ppc_args $1"
    1.81 +    fi
    1.82 +    shift
    1.83 +done
    1.84 +$GCC_COMPILE_PPC $ppc_args || exit $?
    1.85 +if test x"$output" != x; then
    1.86 +    cp $output ppc/$output
    1.87 +fi
    1.88 +
    1.89 +if test x"$output" != x; then
    1.90 +    dir=x86/`dirname $output`
    1.91 +    if test -d $dir; then
    1.92 +        :
    1.93 +    else
    1.94 +        mkdir -p $dir
    1.95 +    fi
    1.96 +fi
    1.97 +set -- $args
    1.98 +while test x$1 != x; do
    1.99 +    if test -f "x86/$1"; then
   1.100 +        x86_args="$x86_args x86/$1"
   1.101 +    else
   1.102 +        x86_args="$x86_args $1"
   1.103 +    fi
   1.104 +    shift
   1.105 +done
   1.106 +$GCC_COMPILE_X86 $x86_args || exit $?
   1.107 +if test x"$output" != x; then
   1.108 +    cp $output x86/$output
   1.109 +fi
   1.110 +
   1.111 +if test x"$output" != x; then
   1.112 +    lipo -create -o $output ppc/$output x86/$output
   1.113 +fi