build-scripts/fatbuild.sh
author Sam Lantinga <slouken@libsdl.org>
Fri, 14 Apr 2006 05:43:04 +0000
changeset 1636 3d0dec74ad01
child 1639 0f466fb614a9
permissions -rwxr-xr-x
A script to build a fat version of the SDL library... completely untested!
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@1636
     6
CFLAGS_PPC=-DBUILD_PPC
slouken@1636
     7
xCFLAGS_PPC="-arch ppc \
slouken@1636
     8
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@1636
     9
-I/Developer/SDKs/MacOSX10.2.8.sdk/Developer/Headers/FlatCarbon \
slouken@1636
    10
-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
slouken@1636
    11
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
slouken@1636
    12
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++ \
slouken@1636
    13
-I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin \
slouken@1636
    14
-isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
slouken@1636
    15
slouken@1636
    16
# PowerPC linker flags 
slouken@1636
    17
xLFLAGS_PPC="-arch ppc -mmacosx-version-min=10.2 \
slouken@1636
    18
-L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
slouken@1636
    19
-F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
slouken@1636
    20
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
slouken@1636
    21
slouken@1636
    22
# Intel compiler flags (10.4 runtime compatibility)
slouken@1636
    23
CFLAGS_X86=-DBUILD_X86
slouken@1636
    24
xCFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
slouken@1636
    25
-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
slouken@1636
    26
slouken@1636
    27
# Intel linker flags
slouken@1636
    28
xLFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
slouken@1636
    29
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.0 \
slouken@1636
    30
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
slouken@1636
    31
slouken@1636
    32
#
slouken@1636
    33
# Find the configure script
slouken@1636
    34
#
slouken@1636
    35
cd `dirname $0`/..
slouken@1636
    36
slouken@1636
    37
#
slouken@1636
    38
# Figure out which phase to build:
slouken@1636
    39
# all,
slouken@1636
    40
# configure, configure-ppc, configure-x86,
slouken@1636
    41
# make, make-ppc, make-x86, merge
slouken@1636
    42
# install
slouken@1636
    43
if test x"$1" = x; then
slouken@1636
    44
    phase=all
slouken@1636
    45
else
slouken@1636
    46
    phase="$1"
slouken@1636
    47
fi
slouken@1636
    48
case $phase in
slouken@1636
    49
    all)
slouken@1636
    50
        configure_ppc="yes"
slouken@1636
    51
        configure_x86="yes"
slouken@1636
    52
        make_ppc="yes"
slouken@1636
    53
        make_x86="yes"
slouken@1636
    54
        merge="yes"
slouken@1636
    55
        ;;
slouken@1636
    56
    configure)
slouken@1636
    57
        configure_ppc="yes"
slouken@1636
    58
        configure_x86="yes"
slouken@1636
    59
        ;;
slouken@1636
    60
    configure-ppc)
slouken@1636
    61
        configure_ppc="yes"
slouken@1636
    62
        ;;
slouken@1636
    63
    configure-x86)
slouken@1636
    64
        configure_x86="yes"
slouken@1636
    65
        ;;
slouken@1636
    66
    make)
slouken@1636
    67
        make_ppc="yes"
slouken@1636
    68
        make_x86="yes"
slouken@1636
    69
        merge="yes"
slouken@1636
    70
        ;;
slouken@1636
    71
    make-ppc)
slouken@1636
    72
        make_ppc="yes"
slouken@1636
    73
        ;;
slouken@1636
    74
    make-x86)
slouken@1636
    75
        make_x86="yes"
slouken@1636
    76
        ;;
slouken@1636
    77
    merge)
slouken@1636
    78
        merge="yes"
slouken@1636
    79
        ;;
slouken@1636
    80
    install)
slouken@1636
    81
        make_x86="yes"
slouken@1636
    82
        ;;
slouken@1636
    83
esac
slouken@1636
    84
slouken@1636
    85
#
slouken@1636
    86
# Create the build directories
slouken@1636
    87
#
slouken@1636
    88
for dir in build build/ppc build/x86; do
slouken@1636
    89
    if test -d $dir; then
slouken@1636
    90
        :
slouken@1636
    91
    else
slouken@1636
    92
        mkdir $dir || exit 1
slouken@1636
    93
    fi
slouken@1636
    94
done
slouken@1636
    95
slouken@1636
    96
#
slouken@1636
    97
# Build the PowerPC binary
slouken@1636
    98
#
slouken@1636
    99
if test x$configure_ppc = xyes; then
slouken@1636
   100
    (cd build/ppc && \
slouken@1636
   101
     sh ../../configure CFLAGS="$CFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
slouken@1636
   102
fi
slouken@1636
   103
if test x$make_ppc = xyes; then
slouken@1636
   104
    (cd build/ppc && make) || exit 3
slouken@1636
   105
fi
slouken@1636
   106
slouken@1636
   107
#
slouken@1636
   108
# Build the Intel binary
slouken@1636
   109
#
slouken@1636
   110
if test x$configure_x86 = xyes; then
slouken@1636
   111
    (cd build/x86 && \
slouken@1636
   112
     sh ../../configure CFLAGS="$CFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
slouken@1636
   113
fi
slouken@1636
   114
if test x$make_x86 = xyes; then
slouken@1636
   115
    (cd build/x86 && make) || exit 3
slouken@1636
   116
fi
slouken@1636
   117
slouken@1636
   118
#
slouken@1636
   119
# Combine into fat binary
slouken@1636
   120
#
slouken@1636
   121
target=`echo build/x86/build/.libs/*.dylib | sed 's|.*/||'`
slouken@1636
   122
if test x$merge = xyes; then
slouken@1636
   123
    (cd build && \
slouken@1636
   124
     lipo -create -o $target */build/.libs/*.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