test/gcc-fat.sh
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Sep 2009 07:32:26 +0000
branchSDL-1.2
changeset 4209 62e86ab81e3c
parent 4127 6cb18cf1777e
permissions -rwxr-xr-x
Fixed bug #570

SDL_SemWaitTimeout in src/thread/generic/SDL_syssem.c line 179 (SVN trunk):

--sem->count;

should be

if (retval == 0) {
--sem->count;
}

Without this, sem->count will underflow on timeout effectively breaking the
semaphore. It appears that the implementation has been wrong since the initial
revision.
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@4127
     7
# Locate Xcode SDK path
slouken@4127
     8
SDK_PATH=/Developer/SDKs
slouken@4127
     9
if [ ! -d $SDK_PATH ]; then
slouken@4127
    10
    echo "Couldn't find SDK path"
slouken@4127
    11
    exit 1
slouken@4127
    12
fi
slouken@4127
    13
slouken@4127
    14
if [ -d "$SDK_PATH/MacOSX10.2.8.sdk" ]; then
slouken@4127
    15
    # PowerPC compiler flags (10.2 runtime compatibility)
slouken@4127
    16
    GCC_COMPILE_PPC="gcc-3.3 -arch ppc \
slouken@1797
    17
-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
slouken@1797
    18
-nostdinc \
slouken@4127
    19
-F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@4127
    20
-I$SDK_PATH/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
slouken@4127
    21
-isystem $SDK_PATH/MacOSX10.2.8.sdk/usr/include"
slouken@1797
    22
slouken@4127
    23
    GCC_LINK_PPC="\
slouken@4127
    24
-L$SDK_PATH/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
slouken@4127
    25
-F$SDK_PATH/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@4127
    26
-Wl,-syslibroot,$SDK_PATH/MacOSX10.2.8.sdk"
slouken@4127
    27
slouken@4127
    28
else # 10.2 or 10.3 SDK
slouken@4127
    29
    # PowerPC compiler flags (10.3 runtime compatibility)
slouken@4127
    30
    GCC_COMPILE_PPC="gcc-4.0 -arch ppc -mmacosx-version-min=10.3 \
slouken@4127
    31
-DMAC_OS_X_VERSION_MIN_REQUIRED=1030 \
slouken@4127
    32
-nostdinc \
slouken@4127
    33
-F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
slouken@4127
    34
-I$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1/include \
slouken@4127
    35
-isystem $SDK_PATH/MacOSX10.3.9.sdk/usr/include"
slouken@4127
    36
slouken@4127
    37
    GCC_LINK_PPC="\
slouken@4127
    38
-L$SDK_PATH/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1 \
slouken@4127
    39
-F$SDK_PATH/MacOSX10.3.9.sdk/System/Library/Frameworks \
slouken@4127
    40
-Wl,-syslibroot,$SDK_PATH/MacOSX10.3.9.sdk"
slouken@4127
    41
slouken@4127
    42
fi # 10.2 or 10.3 SDK
slouken@1797
    43
slouken@1797
    44
# Intel compiler flags (10.4 runtime compatibility)
slouken@1797
    45
GCC_COMPILE_X86="gcc-4.0 -arch i386 -mmacosx-version-min=10.4 \
slouken@1797
    46
-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
slouken@1797
    47
-nostdinc \
slouken@4127
    48
-F$SDK_PATH/MacOSX10.4u.sdk/System/Library/Frameworks \
slouken@4127
    49
-I$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include \
slouken@4127
    50
-isystem $SDK_PATH/MacOSX10.4u.sdk/usr/include"
slouken@1797
    51
slouken@1797
    52
GCC_LINK_X86="\
slouken@4127
    53
-L$SDK_PATH/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 \
slouken@4127
    54
-Wl,-syslibroot,$SDK_PATH/MacOSX10.4u.sdk"
slouken@1797
    55
slouken@1797
    56
# Output both PowerPC and Intel object files
slouken@1797
    57
args="$*"
slouken@1797
    58
compile=yes
slouken@1797
    59
link=yes
slouken@1797
    60
while test x$1 != x; do
slouken@1797
    61
    case $1 in
slouken@1797
    62
        --version) exec gcc $1;;
slouken@1797
    63
        -v) exec gcc $1;;
slouken@1797
    64
        -V) exec gcc $1;;
slouken@1797
    65
        -print-prog-name=*) exec gcc $1;;
slouken@1797
    66
        -print-search-dirs) exec gcc $1;;
slouken@1797
    67
        -E) GCC_COMPILE_PPC="$GCC_COMPILE_PPC -E"
slouken@1797
    68
            GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
slouken@1797
    69
            compile=no; link=no;;
slouken@1797
    70
        -c) link=no;;
slouken@1797
    71
        -o) output=$2;;
slouken@1797
    72
        *.c|*.cc|*.cpp|*.S) source=$1;;
slouken@1797
    73
    esac
slouken@1797
    74
    shift
slouken@1797
    75
done
slouken@1797
    76
if test x$link = xyes; then
slouken@1797
    77
    GCC_COMPILE_PPC="$GCC_COMPILE_PPC $GCC_LINK_PPC"
slouken@1797
    78
    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
slouken@1797
    79
fi
slouken@1797
    80
if test x"$output" = x; then
slouken@1797
    81
    if test x$link = xyes; then
slouken@1797
    82
        output=a.out
slouken@1797
    83
    elif test x$compile = xyes; then
slouken@1797
    84
        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
slouken@1797
    85
    fi
slouken@1797
    86
fi
slouken@1797
    87
slouken@1797
    88
if test x"$output" != x; then
slouken@1797
    89
    dir=ppc/`dirname $output`
slouken@1797
    90
    if test -d $dir; then
slouken@1797
    91
        :
slouken@1797
    92
    else
slouken@1797
    93
        mkdir -p $dir
slouken@1797
    94
    fi
slouken@1797
    95
fi
slouken@1797
    96
set -- $args
slouken@1797
    97
while test x$1 != x; do
slouken@1797
    98
    if test -f "ppc/$1" && test "$1" != "$output"; then
slouken@1797
    99
        ppc_args="$ppc_args ppc/$1"
slouken@1797
   100
    else
slouken@1797
   101
        ppc_args="$ppc_args $1"
slouken@1797
   102
    fi
slouken@1797
   103
    shift
slouken@1797
   104
done
slouken@1797
   105
$GCC_COMPILE_PPC $ppc_args || exit $?
slouken@1797
   106
if test x"$output" != x; then
slouken@1797
   107
    cp $output ppc/$output
slouken@1797
   108
fi
slouken@1797
   109
slouken@1797
   110
if test x"$output" != x; then
slouken@1797
   111
    dir=x86/`dirname $output`
slouken@1797
   112
    if test -d $dir; then
slouken@1797
   113
        :
slouken@1797
   114
    else
slouken@1797
   115
        mkdir -p $dir
slouken@1797
   116
    fi
slouken@1797
   117
fi
slouken@1797
   118
set -- $args
slouken@1797
   119
while test x$1 != x; do
slouken@1797
   120
    if test -f "x86/$1" && test "$1" != "$output"; then
slouken@1797
   121
        x86_args="$x86_args x86/$1"
slouken@1797
   122
    else
slouken@1797
   123
        x86_args="$x86_args $1"
slouken@1797
   124
    fi
slouken@1797
   125
    shift
slouken@1797
   126
done
slouken@1797
   127
$GCC_COMPILE_X86 $x86_args || exit $?
slouken@1797
   128
if test x"$output" != x; then
slouken@1797
   129
    cp $output x86/$output
slouken@1797
   130
fi
slouken@1797
   131
slouken@1797
   132
if test x"$output" != x; then
slouken@1797
   133
    lipo -create -o $output ppc/$output x86/$output
slouken@1797
   134
fi