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