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