build-scripts/g++-fat.sh
author Ryan C. Gordon <icculus@icculus.org>
Sun, 28 Aug 2016 13:36:13 -0400
changeset 10286 3b884985835c
parent 10176 3115d38204aa
permissions -rwxr-xr-x
Merge audio capture work back into the mainline.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7255
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
#!/bin/sh
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
#
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
# Build Universal binaries on Mac OS X, thanks Ryan!
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
#
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
# Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
10176
3115d38204aa Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
Alex Szpakowski <slime73@gmail.com>
parents: 9783
diff changeset
     9
# Intel 32-bit compiler flags (10.6 runtime compatibility)
3115d38204aa Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
Alex Szpakowski <slime73@gmail.com>
parents: 9783
diff changeset
    10
GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \
7255
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
-I/usr/local/include"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
10176
3115d38204aa Removed Mac OS 10.5 support (bug #3137). Also fixed a warning about deprecated Carbon code when using SDL_audio (bug #3127, thanks Dominik!)
Alex Szpakowski <slime73@gmail.com>
parents: 9783
diff changeset
    13
GCC_LINK_X86="-mmacosx-version-min=10.6"
7255
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
# Intel 64-bit compiler flags (10.6 runtime compatibility)
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
-I/usr/local/include"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
GCC_LINK_X64="-mmacosx-version-min=10.6"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
# Output both PowerPC and Intel object files
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
args="$*"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
compile=yes
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
link=yes
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
while test x$1 != x; do
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
    case $1 in
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
        --version) exec g++ $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
        -v) exec g++ $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
        -V) exec g++ $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
        -print-prog-name=*) exec g++ $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
        -print-search-dirs) exec g++ $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
        -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
            GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
            compile=no; link=no;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
        -c) link=no;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
        -o) output=$2;;
9221
0702f9d6e2b1 Fixed gcc-fat.sh failing to build Objective-C sources correctly.
Ryan C. Gordon <icculus@icculus.org>
parents: 7507
diff changeset
    37
        *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
7255
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
    esac
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
    shift
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
done
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
if test x$link = xyes; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
if test x"$output" = x; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
    if test x$link = xyes; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
        output=a.out
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
    elif test x$compile = xyes; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
# Compile X86 32-bit
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
if test x"$output" != x; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
    dir=x86/`dirname $output`
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
    if test -d $dir; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
        :
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
        mkdir -p $dir
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
set -- $args
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
while test x$1 != x; do
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    if test -f "x86/$1" && test "$1" != "$output"; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
        x86_args="$x86_args x86/$1"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
        x86_args="$x86_args $1"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
    shift
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
done
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
$GCC_COMPILE_X86 $x86_args || exit $?
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
if test x"$output" != x; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
    cp $output x86/$output
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
# Compile X86 32-bit
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
if test x"$output" != x; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    dir=x64/`dirname $output`
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    if test -d $dir; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        :
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        mkdir -p $dir
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
set -- $args
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
while test x$1 != x; do
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
    if test -f "x64/$1" && test "$1" != "$output"; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
        x64_args="$x64_args x64/$1"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
        x64_args="$x64_args $1"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
    shift
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
done
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
$GCC_COMPILE_X64 $x64_args || exit $?
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
if test x"$output" != x; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
    cp $output x64/$output
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
if test x"$output" != x; then
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
    lipo -create -o $output x86/$output x64/$output
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
fi