build-scripts/gcc-fat.sh
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 19:59:00 -0400
changeset 10266 c09f06c4e8c8
parent 10182 4980c48b8dbe
permissions -rwxr-xr-x
emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
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 CC="sh gcc-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: 9221
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: 9221
diff changeset
    10
GCC_COMPILE_X86="gcc -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: 9221
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="gcc -arch x86_64 -mmacosx-version-min=10.6 \
10182
4980c48b8dbe Mac: Updated availability macro in build script.
Philipp Wiesemann <philipp.wiesemann@arcor.de>
parents: 10176
diff changeset
    17
-DMAC_OS_X_VERSION_MIN_REQUIRED=1060 \
7255
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
-I/usr/local/include"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
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
    21
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
# 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
    23
args="$*"
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
compile=yes
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
link=yes
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
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
    27
    case $1 in
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
        --version) exec gcc $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
        -v) exec gcc $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
        -V) exec gcc $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
        -print-prog-name=*) exec gcc $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
        -print-search-dirs) exec gcc $1;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
        -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
    34
            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
    35
            compile=no; link=no;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
        -c) link=no;;
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
        -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
    38
        *.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
    39
    esac
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
    shift
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
done
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
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
    43
    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
    44
    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
    45
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
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
    47
    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
    48
        output=a.out
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    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
    50
        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
    51
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
# Compile X86 32-bit
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
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
    56
    dir=x86/`dirname $output`
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
    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
    58
        :
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
        mkdir -p $dir
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
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
set -- $args
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
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
    65
    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
    66
        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
    67
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
        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
    69
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
    shift
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
done
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
$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
    73
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
    74
    cp $output x86/$output
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
# Compile X86 32-bit
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
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
    79
    dir=x64/`dirname $output`
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    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
    81
        :
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
        mkdir -p $dir
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
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
set -- $args
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
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
    88
    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
    89
        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
    90
    else
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
        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
    92
    fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    shift
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
done
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
$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
    96
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
    97
    cp $output x64/$output
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
fi
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
ea30c1b99365 The standard fat gcc scripts work well with SDL 2.0
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
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
   101
    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
   102
fi