build-scripts/gcc-fat.sh
author Ryan C. Gordon <icculus@icculus.org>
Mon, 23 Jun 2014 11:29:53 -0400
branchSDL-1.2
changeset 8914 3984998ee330
child 10124 000274d62b7e
permissions -rwxr-xr-x
Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8914
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
#!/bin/sh
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
#
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
# Build Universal binaries on Mac OS X, thanks Ryan!
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
#
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf x86 x64
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
# Intel 32-bit compiler flags (10.5 runtime compatibility)
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
GCC_COMPILE_X86="gcc -arch i386 -mmacosx-version-min=10.5 \
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
-I/usr/local/include"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
GCC_LINK_X86="-mmacosx-version-min=10.5"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
# Intel 64-bit compiler flags (10.6 runtime compatibility)
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
GCC_COMPILE_X64="gcc -arch x86_64 -mmacosx-version-min=10.6 \
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
-I/usr/local/include"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
GCC_LINK_X64="-mmacosx-version-min=10.6"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
# Output both PowerPC and Intel object files
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
args="$*"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
compile=yes
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
link=yes
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
while test x$1 != x; do
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
    case $1 in
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
        --version) exec gcc $1;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
        -v) exec gcc $1;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
        -V) exec gcc $1;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
        -print-prog-name=*) exec gcc $1;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
        -print-search-dirs) exec gcc $1;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
        -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
            GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
            compile=no; link=no;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
        -c) link=no;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
        -o) output=$2;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
        *.c|*.cc|*.cpp|*.S) source=$1;;
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
    esac
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
    shift
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
done
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
if test x$link = xyes; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
    GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
if test x"$output" = x; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    if test x$link = xyes; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
        output=a.out
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    elif test x$compile = xyes; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
# Compile X86 32-bit
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
if test x"$output" != x; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
    dir=x86/`dirname $output`
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
    if test -d $dir; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
        :
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
    else
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
        mkdir -p $dir
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
set -- $args
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
while test x$1 != x; do
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
    if test -f "x86/$1" && test "$1" != "$output"; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
        x86_args="$x86_args x86/$1"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
    else
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
        x86_args="$x86_args $1"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
    fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
    shift
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
done
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
$GCC_COMPILE_X86 $x86_args || exit $?
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
if test x"$output" != x; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
    cp $output x86/$output
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
# Compile X86 32-bit
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
if test x"$output" != x; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
    dir=x64/`dirname $output`
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
    if test -d $dir; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
        :
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
    else
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
        mkdir -p $dir
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
    fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
set -- $args
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
while test x$1 != x; do
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
    if test -f "x64/$1" && test "$1" != "$output"; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
        x64_args="$x64_args x64/$1"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
    else
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
        x64_args="$x64_args $1"
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
    fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
    shift
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
done
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
$GCC_COMPILE_X64 $x64_args || exit $?
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
if test x"$output" != x; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
    cp $output x64/$output
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
fi
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
if test x"$output" != x; then
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
    lipo -create -o $output x86/$output x64/$output
3984998ee330 Backport gcc-fat.sh and g++-fat.sh to the 1.2 branch to help buildbot.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
fi