build-scripts/fatbuild.sh
changeset 1648 9f59d4c5aaea
parent 1646 7c53bb4b1db4
child 1657 5b0805ceb50f
child 1739 3a3e847aadb9
     1.1 --- a/build-scripts/fatbuild.sh	Thu Apr 20 16:33:51 2006 +0000
     1.2 +++ b/build-scripts/fatbuild.sh	Sat Apr 22 19:17:14 2006 +0000
     1.3 @@ -3,24 +3,28 @@
     1.4  # Build a fat binary on Mac OS X, thanks Ryan!
     1.5  
     1.6  # PowerPC compiler flags (10.2 runtime compatibility)
     1.7 -CFLAGS_PPC="-arch ppc \
     1.8 +CC_PPC="gcc-3.3"
     1.9 +CFLAGS_PPC="-arch ppc"
    1.10 +CPPFLAGS_PPC="-DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
    1.11 +-nostdinc \
    1.12  -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
    1.13 --I/Developer/SDKs/MacOSX10.2.8.sdk/Developer/Headers/FlatCarbon \
    1.14 --DMAC_OS_X_VERSION_MIN_REQUIRED=1020 \
    1.15  -I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3 \
    1.16 --I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++ \
    1.17 --I/Developer/SDKs/MacOSX10.2.8.sdk/usr/include/gcc/darwin/3.3/c++/ppc-darwin \
    1.18  -isystem /Developer/SDKs/MacOSX10.2.8.sdk/usr/include"
    1.19  
    1.20  # PowerPC linker flags 
    1.21 -LFLAGS_PPC="-arch ppc -mmacosx-version-min=10.2 \
    1.22 +LFLAGS_PPC="-arch ppc \
    1.23  -L/Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3 \
    1.24  -F/Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks \
    1.25  -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk"
    1.26  
    1.27  # Intel compiler flags (10.4 runtime compatibility)
    1.28 -CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
    1.29 --DMAC_OS_X_VERSION_MIN_REQUIRED=1040 -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
    1.30 +CC_X86="gcc-4.0"
    1.31 +CFLAGS_X86="-arch i386 -mmacosx-version-min=10.4"
    1.32 +CPPFLAGS_X86="-DMAC_OS_X_VERSION_MIN_REQUIRED=1040 \
    1.33 +-nostdinc \
    1.34 +-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks \
    1.35 +-I/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/gcc/i686-apple-darwin8/4.0.1/include \
    1.36 +-isystem /Developer/SDKs/MacOSX10.4u.sdk/usr/include"
    1.37  
    1.38  # Intel linker flags
    1.39  LFLAGS_X86="-arch i386 -mmacosx-version-min=10.4 \
    1.40 @@ -30,7 +34,9 @@
    1.41  #
    1.42  # Find the configure script
    1.43  #
    1.44 -cd `dirname $0`/..
    1.45 +srcdir=`dirname $0`/..
    1.46 +auxdir=$srcdir/build-scripts
    1.47 +cd $srcdir
    1.48  
    1.49  #
    1.50  # Figure out which phase to build:
    1.51 @@ -76,7 +82,42 @@
    1.52          merge="yes"
    1.53          ;;
    1.54      install)
    1.55 -        make_x86="yes"
    1.56 +        install_bin="yes"
    1.57 +        install_hdrs="yes"
    1.58 +        install_lib="yes"
    1.59 +        install_data="yes"
    1.60 +        install_man="yes"
    1.61 +        ;;
    1.62 +    install-bin)
    1.63 +        install_bin="yes"
    1.64 +        ;;
    1.65 +    install-hdrs)
    1.66 +        install_hdrs="yes"
    1.67 +        ;;
    1.68 +    install-lib)
    1.69 +        install_lib="yes"
    1.70 +        ;;
    1.71 +    install-data)
    1.72 +        install_data="yes"
    1.73 +        ;;
    1.74 +    install-man)
    1.75 +        install_man="yes"
    1.76 +        ;;
    1.77 +    *)
    1.78 +        echo "Usage: $0 [all|configure[-ppc|-x86]|make[-ppc|-x86]|merge]"
    1.79 +        exit 1
    1.80 +        ;;
    1.81 +esac
    1.82 +case `uname -p` in
    1.83 +    powerpc)
    1.84 +        native_path=ppc
    1.85 +        ;;
    1.86 +    *86)
    1.87 +        native_path=x86
    1.88 +        ;;
    1.89 +    *)
    1.90 +        echo "Couldn't figure out native architecture path"
    1.91 +        exit 1
    1.92          ;;
    1.93  esac
    1.94  
    1.95 @@ -96,7 +137,7 @@
    1.96  #
    1.97  if test x$configure_ppc = xyes; then
    1.98      (cd build/ppc && \
    1.99 -     sh ../../configure CFLAGS="$CFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
   1.100 +     sh ../../configure --build=`uname -p`-apple-darwin --host=powerpc-apple-darwin CC="$CC_PPC" CFLAGS="$CFLAGS_PPC" CPPFLAGS="$CPPFLAGS_PPC" LDFLAGS="$LFLAGS_PPC") || exit 2
   1.101  fi
   1.102  if test x$make_ppc = xyes; then
   1.103      (cd build/ppc && make) || exit 3
   1.104 @@ -107,7 +148,7 @@
   1.105  #
   1.106  if test x$configure_x86 = xyes; then
   1.107      (cd build/x86 && \
   1.108 -     sh ../../configure CFLAGS="$CFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
   1.109 +     sh ../../configure --build=`uname -p`-apple-darwin --host=i686-apple-darwin CC="$CC_X86" CFLAGS="$CFLAGS_X86" CPPFLAGS="$CPPFLAGS_X86" LDFLAGS="$LFLAGS_X86") || exit 2
   1.110  fi
   1.111  if test x$make_x86 = xyes; then
   1.112      (cd build/x86 && make) || exit 3
   1.113 @@ -116,22 +157,79 @@
   1.114  #
   1.115  # Combine into fat binary
   1.116  #
   1.117 -target=`find x86 -type f -name '*.dylib' | sed 's|.*/||'`
   1.118  if test x$merge = xyes; then
   1.119 -    (cd build && \
   1.120 -     lipo -create -o $target `find ppc x86 -type f -name "*.dylib"` &&
   1.121 -     ln -s $target libSDL-1.2.0.dylib
   1.122 -     ln -s $target libSDL.dylib
   1.123 -     lipo -create -o SDLMain.o */build/SDLMain.o &&
   1.124 -     ar cru libSDLmain.a SDLMain.o && ranlib libSDLmain.a &&
   1.125 +    output=.libs
   1.126 +    sh $auxdir/mkinstalldirs build/$output
   1.127 +    cd build
   1.128 +    target=`find . -mindepth 3 -type f -name '*.dylib' | head -1 | sed 's|.*/||'`
   1.129 +    (lipo -create -o $output/$target `find . -mindepth 3 -type f -name "*.dylib"` &&
   1.130 +     ln -sf $target $output/libSDL-1.2.0.dylib &&
   1.131 +     ln -sf $target $output/libSDL.dylib &&
   1.132 +     lipo -create -o $output/libSDL.a */build/.libs/libSDL.a &&
   1.133 +     cp $native_path/build/.libs/libSDL.la $output &&
   1.134 +     cp $native_path/build/.libs/libSDL.lai $output &&
   1.135 +     cp $native_path/build/libSDL.la . &&
   1.136 +     lipo -create -o libSDLmain.a */build/libSDLmain.a &&
   1.137       echo "Build complete!" &&
   1.138       echo "Files can be found in the build directory.") || exit 4
   1.139 +    cd ..
   1.140  fi
   1.141  
   1.142  #
   1.143  # Install
   1.144  #
   1.145 -if test x$install = xyes; then
   1.146 -    echo "Install not implemented"
   1.147 -    exit 1
   1.148 +do_install()
   1.149 +{
   1.150 +    echo $*
   1.151 +    $* || exit 5
   1.152 +}
   1.153 +if test x$prefix = x; then
   1.154 +    prefix=/usr/local
   1.155  fi
   1.156 +if test x$exec_prefix = x; then
   1.157 +    exec_prefix=$prefix
   1.158 +fi
   1.159 +if test x$bindir = x; then
   1.160 +    bindir=$exec_prefix/bin
   1.161 +fi
   1.162 +if test x$libdir = x; then
   1.163 +    libdir=$exec_prefix/lib
   1.164 +fi
   1.165 +if test x$includedir = x; then
   1.166 +    includedir=$prefix/include
   1.167 +fi
   1.168 +if test x$datadir = x; then
   1.169 +    datadir=$prefix/share
   1.170 +fi
   1.171 +if test x$mandir = x; then
   1.172 +    mandir=$prefix/man
   1.173 +fi
   1.174 +if test x$install_bin = xyes; then
   1.175 +    do_install sh $auxdir/mkinstalldirs $bindir
   1.176 +    do_install /usr/bin/install -c -m 755 build/$native_path/sdl-config $bindir/sdl-config
   1.177 +fi
   1.178 +if test x$install_hdrs = xyes; then
   1.179 +    do_install sh $auxdir/mkinstalldirs $includedir/SDL
   1.180 +    for src in $srcdir/include/*.h; do \
   1.181 +        file=`echo $src | sed -e 's|^.*/||'`; \
   1.182 +        do_install /usr/bin/install -c -m 644 $src $includedir/SDL/$file; \
   1.183 +    done
   1.184 +    do_install /usr/bin/install -c -m 644 $srcdir/include/SDL_config_macosx.h $includedir/SDL/SDL_config.h
   1.185 +fi
   1.186 +if test x$install_lib = xyes; then
   1.187 +    do_install sh $auxdir/mkinstalldirs $libdir
   1.188 +    do_install sh build/$native_path/libtool --mode=install /usr/bin/install -c  build/libSDL.la $libdir/libSDL.la
   1.189 +    do_install /usr/bin/install -c -m 644 build/libSDLmain.a $libdir/libSDLmain.a
   1.190 +    do_install ranlib $libdir/libSDLmain.a
   1.191 +fi
   1.192 +if test x$install_data = xyes; then
   1.193 +    do_install sh $auxdir/mkinstalldirs $datadir/aclocal
   1.194 +    do_install /usr/bin/install -c -m 644 $srcdir/sdl.m4 $datadir/aclocal/sdl.m4
   1.195 +fi
   1.196 +if test x$install_man = xyes; then
   1.197 +    do_install sh $auxdir/mkinstalldirs $mandir/man3
   1.198 +    for src in $srcdir/docs/man3/*.3; do \
   1.199 +        file=`echo $src | sed -e 's|^.*/||'`; \
   1.200 +        do_install /usr/bin/install -c -m 644 $src $mandir/man3/$file; \
   1.201 +    done
   1.202 +fi