Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision 3666d386ed1501d3270d65703319e19b65b9fd51)
+++ tools/toolchain.sh	(revision 3f7efa7930a7ab0f0a408f73de2493e707d7ac6a)
@@ -52,15 +52,4 @@
 #endif
 EOF
-
-BINUTILS_VERSION="2.21"
-GCC_VERSION="4.6.1"
-GDB_VERSION="7.2"
-
-BASEDIR="`pwd`"
-BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
-GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
-GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
-GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
-GDB="gdb-${GDB_VERSION}.tar.bz2"
 
 #
@@ -150,9 +139,8 @@
 	echo " sparc64    SPARC V9"
 	echo " all        build all targets"
-	echo " parallel   same as 'all', but in parallel"
 	echo
 	echo "The toolchain will be installed to the directory specified by"
 	echo "the CROSS_PREFIX environment variable. If the variable is not"
-	echo "defined, /usr/local/cross will be used by default."
+	echo "defined, /usr/local will be used by default."
 	echo
 	
@@ -206,5 +194,5 @@
 }
 
-download_fetch() {
+download_check() {
 	SOURCE="$1"
 	FILE="$2"
@@ -220,15 +208,4 @@
 }
 
-source_check() {
-	FILE="$1"
-	
-	if [ ! -f "${FILE}" ]; then
-		echo
-		echo "File ${FILE} not found."
-		
-		exit 4
-	fi
-}
-
 cleanup_dir() {
 	DIR="$1"
@@ -264,18 +241,25 @@
 }
 
-prepare() {
-	show_dependencies
-	check_dependecies
-	show_countdown 10
-	
-	BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
-	GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
-	GDB_SOURCE="ftp://ftp.gnu.org/gnu/gdb/"
-	
-	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "c84c5acc9d266f1a7044b51c85a823f5"
-	download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "0c0e7e35d2215e19de9c97efba507553"
-	download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "cbf0d4b701827922cf37ba6a4ace0079"
-	download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "0d75ca7ca35b1e7f252223f9d23a6ad1"
-	download_fetch "${GDB_SOURCE}" "${GDB}" "64260e6c56979ee750a01055f16091a5"
+patch_binutils() {
+	PLATFORM="$1"
+	
+	if [ "${PLATFORM}" == "arm32" ] ; then
+		patch -p1 <<EOF
+diff -Naur binutils-2.20.orig/gas/config/tc-arm.c binutils-2.20/gas/config/tc-arm.c
+--- binutils-2.20.orig/gas/config/tc-arm.c	2009-08-30 00:10:59.000000000 +0200
++++ binutils-2.20/gas/config/tc-arm.c	2009-11-02 14:25:11.000000000 +0100
+@@ -2485,8 +2485,9 @@
+       know (frag->tc_frag_data.first_map == NULL);
+       frag->tc_frag_data.first_map = symbolP;
+     }
+-  if (frag->tc_frag_data.last_map != NULL)
++  if (frag->tc_frag_data.last_map != NULL) {
+     know (S_GET_VALUE (frag->tc_frag_data.last_map) < S_GET_VALUE (symbolP));
++  }
+   frag->tc_frag_data.last_map = symbolP;
+ }
+EOF
+		check_error $? "Error patching binutils"
+	fi
 }
 
@@ -284,12 +268,22 @@
 	TARGET="$2"
 	
-	WORKDIR="${BASEDIR}/${PLATFORM}"
+	BINUTILS_VERSION="2.20"
+	GCC_VERSION="4.5.1"
+	
+	BINUTILS="binutils-${BINUTILS_VERSION}.tar.bz2"
+	GCC_CORE="gcc-core-${GCC_VERSION}.tar.bz2"
+	GCC_OBJC="gcc-objc-${GCC_VERSION}.tar.bz2"
+	GCC_CPP="gcc-g++-${GCC_VERSION}.tar.bz2"
+	
+	BINUTILS_SOURCE="ftp://ftp.gnu.org/gnu/binutils/"
+	GCC_SOURCE="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/"
+	
+	WORKDIR="`pwd`"
 	BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
 	GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
 	OBJDIR="${WORKDIR}/gcc-obj"
-	GDBDIR="${WORKDIR}/gdb-${GDB_VERSION}"
 	
 	if [ -z "${CROSS_PREFIX}" ] ; then
-		CROSS_PREFIX="/usr/local/cross"
+		CROSS_PREFIX="/usr/local"
 	fi
 	
@@ -297,13 +291,14 @@
 	
 	echo ">>> Downloading tarballs"
-	source_check "${BASEDIR}/${BINUTILS}"
-	source_check "${BASEDIR}/${GCC_CORE}"
-	source_check "${BASEDIR}/${GCC_OBJC}"
-	source_check "${BASEDIR}/${GCC_CPP}"
-	source_check "${BASEDIR}/${GDB}"
+	download_check "${BINUTILS_SOURCE}" "${BINUTILS}" "ee2d3e996e9a2d669808713360fa96f8"
+	download_check "${GCC_SOURCE}" "${GCC_CORE}" "dc8959e31b01a65ce10d269614815054"
+	download_check "${GCC_SOURCE}" "${GCC_OBJC}" "3c11b7037896e967eddf8178af2ddd98"
+	download_check "${GCC_SOURCE}" "${GCC_CPP}" "b294953ff0bb2f20c7acb2bf005d832a"
 	
 	echo ">>> Removing previous content"
 	cleanup_dir "${PREFIX}"
-	cleanup_dir "${WORKDIR}"
+	cleanup_dir "${OBJDIR}"
+	cleanup_dir "${BINUTILSDIR}"
+	cleanup_dir "${GCCDIR}"
 	
 	create_dir "${PREFIX}" "destination directory"
@@ -311,19 +306,16 @@
 	
 	echo ">>> Unpacking tarballs"
-	cd "${WORKDIR}"
-	check_error $? "Change directory failed."
-	
-	unpack_tarball "${BASEDIR}/${BINUTILS}" "binutils"
-	unpack_tarball "${BASEDIR}/${GCC_CORE}" "GCC Core"
-	unpack_tarball "${BASEDIR}/${GCC_OBJC}" "Objective C"
-	unpack_tarball "${BASEDIR}/${GCC_CPP}" "C++"
-	unpack_tarball "${BASEDIR}/${GDB}" "GDB"
+	unpack_tarball "${BINUTILS}" "binutils"
+	unpack_tarball "${GCC_CORE}" "GCC Core"
+	unpack_tarball "${GCC_OBJC}" "Objective C"
+	unpack_tarball "${GCC_CPP}" "C++"
 	
 	echo ">>> Processing binutils (${PLATFORM})"
 	cd "${BINUTILSDIR}"
 	check_error $? "Change directory failed."
+	patch_binutils "${PLATFORM}"
 	
 	change_title "binutils: configure (${PLATFORM})"
-	CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls
+	./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls
 	check_error $? "Error configuring binutils."
 	
@@ -344,21 +336,11 @@
 	check_error $? "Error compiling/installing GCC."
 	
-	echo ">>> Processing GDB (${PLATFORM})"
-	cd "${GDBDIR}"
+	cd "${WORKDIR}"
 	check_error $? "Change directory failed."
 	
-	change_title "GDB: configure (${PLATFORM})"
-	./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
-	check_error $? "Error configuring GDB."
-	
-	change_title "GDB: make (${PLATFORM})"
-	make all install
-	check_error $? "Error compiling/installing GDB."
-	
-	cd "${BASEDIR}"
-	check_error $? "Change directory failed."
-	
 	echo ">>> Cleaning up"
-	cleanup_dir "${WORKDIR}"
+	cleanup_dir "${OBJDIR}"
+	cleanup_dir "${BINUTILSDIR}"
+	cleanup_dir "${GCCDIR}"
 	
 	echo
@@ -370,50 +352,47 @@
 fi
 
+show_dependencies
+check_dependecies
+show_countdown 10
+
 case "$1" in
 	"amd64")
-		prepare
 		build_target "amd64" "amd64-linux-gnu"
 		;;
 	"arm32")
-		prepare
 		build_target "arm32" "arm-linux-gnu"
 		;;
 	"ia32")
-		prepare
 		build_target "ia32" "i686-pc-linux-gnu"
 		;;
 	"ia64")
-		prepare
 		build_target "ia64" "ia64-pc-linux-gnu"
 		;;
+	"ia64")
+		build_target "ia64" "ia64-pc-linux-gnu"
+		;;
 	"mips32")
-		prepare
 		build_target "mips32" "mipsel-linux-gnu"
 		;;
 	"mips32eb")
-		prepare
 		build_target "mips32eb" "mips-linux-gnu"
 		;;
 	"mips64")
-		prepare
 		build_target "mips64" "mips64el-linux-gnu"
 		;;
 	"ppc32")
-		prepare
 		build_target "ppc32" "ppc-linux-gnu"
 		;;
 	"ppc64")
-		prepare
 		build_target "ppc64" "ppc64-linux-gnu"
 		;;
 	"sparc64")
-		prepare
 		build_target "sparc64" "sparc64-linux-gnu"
 		;;
 	"all")
-		prepare
 		build_target "amd64" "amd64-linux-gnu"
 		build_target "arm32" "arm-linux-gnu"
 		build_target "ia32" "i686-pc-linux-gnu"
+		build_target "ia64" "ia64-pc-linux-gnu"
 		build_target "ia64" "ia64-pc-linux-gnu"
 		build_target "mips32" "mipsel-linux-gnu"
@@ -424,18 +403,4 @@
 		build_target "sparc64" "sparc64-linux-gnu"
 		;;
-	"parallel")
-		prepare
-		build_target "amd64" "amd64-linux-gnu" &
-		build_target "arm32" "arm-linux-gnu" &
-		build_target "ia32" "i686-pc-linux-gnu" &
-		build_target "ia64" "ia64-pc-linux-gnu" &
-		build_target "mips32" "mipsel-linux-gnu" &
-		build_target "mips32eb" "mips-linux-gnu" &
-		build_target "mips64" "mips64el-linux-gnu" &
-		build_target "ppc32" "ppc-linux-gnu" &
-		build_target "ppc64" "ppc64-linux-gnu" &
-		build_target "sparc64" "sparc64-linux-gnu" &
-		wait
-		;;
 	*)
 		show_usage
