build-scripts/fatbuild.sh
author Holmes Futrell <hfutrell@umail.ucsb.edu>
Fri, 18 Jul 2008 20:46:02 +0000
branchgsoc2008_iphone
changeset 2378 d76ecec0c3f7
parent 2282 ff3b47d22a6d
child 3245 d984d5bb17e9
permissions -rwxr-xr-x
iPhone SDL 1.3 demos go here. All these demos are written using pure SDL 1.3 code. No compatibility calls! Perhaps if they are any good they could be use as tests for the SDL 1.3 release.
slouken@1636
     1
#!/bin/sh
slouken@1636
     2
#
slouken@1636
     3
# Build a fat binary on Mac OS X, thanks Ryan!
slouken@1636
     4
icculus@1741
     5
# Number of CPUs (for make -j)
icculus@1741
     6
NCPU=`sysctl -n hw.ncpu`
slouken@1744
     7
NJOB=$NCPU
slouken@1744
     8
#NJOB=`expr $NCPU + 1`
icculus@1741
     9
icculus@1741
    10
# Generic, cross-platform CFLAGS you always want go here.
icculus@1741
    11
CFLAGS="-O3 -g -pipe"
icculus@1741
    12
slouken@2282
    13
# PowerPC configure flags (10.3 runtime compatibility)
slouken@1799
    14
# We dynamically load X11, so using the system X11 headers is fine.
slouken@1799
    15
CONFIG_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
slouken@1799
    16
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
slouken@1799
    17
slouken@1799
    18
# PowerPC compiler flags
slouken@2282
    19
CC_PPC="gcc-4.0 -arch ppc"
slouken@2282
    20
CXX_PPC="g++-4.0 -arch ppc"
slouken@1739
    21
CFLAGS_PPC=""
slouken@2047
    22
CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1030 \
slouken@1648
    23
-nostdinc \
slouken@2047
    24
-F/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks \
slouken@2282
    25
-I/Developer/SDKs/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1/include \
slouken@2047
    26
-isystem /Developer/SDKs/MacOSX10.3.9.sdk/usr/include"
slouken@1636
    27
slouken@2282
    28
# PowerPC linker flags
slouken@2282
    29
LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.3 \
slouken@2282
    30
-L/Developer/SDKs/MacOSX10.3.9.sdk/usr/lib/gcc/powerpc-apple-darwin9/4.0.1 \
slouken@2047
    31
-F/Developer/SDKs/MacOSX10.3.9.sdk/System/Library/Frameworks \
slouken@2047
    32
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.3.9.sdk"
slouken@1636
    33
slouken@1799
    34
# Intel configure flags (10.4 runtime compatibility)
slouken@1799
    35
# We dynamically load X11, so using the system X11 headers is fine.
slouken@1799
    36
CONFIG_X86="--build=`uname -p`-apple-darwin --host=i386-apple-darwin \
slouken@1799
    37
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
slouken@1799
    38
slouken@1799
    39
# Intel compiler flags
slouken@1739
    40
CC_X86="gcc-4.0 -arch i386"
slouken@1743
    41
CXX_X86="g++-4.0 -arch i386"
slouken@1739
    42
CFLAGS_X86="-mmacosx-version-min=10.4"
slouken@1648
    43
CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
slouken@1742
    44
-nostdinc \
slouken@1648
    45
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
slouken@2282
    46
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1/include \
slouken@1648
    47
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
slouken@1636
    48
slouken@1636
    49
# Intel linker flags
slouken@1639
    50
LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
slouken@2282
    51
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin9/4.0.1 \
slouken@1636
    52
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
slouken@1636
    53
slouken@1636
    54
#
slouken@1636
    55
# Find the configure script
slouken@1636
    56
#
slouken@1648
    57
srcdir=`dirname $0`/..
slouken@1648
    58
auxdir=$srcdir/build-scripts
slouken@1648
    59
cd $srcdir
slouken@1636
    60
slouken@1636
    61
#
slouken@1636
    62
# Figure out which phase to build:
slouken@1636
    63
# all,
slouken@1636
    64
# configure, configure-ppc, configure-x86,
slouken@1636
    65
# make, make-ppc, make-x86, merge
slouken@1636
    66
# install
icculus@1741
    67
# clean
slouken@1636
    68
if test x"$1" = x; then
slouken@1636
    69
    phase=all
slouken@1636
    70
else
slouken@1636
    71
    phase="$1"
slouken@1636
    72
fi
slouken@1636
    73
case $phase in
slouken@1636
    74
    all)
slouken@1636
    75
        configure_ppc="yes"
slouken@1636
    76
        configure_x86="yes"
slouken@1636
    77
        make_ppc="yes"
slouken@1636
    78
        make_x86="yes"
slouken@1636
    79
        merge="yes"
slouken@1636
    80
        ;;
slouken@1636
    81
    configure)
slouken@1636
    82
        configure_ppc="yes"
slouken@1636
    83
        configure_x86="yes"
slouken@1636
    84
        ;;
slouken@1636
    85
    configure-ppc)
slouken@1636
    86
        configure_ppc="yes"
slouken@1636
    87
        ;;
slouken@1636
    88
    configure-x86)
slouken@1636
    89
        configure_x86="yes"
slouken@1636
    90
        ;;
slouken@1636
    91
    make)
slouken@1636
    92
        make_ppc="yes"
slouken@1636
    93
        make_x86="yes"
slouken@1636
    94
        merge="yes"
slouken@1636
    95
        ;;
slouken@1636
    96
    make-ppc)
slouken@1636
    97
        make_ppc="yes"
slouken@1636
    98
        ;;
slouken@1636
    99
    make-x86)
slouken@1636
   100
        make_x86="yes"
slouken@1636
   101
        ;;
slouken@1636
   102
    merge)
slouken@1636
   103
        merge="yes"
slouken@1636
   104
        ;;
slouken@1636
   105
    install)
slouken@1648
   106
        install_bin="yes"
slouken@1648
   107
        install_hdrs="yes"
slouken@1648
   108
        install_lib="yes"
slouken@1648
   109
        install_data="yes"
slouken@1648
   110
        install_man="yes"
slouken@1648
   111
        ;;
slouken@1648
   112
    install-bin)
slouken@1648
   113
        install_bin="yes"
slouken@1648
   114
        ;;
slouken@1648
   115
    install-hdrs)
slouken@1648
   116
        install_hdrs="yes"
slouken@1648
   117
        ;;
slouken@1648
   118
    install-lib)
slouken@1648
   119
        install_lib="yes"
slouken@1648
   120
        ;;
slouken@1648
   121
    install-data)
slouken@1648
   122
        install_data="yes"
slouken@1648
   123
        ;;
slouken@1648
   124
    install-man)
slouken@1648
   125
        install_man="yes"
slouken@1648
   126
        ;;
icculus@1741
   127
    clean)
icculus@1741
   128
        clean_ppc="yes"
icculus@1741
   129
        clean_x86="yes"
icculus@1741
   130
        ;;
icculus@1741
   131
    clean-ppc)
icculus@1741
   132
        clean_ppc="yes"
icculus@1741
   133
        ;;
icculus@1741
   134
    clean-x86)
icculus@1741
   135
        clean_x86="yes"
icculus@1741
   136
        ;;
slouken@1648
   137
    *)
icculus@1741
   138
        echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge|install|clean]"
slouken@1648
   139
        exit 1
slouken@1648
   140
        ;;
slouken@1648
   141
esac
slouken@1648
   142
case `uname -p` in
slouken@1648
   143
    powerpc)
slouken@1648
   144
        native_path=ppc
slouken@1648
   145
        ;;
slouken@1648
   146
    *86)
slouken@1648
   147
        native_path=x86
slouken@1648
   148
        ;;
slouken@1648
   149
    *)
slouken@1648
   150
        echo "Couldn't figure out native architecture path"
slouken@1648
   151
        exit 1
slouken@1636
   152
        ;;
slouken@1636
   153
esac
slouken@1636
   154
slouken@1636
   155
#
slouken@1636
   156
# Create the build directories
slouken@1636
   157
#
slouken@1636
   158
for dir in build build/ppc build/x86; do
slouken@1636
   159
    if test -d $dir; then
slouken@1636
   160
        :
slouken@1636
   161
    else
slouken@1636
   162
        mkdir $dir || exit 1
slouken@1636
   163
    fi
slouken@1636
   164
done
slouken@1636
   165
slouken@1636
   166
#
slouken@1636
   167
# Build the PowerPC binary
slouken@1636
   168
#
slouken@1636
   169
if test x$configure_ppc = xyes; then
slouken@1636
   170
    (cd build/ppc && \
slouken@1799
   171
     sh ../../configure $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
slouken@1636
   172
fi
slouken@1636
   173
if test x$make_ppc = xyes; then
slouken@1742
   174
    (cd build/ppc && ls include && make -j$NJOB) || exit 3
slouken@1636
   175
fi
slouken@1636
   176
slouken@1636
   177
#
slouken@1636
   178
# Build the Intel binary
slouken@1636
   179
#
slouken@1636
   180
if test x$configure_x86 = xyes; then
slouken@1636
   181
    (cd build/x86 && \
slouken@1799
   182
     sh ../../configure $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
slouken@1636
   183
fi
slouken@1636
   184
if test x$make_x86 = xyes; then
slouken@1742
   185
    (cd build/x86 && make -j$NJOB) || exit 3
slouken@1636
   186
fi
slouken@1636
   187
slouken@1636
   188
#
slouken@1636
   189
# Combine into fat binary
slouken@1636
   190
#
slouken@1636
   191
if test x$merge = xyes; then
slouken@1648
   192
    output=.libs
slouken@1648
   193
    sh $auxdir/mkinstalldirs build/$output
slouken@1648
   194
    cd build
slouken@1648
   195
    target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
slouken@1648
   196
    (lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
slouken@1648
   197
     ln -sf $target $output/libSDL-1.2.0.dylib &&
slouken@1648
   198
     ln -sf $target $output/libSDL.dylib &&
slouken@1648
   199
     lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
slouken@1648
   200
     cp $native_path/build/.libs/libSDL.la $output &&
slouken@1648
   201
     cp $native_path/build/.libs/libSDL.lai $output &&
slouken@1648
   202
     cp $native_path/build/libSDL.la . &&
slouken@1648
   203
     lipo -create -o libSDLmain.a */build/libSDLmain.a &&
slouken@1636
   204
     echo "Build complete!" &&
slouken@1636
   205
     echo "Files can be found in the build directory.") || exit 4
slouken@1648
   206
    cd ..
slouken@1636
   207
fi
slouken@1636
   208
slouken@1636
   209
#
slouken@1636
   210
# Install
slouken@1636
   211
#
slouken@1648
   212
do_install()
slouken@1648
   213
{
slouken@1648
   214
    echo $*
slouken@1648
   215
    $* || exit 5
slouken@1648
   216
}
slouken@1648
   217
if test x$prefix = x; then
slouken@1648
   218
    prefix=/usr/local
slouken@1636
   219
fi
slouken@1648
   220
if test x$exec_prefix = x; then
slouken@1648
   221
    exec_prefix=$prefix
slouken@1648
   222
fi
slouken@1648
   223
if test x$bindir = x; then
slouken@1648
   224
    bindir=$exec_prefix/bin
slouken@1648
   225
fi
slouken@1648
   226
if test x$libdir = x; then
slouken@1648
   227
    libdir=$exec_prefix/lib
slouken@1648
   228
fi
slouken@1648
   229
if test x$includedir = x; then
slouken@1648
   230
    includedir=$prefix/include
slouken@1648
   231
fi
slouken@1648
   232
if test x$datadir = x; then
slouken@1648
   233
    datadir=$prefix/share
slouken@1648
   234
fi
slouken@1648
   235
if test x$mandir = x; then
slouken@1648
   236
    mandir=$prefix/man
slouken@1648
   237
fi
slouken@1648
   238
if test x$install_bin = xyes; then
slouken@1648
   239
    do_install sh $auxdir/mkinstalldirs $bindir
slouken@1648
   240
    do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
slouken@1648
   241
fi
slouken@1648
   242
if test x$install_hdrs = xyes; then
slouken@1648
   243
    do_install sh $auxdir/mkinstalldirs $includedir/SDL
slouken@1648
   244
    for src in $srcdir/include/*.h; do \
slouken@1648
   245
        file=`echo $src | sed -e 's|^.*/||'`; \
slouken@1648
   246
        do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
slouken@1648
   247
    done
slouken@1648
   248
    do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
slouken@1648
   249
fi
slouken@1648
   250
if test x$install_lib = xyes; then
slouken@1648
   251
    do_install sh $auxdir/mkinstalldirs $libdir
slouken@1648
   252
    do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c  build/libSDL.la $libdir/libSDL.la
slouken@1648
   253
    do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
slouken@1648
   254
    do_install ranlib $libdir/libSDLmain.a
slouken@1648
   255
fi
slouken@1648
   256
if test x$install_data = xyes; then
slouken@1648
   257
    do_install sh $auxdir/mkinstalldirs $datadir/aclocal
slouken@1648
   258
    do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
slouken@1648
   259
fi
slouken@1648
   260
if test x$install_man = xyes; then
slouken@1648
   261
    do_install sh $auxdir/mkinstalldirs $mandir/man3
slouken@1648
   262
    for src in $srcdir/docs/man3/*.3; do \
slouken@1648
   263
        file=`echo $src | sed -e 's|^.*/||'`; \
slouken@1648
   264
        do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
slouken@1648
   265
    done
slouken@1648
   266
fi
icculus@1741
   267
icculus@1741
   268
#
icculus@1741
   269
# Clean up
icculus@1741
   270
#
icculus@1741
   271
do_clean()
icculus@1741
   272
{
icculus@1741
   273
    echo $*
icculus@1741
   274
    $* || exit 6
icculus@1741
   275
}
icculus@1741
   276
if test x$clean_x86 = xyes; then
icculus@1741
   277
    do_clean rm -r build/x86
icculus@1741
   278
fi
icculus@1741
   279
if test x$clean_ppc = xyes; then
icculus@1741
   280
    do_clean rm -r build/ppc
icculus@1741
   281
fi
icculus@1741
   282