build-scripts/fatbuild.sh
author Sam Lantinga <slouken@libsdl.org>
Wed, 19 Apr 2006 03:49:57 +0000
changeset 1646 7c53bb4b1db4
parent 1645 2a55580b767b
child 1648 9f59d4c5aaea
permissions -rwxr-xr-x
I think this is it...
slouken@1636
     1
#!/bin/sh
slouken@1636
     2
#
slouken@1636
     3
# Build a fat binary on Mac OS X, thanks Ryan!
slouken@1636
     4
slouken@1636
     5
# PowerPC compiler flags (10.2 runtime compatibility)
slouken@1639
     6
CFLAGS_PPC="-arch ppc \
slouken@1636
     7
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@1636
     8
-I/Developer/SDKs/MacOSX10.2.8.sdk/Developer/Headers/FlatCarbon \
slouken@1636
     9
-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
slouken@1636
    10
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
slouken@1636
    11
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++ \
slouken@1636
    12
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin \
slouken@1636
    13
-isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
slouken@1636
    14
slouken@1636
    15
# PowerPC linker flags 
slouken@1639
    16
LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.2 \
slouken@1636
    17
-L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
slouken@1636
    18
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@1636
    19
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
slouken@1636
    20
slouken@1636
    21
# Intel compiler flags (10.4 runtime compatibility)
slouken@1639
    22
CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
slouken@1636
    23
-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
slouken@1636
    24
slouken@1636
    25
# Intel linker flags
slouken@1639
    26
LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
slouken@1636
    27
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
slouken@1636
    28
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
slouken@1636
    29
slouken@1636
    30
#
slouken@1636
    31
# Find the configure script
slouken@1636
    32
#
slouken@1636
    33
cd `dirname $0`/..
slouken@1636
    34
slouken@1636
    35
#
slouken@1636
    36
# Figure out which phase to build:
slouken@1636
    37
# all,
slouken@1636
    38
# configure, configure-ppc, configure-x86,
slouken@1636
    39
# make, make-ppc, make-x86, merge
slouken@1636
    40
# install
slouken@1636
    41
if test x"$1" = x; then
slouken@1636
    42
    phase=all
slouken@1636
    43
else
slouken@1636
    44
    phase="$1"
slouken@1636
    45
fi
slouken@1636
    46
case $phase in
slouken@1636
    47
    all)
slouken@1636
    48
        configure_ppc="yes"
slouken@1636
    49
        configure_x86="yes"
slouken@1636
    50
        make_ppc="yes"
slouken@1636
    51
        make_x86="yes"
slouken@1636
    52
        merge="yes"
slouken@1636
    53
        ;;
slouken@1636
    54
    configure)
slouken@1636
    55
        configure_ppc="yes"
slouken@1636
    56
        configure_x86="yes"
slouken@1636
    57
        ;;
slouken@1636
    58
    configure-ppc)
slouken@1636
    59
        configure_ppc="yes"
slouken@1636
    60
        ;;
slouken@1636
    61
    configure-x86)
slouken@1636
    62
        configure_x86="yes"
slouken@1636
    63
        ;;
slouken@1636
    64
    make)
slouken@1636
    65
        make_ppc="yes"
slouken@1636
    66
        make_x86="yes"
slouken@1636
    67
        merge="yes"
slouken@1636
    68
        ;;
slouken@1636
    69
    make-ppc)
slouken@1636
    70
        make_ppc="yes"
slouken@1636
    71
        ;;
slouken@1636
    72
    make-x86)
slouken@1636
    73
        make_x86="yes"
slouken@1636
    74
        ;;
slouken@1636
    75
    merge)
slouken@1636
    76
        merge="yes"
slouken@1636
    77
        ;;
slouken@1636
    78
    install)
slouken@1636
    79
        make_x86="yes"
slouken@1636
    80
        ;;
slouken@1636
    81
esac
slouken@1636
    82
slouken@1636
    83
#
slouken@1636
    84
# Create the build directories
slouken@1636
    85
#
slouken@1636
    86
for dir in build build/ppc build/x86; do
slouken@1636
    87
    if test -d $dir; then
slouken@1636
    88
        :
slouken@1636
    89
    else
slouken@1636
    90
        mkdir $dir || exit 1
slouken@1636
    91
    fi
slouken@1636
    92
done
slouken@1636
    93
slouken@1636
    94
#
slouken@1636
    95
# Build the PowerPC binary
slouken@1636
    96
#
slouken@1636
    97
if test x$configure_ppc = xyes; then
slouken@1636
    98
    (cd build/ppc && \
slouken@1636
    99
     sh ../../configure CFLAGS="$CFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
slouken@1636
   100
fi
slouken@1636
   101
if test x$make_ppc = xyes; then
slouken@1636
   102
    (cd build/ppc && make) || exit 3
slouken@1636
   103
fi
slouken@1636
   104
slouken@1636
   105
#
slouken@1636
   106
# Build the Intel binary
slouken@1636
   107
#
slouken@1636
   108
if test x$configure_x86 = xyes; then
slouken@1636
   109
    (cd build/x86 && \
slouken@1636
   110
     sh ../../configure CFLAGS="$CFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
slouken@1636
   111
fi
slouken@1636
   112
if test x$make_x86 = xyes; then
slouken@1636
   113
    (cd build/x86 && make) || exit 3
slouken@1636
   114
fi
slouken@1636
   115
slouken@1636
   116
#
slouken@1636
   117
# Combine into fat binary
slouken@1636
   118
#
slouken@1646
   119
target=`find x86 -type f -name '*.dylib' | sed 's|.*/||'`
slouken@1636
   120
if test x$merge = xyes; then
slouken@1636
   121
    (cd build && \
slouken@1646
   122
     lipo -create -o $target `find ppc x86 -type f -name "*.dylib"` &&
slouken@1646
   123
     ln -s $target libSDL-1.2.0.dylib
slouken@1646
   124
     ln -s $target libSDL.dylib
slouken@1636
   125
     lipo -create -o SDLMain.o */build/SDLMain.o &&
slouken@1636
   126
     ar cru libSDLmain.a SDLMain.o && ranlib libSDLmain.a &&
slouken@1636
   127
     echo "Build complete!" &&
slouken@1636
   128
     echo "Files can be found in the build directory.") || exit 4
slouken@1636
   129
fi
slouken@1636
   130
slouken@1636
   131
#
slouken@1636
   132
# Install
slouken@1636
   133
#
slouken@1636
   134
if test x$install = xyes; then
slouken@1636
   135
    echo "Install not implemented"
slouken@1636
   136
    exit 1
slouken@1636
   137
fi