#!/bin/bash

WORKDIR=`pwd`/work
SRCDIR=`pwd`/src
DESTROOT=`pwd`/destroot
SETUP_GCC_ARGS="--d-language-version=1"

if [ ! -d $SRCDIR ]; then
	mkdir $SRCDIR
fi

if [ ! -d $SRCDIR/dgcc ]; then
	svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk $SRCDIR/dgcc
else
	svn up $SRCDIR/dgcc
fi

if [ ! -f $SRCDIR/gcc-5465.tar.gz ]; then
 	curl http://www.opensource.apple.com/darwinsource/tarballs/other/gcc-5465.tar.gz > $SRCDIR/gcc-5465.tar.gz
fi

rm -rf $WORKDIR 
rm -rf $DESTROOT
mkdir -p $WORKDIR 
mkdir -p $DESTROOT
pushd $WORKDIR

tar xfz $SRCDIR/gcc-5465.tar.gz
cp -r $SRCDIR/dgcc/d $WORKDIR/gcc-5465/gcc 

pushd $WORKDIR/gcc-5465
./gcc/d/setup-gcc.sh
popd

$WORKDIR/gcc-5465/configure \
	--prefix=$DESTROOT \
	--enable-languages=c,d \
	--with-system-zlib \
	--disable-nls \
	--disable-multilib
	# --disable-checking \
	# -enable-werror \
	# --prefix=/usr --mandir=/share/man 
	# --enable-languages=c,c++,d \
	# --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ \
	# --with-gxx-include-dir=/include/c++/4.0.0 \
	# --with-slibdir=/usr/lib 
	# --build=i686-apple-darwin9 \
	# --with-arch=nocona \
	# --with-tune=generic \
	# --host=i686-apple-darwin9 \
	# --target=i686-apple-darwin9 \

	
make && make install

popd





