test/gcc-fat.sh
author David Ludwig <dludwig@pobox.com>
Wed, 25 Dec 2013 21:39:48 -0500
changeset 8563 c0e68f3b6bbb
parent 1797 783b9409baa0
child 4127 6cb18cf1777e
permissions -rwxr-xr-x
WinRT: compiled the d3d11 renderer's shaders into SDL itself

Previously, the shaders would get compiled separately, the output of which would need to be packaged into the app. This change should make SDL's dll be the only binary needed to include SDL in a WinRT app.
slouken@1797
     1
#!/bin/sh
slouken@1797
     2
#
slouken@1797
     3
# Build Universal binaries on Mac OS X, thanks Ryan!
slouken@1797
     4
#
slouken@1797
     5
# Usage: ./configure CC="sh gcc-fat.sh" && make && rm -rf ppc x86
slouken@1797
     6
slouken@1797
     7
# PowerPC compiler flags (10.2 runtime compatibility)
slouken@1797
     8
GCC_COMPILE_PPC="gcc-3.3 -arch ppc \
slouken@1797
     9
-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
slouken@1797
    10
-nostdinc \
slouken@1797
    11
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@1797
    12
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
slouken@1797
    13
-isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
slouken@1797
    14
slouken@1797
    15
GCC_LINK_PPC="\
slouken@1797
    16
-L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
slouken@1797
    17
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@1797
    18
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
slouken@1797
    19
slouken@1797
    20
# Intel compiler flags (10.4 runtime compatibility)
slouken@1797
    21
GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
slouken@1797
    22
-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
slouken@1797
    23
-nostdinc \
slouken@1797
    24
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
slouken@1797
    25
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
slouken@1797
    26
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
slouken@1797
    27
slouken@1797
    28
GCC_LINK_X86="\
slouken@1797
    29
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
slouken@1797
    30
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
slouken@1797
    31
slouken@1797
    32
# Output both PowerPC and Intel object files
slouken@1797
    33
args="$*"
slouken@1797
    34
compile=yes
slouken@1797
    35
link=yes
slouken@1797
    36
while test x$1 != x; do
slouken@1797
    37
    case $1 in
slouken@1797
    38
        --version) exec gcc $1;;
slouken@1797
    39
        -v) exec gcc $1;;
slouken@1797
    40
        -V) exec gcc $1;;
slouken@1797
    41
        -print-prog-name=*) exec gcc $1;;
slouken@1797
    42
        -print-search-dirs) exec gcc $1;;
slouken@1797
    43
        -E) GCC_COMPILE_PPC="$GCC_COMPILE_PPC -E"
slouken@1797
    44
            GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
slouken@1797
    45
            compile=no; link=no;;
slouken@1797
    46
        -c) link=no;;
slouken@1797
    47
        -o) output=$2;;
slouken@1797
    48
        *.c|*.cc|*.cpp|*.S) source=$1;;
slouken@1797
    49
    esac
slouken@1797
    50
    shift
slouken@1797
    51
done
slouken@1797
    52
if test x$link = xyes; then
slouken@1797
    53
    GCC_COMPILE_PPC="$GCC_COMPILE_PPC $GCC_LINK_PPC"
slouken@1797
    54
    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
slouken@1797
    55
fi
slouken@1797
    56
if test x"$output" = x; then
slouken@1797
    57
    if test x$link = xyes; then
slouken@1797
    58
        output=a.out
slouken@1797
    59
    elif test x$compile = xyes; then
slouken@1797
    60
        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
slouken@1797
    61
    fi
slouken@1797
    62
fi
slouken@1797
    63
slouken@1797
    64
if test x"$output" != x; then
slouken@1797
    65
    dir=ppc/`dirname $output`
slouken@1797
    66
    if test -d $dir; then
slouken@1797
    67
        :
slouken@1797
    68
    else
slouken@1797
    69
        mkdir -p $dir
slouken@1797
    70
    fi
slouken@1797
    71
fi
slouken@1797
    72
set -- $args
slouken@1797
    73
while test x$1 != x; do
slouken@1797
    74
    if test -f "ppc/$1" && test "$1" != "$output"; then
slouken@1797
    75
        ppc_args="$ppc_args ppc/$1"
slouken@1797
    76
    else
slouken@1797
    77
        ppc_args="$ppc_args $1"
slouken@1797
    78
    fi
slouken@1797
    79
    shift
slouken@1797
    80
done
slouken@1797
    81
$GCC_COMPILE_PPC $ppc_args || exit $?
slouken@1797
    82
if test x"$output" != x; then
slouken@1797
    83
    cp $output ppc/$output
slouken@1797
    84
fi
slouken@1797
    85
slouken@1797
    86
if test x"$output" != x; then
slouken@1797
    87
    dir=x86/`dirname $output`
slouken@1797
    88
    if test -d $dir; then
slouken@1797
    89
        :
slouken@1797
    90
    else
slouken@1797
    91
        mkdir -p $dir
slouken@1797
    92
    fi
slouken@1797
    93
fi
slouken@1797
    94
set -- $args
slouken@1797
    95
while test x$1 != x; do
slouken@1797
    96
    if test -f "x86/$1" && test "$1" != "$output"; then
slouken@1797
    97
        x86_args="$x86_args x86/$1"
slouken@1797
    98
    else
slouken@1797
    99
        x86_args="$x86_args $1"
slouken@1797
   100
    fi
slouken@1797
   101
    shift
slouken@1797
   102
done
slouken@1797
   103
$GCC_COMPILE_X86 $x86_args || exit $?
slouken@1797
   104
if test x"$output" != x; then
slouken@1797
   105
    cp $output x86/$output
slouken@1797
   106
fi
slouken@1797
   107
slouken@1797
   108
if test x"$output" != x; then
slouken@1797
   109
    lipo -create -o $output ppc/$output x86/$output
slouken@1797
   110
fi