build-scripts/fatbuild.sh
author Ryan C. Gordon <icculus@icculus.org>
Sun, 17 Jan 2010 05:17:59 +0000
branchSDL-1.2
changeset 4396 f5d3f7fa071d
parent 4371 6f74b80cca1d
child 4397 fb1fc6c9289e
permissions -rwxr-xr-x
1.2 pulseaudio: make some function pointers static.
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
icculus@1741
     8
icculus@1741
     9
# Generic, cross-platform CFLAGS you always want go here.
icculus@1741
    10
CFLAGS="-O3 -g -pipe"
icculus@1741
    11
icculus@4396
    12
# PowerPC 32-bit configure flags (10.4 runtime compatibility)
icculus@4396
    13
# We dynamically load X11, so using the system X11 headers is fine.
icculus@4396
    14
CONFIG_PPC="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
slouken@1799
    15
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
slouken@1799
    16
icculus@4396
    17
# PowerPC 32-bit compiler flags
icculus@4396
    18
CC_PPC="gcc-4.0 -arch ppc"
icculus@4396
    19
CXX_PPC="g++-4.0 -arch ppc"
icculus@4396
    20
CFLAGS_PPC="-mmacosx-version-min=10.4"
icculus@4396
    21
CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
slouken@1648
    22
-nostdinc \
icculus@4396
    23
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
icculus@4396
    24
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.0.1/include \
icculus@4396
    25
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
slouken@4116
    26
icculus@4396
    27
# PowerPC 32-bit linker flags
icculus@4396
    28
LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.4 \
icculus@4396
    29
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
icculus@4396
    30
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.0.1 \
icculus@4396
    31
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
slouken@4116
    32
icculus@4396
    33
# PowerPC 64-bit configure flags (10.5 runtime compatibility)
icculus@4396
    34
# We dynamically load X11, so using the system X11 headers is fine.
icculus@4396
    35
CONFIG_PPC64="--build=`uname -p`-apple-darwin --host=powerpc-apple-darwin \
slouken@4116
    36
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
slouken@1636
    37
icculus@4396
    38
# PowerPC 64-bit compiler flags
icculus@4396
    39
CC_PPC64="gcc-4.0 -arch ppc64"
icculus@4396
    40
CXX_PPC64="g++-4.0 -arch ppc64"
icculus@4396
    41
CFLAGS_PPC64="-mmacosx-version-min=10.5"
icculus@4396
    42
CPPFLAGS_PPC64="-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
slouken@4116
    43
-nostdinc \
icculus@4396
    44
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
icculus@4396
    45
-I/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.0.1/include \
icculus@4396
    46
-isystem /Developer/SDKs/MacOSX10.5.sdk/usr/include"
slouken@4116
    47
icculus@4396
    48
# PowerPC 64-bit linker flags
icculus@4396
    49
LFLAGS_PPC64="-arch ppc64 -mmacosx-version-min=10.5 \
icculus@4396
    50
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
icculus@4396
    51
-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/powerpc-apple-darwin10/4.0.1/ppc64 \
icculus@4396
    52
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
slouken@4116
    53
icculus@4396
    54
# Intel 32-bit configure flags (10.4 runtime compatibility)
slouken@1799
    55
# We dynamically load X11, so using the system X11 headers is fine.
slouken@1799
    56
CONFIG_X86="--build=`uname -p`-apple-darwin --host=i386-apple-darwin \
slouken@1799
    57
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
slouken@1799
    58
icculus@4396
    59
# Intel 32-bit configure flags (10.4 runtime compatibility)
icculus@4396
    60
# We dynamically load X11, so using the system X11 headers is fine.
icculus@4396
    61
CONFIG_X86="--build=`uname -p`-apple-darwin --host=i386-apple-darwin \
icculus@4396
    62
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
icculus@4371
    63
icculus@4396
    64
# Intel 32-bit compiler flags
slouken@1739
    65
CC_X86="gcc-4.0 -arch i386"
slouken@1743
    66
CXX_X86="g++-4.0 -arch i386"
slouken@1739
    67
CFLAGS_X86="-mmacosx-version-min=10.4"
slouken@1648
    68
CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
slouken@1742
    69
-nostdinc \
icculus@4396
    70
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
icculus@4396
    71
-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
icculus@4396
    72
-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
icculus@4396
    73
icculus@4396
    74
# Intel 32-bit linker flags
icculus@4396
    75
LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
icculus@4396
    76
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
icculus@4396
    77
-L/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1 \
icculus@4396
    78
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"
icculus@4396
    79
icculus@4396
    80
# Intel 64-bit configure flags (10.5 runtime compatibility)
icculus@4396
    81
# We dynamically load X11, so using the system X11 headers is fine.
icculus@4396
    82
CONFIG_X64="--build=`uname -p`-apple-darwin --host=i386-apple-darwin \
icculus@4396
    83
--x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib"
slouken@1636
    84
icculus@4396
    85
# Intel 64-bit compiler flags
icculus@4396
    86
CC_X64="gcc-4.0 -arch x86_64"
icculus@4396
    87
CXX_X64="g++-4.0 -arch x86_64"
icculus@4396
    88
CFLAGS_X64="-mmacosx-version-min=10.5"
icculus@4396
    89
CPPFLAGS_X64="-DMAC_OS_X_VERSION_MIN_REQUIRED=1050 \
icculus@4396
    90
-nostdinc \
icculus@4396
    91
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
icculus@4396
    92
-I/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/include \
icculus@4396
    93
-isystem /Developer/SDKs/MacOSX10.5.sdk/usr/include"
icculus@4396
    94
icculus@4396
    95
# Intel 64-bit linker flags
icculus@4396
    96
LFLAGS_X64="-arch x86_64 -mmacosx-version-min=10.5 \
icculus@4396
    97
-F/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks \
icculus@4396
    98
-L/Developer/SDKs/MacOSX10.5.sdk/usr/lib/gcc/i686-apple-darwin10/4.0.1/x86_64 \
icculus@4396
    99
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
slouken@1636
   100
slouken@1636
   101
#
slouken@1636
   102
# Find the configure script
slouken@1636
   103
#
slouken@1648
   104
srcdir=`dirname $0`/..
slouken@1648
   105
auxdir=$srcdir/build-scripts
slouken@1648
   106
cd $srcdir
slouken@1636
   107
slouken@1636
   108
#
slouken@1636
   109
# Figure out which phase to build:
slouken@1636
   110
# all,
icculus@4396
   111
# configure, configure-ppc, configure-ppc64, configure-x86, configure-x64
icculus@4396
   112
# make, make-ppc, make-ppc64, make-x86, make-x64, merge
slouken@1636
   113
# install
icculus@1741
   114
# clean
slouken@1636
   115
if test x"$1" = x; then
slouken@1636
   116
    phase=all
slouken@1636
   117
else
slouken@1636
   118
    phase="$1"
slouken@1636
   119
fi
slouken@1636
   120
case $phase in
slouken@1636
   121
    all)
slouken@1636
   122
        configure_ppc="yes"
icculus@4396
   123
        #configure_ppc64="yes"
slouken@1636
   124
        configure_x86="yes"
icculus@4396
   125
        configure_x64="yes"
slouken@1636
   126
        make_ppc="yes"
icculus@4396
   127
        #make_ppc64="yes"
slouken@1636
   128
        make_x86="yes"
icculus@4396
   129
        make_x64="yes"
slouken@1636
   130
        merge="yes"
slouken@1636
   131
        ;;
slouken@1636
   132
    configure)
slouken@1636
   133
        configure_ppc="yes"
icculus@4396
   134
        configure_ppc64="yes"
slouken@1636
   135
        configure_x86="yes"
icculus@4396
   136
        configure_x64="yes"
slouken@1636
   137
        ;;
slouken@1636
   138
    configure-ppc)
slouken@1636
   139
        configure_ppc="yes"
slouken@1636
   140
        ;;
icculus@4396
   141
    configure-ppc64)
icculus@4396
   142
        configure_ppc64="yes"
icculus@4396
   143
        ;;
slouken@1636
   144
    configure-x86)
slouken@1636
   145
        configure_x86="yes"
slouken@1636
   146
        ;;
icculus@4396
   147
    configure-x64)
icculus@4396
   148
        configure_x64="yes"
icculus@4396
   149
        ;;
slouken@1636
   150
    make)
slouken@1636
   151
        make_ppc="yes"
icculus@4396
   152
        make_ppc64="yes"
slouken@1636
   153
        make_x86="yes"
icculus@4396
   154
        make_x64="yes"
slouken@1636
   155
        merge="yes"
slouken@1636
   156
        ;;
slouken@1636
   157
    make-ppc)
slouken@1636
   158
        make_ppc="yes"
slouken@1636
   159
        ;;
icculus@4396
   160
    make-ppc64)
icculus@4396
   161
        make_ppc64="yes"
icculus@4396
   162
        ;;
slouken@1636
   163
    make-x86)
slouken@1636
   164
        make_x86="yes"
slouken@1636
   165
        ;;
icculus@4396
   166
    make-x64)
icculus@4396
   167
        make_x64="yes"
icculus@4396
   168
        ;;
slouken@1636
   169
    merge)
slouken@1636
   170
        merge="yes"
slouken@1636
   171
        ;;
slouken@1636
   172
    install)
slouken@1648
   173
        install_bin="yes"
slouken@1648
   174
        install_hdrs="yes"
slouken@1648
   175
        install_lib="yes"
slouken@1648
   176
        install_data="yes"
slouken@1648
   177
        install_man="yes"
slouken@1648
   178
        ;;
slouken@1648
   179
    install-bin)
slouken@1648
   180
        install_bin="yes"
slouken@1648
   181
        ;;
slouken@1648
   182
    install-hdrs)
slouken@1648
   183
        install_hdrs="yes"
slouken@1648
   184
        ;;
slouken@1648
   185
    install-lib)
slouken@1648
   186
        install_lib="yes"
slouken@1648
   187
        ;;
slouken@1648
   188
    install-data)
slouken@1648
   189
        install_data="yes"
slouken@1648
   190
        ;;
slouken@1648
   191
    install-man)
slouken@1648
   192
        install_man="yes"
slouken@1648
   193
        ;;
icculus@1741
   194
    clean)
icculus@1741
   195
        clean_ppc="yes"
icculus@4396
   196
        clean_ppc64="yes"
icculus@1741
   197
        clean_x86="yes"
icculus@4396
   198
        clean_x64="yes"
icculus@1741
   199
        ;;
icculus@1741
   200
    clean-ppc)
icculus@1741
   201
        clean_ppc="yes"
icculus@1741
   202
        ;;
icculus@4396
   203
    clean-ppc64)
icculus@4396
   204
        clean_ppc64="yes"
icculus@4396
   205
        ;;
icculus@1741
   206
    clean-x86)
icculus@1741
   207
        clean_x86="yes"
icculus@1741
   208
        ;;
icculus@4396
   209
    clean-x64)
icculus@4396
   210
        clean_x64="yes"
icculus@4396
   211
        ;;
slouken@1648
   212
    *)
icculus@4396
   213
        echo "Usage: $0 [all|configure[-ppc|-ppc64|-x86|-x64]|make[-ppc|-ppc64|-x86|-x64]|merge|install|clean[-ppc|-ppc64|-x86|-x64]]"
slouken@1648
   214
        exit 1
slouken@1648
   215
        ;;
slouken@1648
   216
esac
slouken@1648
   217
case `uname -p` in
slouken@1648
   218
    powerpc)
slouken@1648
   219
        native_path=ppc
slouken@1648
   220
        ;;
icculus@4396
   221
    powerpc64)
icculus@4396
   222
        native_path=ppc64
icculus@4396
   223
        ;;
slouken@1648
   224
    *86)
slouken@1648
   225
        native_path=x86
slouken@1648
   226
        ;;
icculus@4396
   227
    x86_64)
icculus@4396
   228
        native_path=x64
icculus@4396
   229
        ;;
slouken@1648
   230
    *)
slouken@1648
   231
        echo "Couldn't figure out native architecture path"
slouken@1648
   232
        exit 1
slouken@1636
   233
        ;;
slouken@1636
   234
esac
slouken@1636
   235
slouken@1636
   236
#
slouken@1636
   237
# Create the build directories
slouken@1636
   238
#
icculus@4396
   239
for dir in build build/ppc build/ppc64 build/x86 build/x64; do
slouken@1636
   240
    if test -d $dir; then
slouken@1636
   241
        :
slouken@1636
   242
    else
slouken@1636
   243
        mkdir $dir || exit 1
slouken@1636
   244
    fi
slouken@1636
   245
done
slouken@1636
   246
slouken@1636
   247
#
icculus@4396
   248
# Build the PowerPC 32-bit binary
slouken@1636
   249
#
slouken@1636
   250
if test x$configure_ppc = xyes; then
slouken@1636
   251
    (cd build/ppc && \
slouken@1799
   252
     sh ../../configure $CONFIG_PPC CC="$CC_PPC" CXX="$CXX_PPC" CFLAGS="$CFLAGS $CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
slouken@1636
   253
fi
slouken@1636
   254
if test x$make_ppc = xyes; then
slouken@1742
   255
    (cd build/ppc && ls include && make -j$NJOB) || exit 3
slouken@1636
   256
fi
slouken@1636
   257
slouken@1636
   258
#
icculus@4396
   259
# Build the PowerPC 64-bit binary
icculus@4396
   260
#
icculus@4396
   261
if test x$configure_ppc64 = xyes; then
icculus@4396
   262
    (cd build/ppc64 && \
icculus@4396
   263
     sh ../../configure $CONFIG_PPC64 CC="$CC_PPC64" CXX="$CXX_PPC64" CFLAGS="$CFLAGS $CFLAGS_PPC64" CPPFLAGS="$CPPFLAGS_PPC64" LDFLAGS="$LFLAGS_PPC64") || exit 2
icculus@4396
   264
fi
icculus@4396
   265
if test x$make_ppc64 = xyes; then
icculus@4396
   266
    (cd build/ppc64 && ls include && make -j$NJOB) || exit 3
icculus@4396
   267
fi
icculus@4396
   268
icculus@4396
   269
#
icculus@4396
   270
# Build the Intel 32-bit binary
slouken@1636
   271
#
slouken@1636
   272
if test x$configure_x86 = xyes; then
slouken@1636
   273
    (cd build/x86 && \
slouken@1799
   274
     sh ../../configure $CONFIG_X86 CC="$CC_X86" CXX="$CXX_X86" CFLAGS="$CFLAGS $CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
slouken@1636
   275
fi
slouken@1636
   276
if test x$make_x86 = xyes; then
slouken@1742
   277
    (cd build/x86 && make -j$NJOB) || exit 3
slouken@1636
   278
fi
slouken@1636
   279
slouken@1636
   280
#
icculus@4396
   281
# Build the Intel 32-bit binary
icculus@4396
   282
#
icculus@4396
   283
if test x$configure_x64 = xyes; then
icculus@4396
   284
    (cd build/x64 && \
icculus@4396
   285
     sh ../../configure $CONFIG_X64 CC="$CC_X64" CXX="$CXX_X64" CFLAGS="$CFLAGS $CFLAGS_X64" CPPFLAGS="$CPPFLAGS_X64" LDFLAGS="$LFLAGS_X64") || exit 2
icculus@4396
   286
fi
icculus@4396
   287
if test x$make_x64 = xyes; then
icculus@4396
   288
    (cd build/x64 && make -j$NJOB) || exit 3
icculus@4396
   289
fi
icculus@4396
   290
icculus@4396
   291
#
slouken@1636
   292
# Combine into fat binary
slouken@1636
   293
#
slouken@1636
   294
if test x$merge = xyes; then
slouken@1648
   295
    output=.libs
slouken@1648
   296
    sh $auxdir/mkinstalldirs build/$output
slouken@1648
   297
    cd build
icculus@4396
   298
    target=`find . -mindepth 4 -maxdepth 4 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
icculus@4396
   299
    (lipo -create -o $output/$target `find . -mindepth 4 -maxdepth 4 -type f -name "*.dylib"` &&
slouken@1648
   300
     ln -sf $target $output/libSDL.dylib &&
slouken@1648
   301
     lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
slouken@1648
   302
     cp $native_path/build/.libs/libSDL.la $output &&
slouken@1648
   303
     cp $native_path/build/.libs/libSDL.lai $output &&
slouken@1648
   304
     cp $native_path/build/libSDL.la . &&
slouken@1648
   305
     lipo -create -o libSDLmain.a */build/libSDLmain.a &&
slouken@1636
   306
     echo "Build complete!" &&
slouken@1636
   307
     echo "Files can be found in the build directory.") || exit 4
slouken@1648
   308
    cd ..
slouken@1636
   309
fi
slouken@1636
   310
slouken@1636
   311
#
slouken@1636
   312
# Install
slouken@1636
   313
#
slouken@1648
   314
do_install()
slouken@1648
   315
{
slouken@1648
   316
    echo $*
slouken@1648
   317
    $* || exit 5
slouken@1648
   318
}
slouken@1648
   319
if test x$prefix = x; then
slouken@1648
   320
    prefix=/usr/local
slouken@1648
   321
fi
slouken@1648
   322
if test x$exec_prefix = x; then
slouken@1648
   323
    exec_prefix=$prefix
slouken@1648
   324
fi
slouken@1648
   325
if test x$bindir = x; then
slouken@1648
   326
    bindir=$exec_prefix/bin
slouken@1648
   327
fi
slouken@1648
   328
if test x$libdir = x; then
slouken@1648
   329
    libdir=$exec_prefix/lib
slouken@1648
   330
fi
slouken@1648
   331
if test x$includedir = x; then
slouken@1648
   332
    includedir=$prefix/include
slouken@1648
   333
fi
slouken@1648
   334
if test x$datadir = x; then
slouken@1648
   335
    datadir=$prefix/share
slouken@1648
   336
fi
slouken@1648
   337
if test x$mandir = x; then
slouken@1648
   338
    mandir=$prefix/man
slouken@1636
   339
fi
slouken@1648
   340
if test x$install_bin = xyes; then
slouken@1648
   341
    do_install sh $auxdir/mkinstalldirs $bindir
slouken@1648
   342
    do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
slouken@1648
   343
fi
slouken@1648
   344
if test x$install_hdrs = xyes; then
slouken@1648
   345
    do_install sh $auxdir/mkinstalldirs $includedir/SDL
slouken@1648
   346
    for src in $srcdir/include/*.h; do \
slouken@1648
   347
        file=`echo $src | sed -e 's|^.*/||'`; \
slouken@1648
   348
        do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
slouken@1648
   349
    done
slouken@1648
   350
    do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
slouken@1648
   351
fi
slouken@1648
   352
if test x$install_lib = xyes; then
slouken@1648
   353
    do_install sh $auxdir/mkinstalldirs $libdir
slouken@1648
   354
    do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c  build/libSDL.la $libdir/libSDL.la
slouken@1648
   355
    do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
slouken@1648
   356
    do_install ranlib $libdir/libSDLmain.a
slouken@1648
   357
fi
slouken@1648
   358
if test x$install_data = xyes; then
slouken@1648
   359
    do_install sh $auxdir/mkinstalldirs $datadir/aclocal
slouken@1648
   360
    do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
slouken@1648
   361
fi
slouken@1648
   362
if test x$install_man = xyes; then
slouken@1648
   363
    do_install sh $auxdir/mkinstalldirs $mandir/man3
slouken@1648
   364
    for src in $srcdir/docs/man3/*.3; do \
slouken@1648
   365
        file=`echo $src | sed -e 's|^.*/||'`; \
slouken@1648
   366
        do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
slouken@1648
   367
    done
slouken@1648
   368
fi
icculus@1741
   369
icculus@1741
   370
#
icculus@1741
   371
# Clean up
icculus@1741
   372
#
icculus@1741
   373
do_clean()
icculus@1741
   374
{
icculus@1741
   375
    echo $*
icculus@1741
   376
    $* || exit 6
icculus@1741
   377
}
icculus@1741
   378
if test x$clean_x86 = xyes; then
icculus@1741
   379
    do_clean rm -r build/x86
icculus@1741
   380
fi
icculus@1741
   381
if test x$clean_ppc = xyes; then
icculus@1741
   382
    do_clean rm -r build/ppc
icculus@1741
   383
fi
icculus@1741
   384