-DIR="bld-ppc"
-
-export CXX="g++-3.3 -arch ppc"
-export CC="gcc-3.3 -arch ppc"
-mkdir -p $DIR
-cd $DIR
-do_build
-cd ..
-
-# Do another build, but with i386 this time
-DIR="bld-i386"
-
-export CXX="g++-4.0 -arch i386"
-export CC="gcc-4.0 -arch i386"
-mkdir -p $DIR
-cd $DIR
-do_build
-cd ..
-
-# Copy over everything, then remove files we need to replace with lipo'd versions
-mkdir -p bld
-cp -R bld-i386/* bld
-cp -R bld-i386/.pch bld/.pch
-rm bld/lib/*.dylib
-
-# lipo the files, but make sure not to run it on symbolic links
-for item in `cd bld-i386/lib; ls *.dylib`
-do
- if [ -f bld-i386/lib/$item -a ! -L bld-i386/lib/$item ]; then
- lipo -create bld-i386/lib/$item bld-ppc/lib/$item -output bld/lib/$item
- else
- cp -R bld-i386/lib/$item bld/lib
- fi
-done
-
-# make install hacks - the copy operations mess up the timestamps and thus
-# cause make to erroneously think that the libraries need rebuilt
-touch bld/.pch/wxprec_monodll/wx/*.gch
-touch bld/.pch/wxprec_gldll/wx/*.gch
-touch bld/*.o
-touch bld/lib/*
-
-# one more hack - inplace wx-config has a hardcoded path in it - we need to
-# change that path from bld-i386 to just bld in case someone wants to build things
-# in tree. (wxPython does this, for example)
-python -c "import os; fname = os.path.abspath('bld/wx-config'); data = open(fname).read(); data = data.replace('bld-i386', 'bld'); open(fname, 'w').write(data)"
-
-cd bld
-make prefix=$INSTALLDIR install
-
+OTHER_OPTS="$OTHER_OPTS --disable-precomp-headers"
+
+do_lipo_build(){
+ DIR="bld-$1"
+
+ if [ "$1" = "ppc" ]; then
+ export CXX="g++-3.3 -arch ppc -DMAC_OS_X_VERSION_MAX_ALLOWED=1040"
+ export CC="gcc-3.3 -arch ppc -DMAC_OS_X_VERSION_MAX_ALLOWED=1040"
+ export MACOSX_DEPLOYMENT_TARGET=10.3
+ else
+ export CXX="g++-4.0 -arch i386"
+ export CC="gcc-4.0 -arch i386"
+ export MACOSX_DEPLOYMENT_TARGET=10.4
+ fi
+
+ mkdir -p $DIR
+ cd $DIR
+ do_build
+
+ mkdir -p $INSTALLDIR/$1
+
+ make prefix=$INSTALLDIR/$1 install
+
+ if [ "$WXPYTHON" == "1" ]; then
+ make -C contrib/src/gizmos prefix=$INSTALLDIR/$1 install
+ make -C contrib/src/stc prefix=$INSTALLDIR/$1 install
+ fi
+
+ cd ..
+}
+
+do_lipo_build "ppc"
+do_lipo_build "i386"
+
+python $WXROOT/distrib/scripts/mac/lipo-dir.py $INSTALLDIR/ppc $INSTALLDIR/i386 $INSTALLDIR
+
+rm -rf $INSTALLDIR/ppc $INSTALLDIR/i386
+python -c "import os; fname = os.path.abspath('$INSTALLDIR/bin/wx-config'); data = open(fname).read(); data = data.replace('ppc/', ''); open(fname, 'w').write(data)"
+
+if [ $? != 0 ]; then
+ exit $?
+fi