build-scripts/gcc-fat.sh
author Ozkan Sezer <sezeroz@gmail.com>
Sat, 24 Mar 2018 23:38:50 +0300
branchSDL-1.2
changeset 11977 6cf3a08b42dc
parent 10132 000274d62b7e
permissions -rwxr-xr-x
backport bug #3332 (win32 deadkeys) patch:

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