diff -cr gcc-5664.orig/build_gcc gcc-5664/build_gcc
*** gcc-5664.orig/build_gcc	2009-12-15 22:21:10.000000000 +0000
--- gcc-5664/build_gcc	2010-10-27 19:50:47.392795002 +0100
***************
*** 31,37 ****
  
  # Language front-ends to build. This also affects
  # whether the C++ driver and driver-driver are installed
! LANGUAGES=${LANGUAGES-c,objc,c++,obj-c++}
  
  # The B&I build script (~rc/bin/buildit) accepts an '-othercflags'
  # command-line flag, and captures the argument to that flag in
--- 31,37 ----
  
  # Language front-ends to build. This also affects
  # whether the C++ driver and driver-driver are installed
! LANGUAGES=${LANGUAGES-c,objc,c++,obj-c++,d}
  
  # The B&I build script (~rc/bin/buildit) accepts an '-othercflags'
  # command-line flag, and captures the argument to that flag in
***************
*** 40,47 ****
  
  CFLAGS="-g -O2 ${RC_NONARCH_CFLAGS/-pipe/}"
  
  # This isn't a parameter; it is the architecture of the current machine.
! BUILD=`arch | $TRANSLATE_ARCH`
  
  # The third parameter is the path to the compiler sources.  There should
  # be a shell script named 'configure' in this directory.  This script
--- 40,52 ----
  
  CFLAGS="-g -O2 ${RC_NONARCH_CFLAGS/-pipe/}"
  
+ ARCH="`arch`"
+ if [ "x$ARCH" = "xi386" -a "`sysctl -n hw.cpu64bit_capable`" = "1" ]; then
+   ARCH="x86_64"
+ fi
+ 
  # This isn't a parameter; it is the architecture of the current machine.
! BUILD=`echo $ARCH | $TRANSLATE_ARCH`
  
  # The third parameter is the path to the compiler sources.  There should
  # be a shell script named 'configure' in this directory.  This script
***************
*** 220,226 ****
  # comparable to the native built libraries.
  unset RC_DEBUG_OPTIONS
  make $MAKEFLAGS CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
! make $MAKEFLAGS html CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
  make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$BUILD install-gcc install-target \
    CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
  
--- 220,226 ----
  # comparable to the native built libraries.
  unset RC_DEBUG_OPTIONS
  make $MAKEFLAGS CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
! #make $MAKEFLAGS html CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
  make $MAKEFLAGS DESTDIR=$DIR/dst-$BUILD-$BUILD install-gcc install-target \
    CFLAGS="$CFLAGS" CXXFLAGS="$CFLAGS" || exit 1
  
***************
*** 387,395 ****
  rm -rf * || exit 1
  
  # HTML documentation
! HTMLDIR="/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/documentation/DeveloperTools"
! mkdir -p ".$HTMLDIR" || exit 1
! cp -Rp $DIR/obj-$BUILD-$BUILD/gcc/HTML/* ".$HTMLDIR/" || exit 1
  
  # Manual pages
  mkdir -p .$DEST_ROOT/share || exit 1
--- 387,395 ----
  rm -rf * || exit 1
  
  # HTML documentation
! #HTMLDIR="/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/documentation/DeveloperTools"
! #mkdir -p ".$HTMLDIR" || exit 1
! #cp -Rp $DIR/obj-$BUILD-$BUILD/gcc/HTML/* ".$HTMLDIR/" || exit 1
  
  # Manual pages
  mkdir -p .$DEST_ROOT/share || exit 1
***************
*** 424,430 ****
  # bin
  # The native drivers ('native' is different in different architectures).
  BIN_FILES=`ls $DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin | grep '^[^-]*-[0-9.]*$' \
!   | grep -v gccbug | grep -v gcov || exit 1`
  mkdir .$DEST_ROOT/bin
  for f in $BIN_FILES ; do
    lipo -output .$DEST_ROOT/bin/$f -create $DIR/dst-*$DEST_ROOT/bin/$f || exit 1
--- 424,430 ----
  # bin
  # The native drivers ('native' is different in different architectures).
  BIN_FILES=`ls $DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin | grep '^[^-]*-[0-9.]*$' \
!   | grep -v gccbug | grep -v gcov | grep -v gdmd || exit 1`
  mkdir .$DEST_ROOT/bin
  for f in $BIN_FILES ; do
    lipo -output .$DEST_ROOT/bin/$f -create $DIR/dst-*$DEST_ROOT/bin/$f || exit 1
***************
*** 444,449 ****
--- 444,451 ----
      lipo -output .$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-g++-$VERS -create \
      $DIR/dst-*-$t$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-g++* || exit 1
    fi
+   lipo -output .$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-gdc-$VERS -create \
+   $DIR/dst-*-$t$DEST_ROOT/bin/$t-apple-darwin$DARWIN_VERS-gdc* || exit 1
  done
  
  # lib
***************
*** 521,526 ****
--- 523,564 ----
    fi
  done
  
+ # GDC: Phobos and gdmd
+ if test -e $DIR/dst-$BUILD-$BUILD$DEST_ROOT/include/d2; then
+   phobos_sfx=2;
+ else
+   phobos_sfx='';
+ fi
+ cp -p $DIR/dst-$BUILD-$BUILD$DEST_ROOT/bin/gdmd-* $DEST_DIR$DEST_ROOT/bin
+ cp -pR $DIR/dst-$BUILD-$BUILD$DEST_ROOT/include/d$phobos_sfx $DEST_DIR$DEST_ROOT/include \
+     || exit 1
+ phobos_lib_list=
+ for t in $TARGETS ; do
+   if test $t = $BUILD ; then
+     phobos_lib_dir="$DIR/dst-$BUILD-$t$DEST_ROOT/lib"
+   else
+     cp -pR $DIR/dst-$BUILD-$t$DEST_ROOT/include/d$phobos_sfx/$VERS/$t-apple-darwin$DARWIN_VERS \
+ 	$DEST_DIR$DEST_ROOT/include/d$phobos_sfx/$VERS || exit 1
+     phobos_lib_dir="$DIR/dst-$BUILD-$t$DEST_ROOT/$t-apple-darwin$DARWIN_VERS/lib"
+   fi
+   phobos_lib_list="$phobos_lib_list $phobos_lib_dir/libgphobos$phobos_sfx.a"
+ 
+   # Get 64-bit variants
+   other_libdir=''
+   if test "$t" = i686; then
+     other_libdir="x86_64"
+   elif test "$t" = powerpc; then
+     other_libdir="ppc64"
+   fi
+   if test -n "$other_libdir"; then
+     other_phobos="$phobos_lib_dir/$other_libdir/libgphobos$phobos_sfx.a"
+     if test -r "$other_phobos"; then
+       phobos_lib_list="$phobos_lib_list $other_phobos"
+     fi
+   fi
+ done
+ lipo -output $DEST_DIR$DEST_ROOT/lib/libgphobos$phobos_sfx.a -create $phobos_lib_list || exit 1  
+ 
  # Add extra man page symlinks for 'c++' and for arch-specific names.
  MDIR=$DEST_DIR$DEST_ROOT/share/man/man1
  if [ $BUILD_CXX -eq 1 ]; then
***************
*** 568,573 ****
--- 606,620 ----
              -L$DIR/obj-$h-$BUILD/libiberty/                                        \
  	    -o $DEST_DIR/$DEST_ROOT/bin/tmp-$h-g++-$MAJ_VERS || exit 1
      fi
+     $DIR/dst-$BUILD-$h$DEST_ROOT/bin/$h-apple-darwin$DARWIN_VERS-gcc-$VERS     \
+ 	$ORIG_SRC_DIR/driverdriver.c                               \
+ 	-DPDN="\"-apple-darwin$DARWIN_VERS-gdc-$VERS\""                                    \
+ 	-DIL="\"$DEST_ROOT/bin/\"" -I  $ORIG_SRC_DIR/include                   \
+ 	-I  $ORIG_SRC_DIR/gcc -I  $ORIG_SRC_DIR/gcc/config                     \
+ 	-liberty -L$DIR/dst-$BUILD-$h$DEST_ROOT/lib/                           \
+ 	-L$DIR/dst-$BUILD-$h$DEST_ROOT/$h-apple-darwin$DARWIN_VERS/lib/                    \
+         -L$DIR/obj-$h-$BUILD/libiberty/                                        \
+ 	-o $DEST_DIR/$DEST_ROOT/bin/tmp-$h-gdc-$MAJ_VERS || exit 1
  done
  
  lipo -output $DEST_DIR/$DEST_ROOT/bin/gcc-$MAJ_VERS -create \
***************
*** 587,592 ****
--- 634,652 ----
    rm -rf $DEST_DIR/$DEST_ROOT/lib/gcc/*/*/include/c++
  fi
  
+ lipo -output $DEST_DIR/$DEST_ROOT/bin/gdc-$MAJ_VERS -create \
+   $DEST_DIR/$DEST_ROOT/bin/tmp-*-gdc-$MAJ_VERS || exit 1
+ rm $DEST_DIR/$DEST_ROOT/bin/tmp-*-gdc-$MAJ_VERS || exit 1
+ 
+ # Build rdmd
+ for h in $HOSTS ; do
+   $DEST_DIR$DEST_ROOT/bin/$h-apple-darwin$DARWIN_VERS-gdc-$VERS \
+     $ORIG_SRC_DIR/gcc/d/rdmd.d \
+     -o $DEST_DIR/$DEST_ROOT/bin/tmp-$h-rdmd || exit 1
+ done
+ lipo -output $DEST_DIR/$DEST_ROOT/bin/rdmd -create \
+   $DEST_DIR/$DEST_ROOT/bin/tmp-*-rdmd || exit 1
+ rm $DEST_DIR/$DEST_ROOT/bin/tmp-*-rdmd || exit 1
  
  ########################################
  # Create SYM_DIR with information required for debugging.
