Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision 3f7efa7930a7ab0f0a408f73de2493e707d7ac6a)
+++ tools/toolchain.sh	(revision 66a54cca9f5cd9c1ecc9a96ea5ec1ab1c05590e5)
@@ -52,4 +52,13 @@
 #endif
 EOF
+
+BINUTILS_VERSION="2.21"
+GCC_VERSION="4.6.0"
+
+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"
 
 #
@@ -139,8 +148,9 @@
 	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 will be used by default."
+	echo "defined, /usr/local/cross will be used by default."
 	echo
 	
@@ -194,5 +204,5 @@
 }
 
-download_check() {
+download_fetch() {
 	SOURCE="$1"
 	FILE="$2"
@@ -208,4 +218,15 @@
 }
 
+source_check() {
+	FILE="$1"
+	
+	if [ ! -f "${FILE}" ]; then
+		echo
+		echo "File ${FILE} not found."
+		
+		exit 4
+	fi
+}
+
 cleanup_dir() {
 	DIR="$1"
@@ -241,25 +262,16 @@
 }
 
-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
+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}/"
+	
+	download_fetch "${BINUTILS_SOURCE}" "${BINUTILS}" "c84c5acc9d266f1a7044b51c85a823f5"
+	download_fetch "${GCC_SOURCE}" "${GCC_CORE}" "b1957f3209080b2f55bc3756d3a62b7c"
+	download_fetch "${GCC_SOURCE}" "${GCC_OBJC}" "120d4675366ee82ea52f9ed65b57da04"
+	download_fetch "${GCC_SOURCE}" "${GCC_CPP}" "a30090fa655d0db4c970740d353c81f1"
 }
 
@@ -268,16 +280,5 @@
 	TARGET="$2"
 	
-	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`"
+	WORKDIR="${BASEDIR}/${PLATFORM}"
 	BINUTILSDIR="${WORKDIR}/binutils-${BINUTILS_VERSION}"
 	GCCDIR="${WORKDIR}/gcc-${GCC_VERSION}"
@@ -285,5 +286,5 @@
 	
 	if [ -z "${CROSS_PREFIX}" ] ; then
-		CROSS_PREFIX="/usr/local"
+		CROSS_PREFIX="/usr/local/cross"
 	fi
 	
@@ -291,14 +292,12 @@
 	
 	echo ">>> Downloading tarballs"
-	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"
+	source_check "${BASEDIR}/${BINUTILS}"
+	source_check "${BASEDIR}/${GCC_CORE}"
+	source_check "${BASEDIR}/${GCC_OBJC}"
+	source_check "${BASEDIR}/${GCC_CPP}"
 	
 	echo ">>> Removing previous content"
 	cleanup_dir "${PREFIX}"
-	cleanup_dir "${OBJDIR}"
-	cleanup_dir "${BINUTILSDIR}"
-	cleanup_dir "${GCCDIR}"
+	cleanup_dir "${WORKDIR}"
 	
 	create_dir "${PREFIX}" "destination directory"
@@ -306,13 +305,15 @@
 	
 	echo ">>> Unpacking tarballs"
-	unpack_tarball "${BINUTILS}" "binutils"
-	unpack_tarball "${GCC_CORE}" "GCC Core"
-	unpack_tarball "${GCC_OBJC}" "Objective C"
-	unpack_tarball "${GCC_CPP}" "C++"
+	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++"
 	
 	echo ">>> Processing binutils (${PLATFORM})"
 	cd "${BINUTILSDIR}"
 	check_error $? "Change directory failed."
-	patch_binutils "${PLATFORM}"
 	
 	change_title "binutils: configure (${PLATFORM})"
@@ -336,11 +337,9 @@
 	check_error $? "Error compiling/installing GCC."
 	
-	cd "${WORKDIR}"
+	cd "${BASEDIR}"
 	check_error $? "Change directory failed."
 	
 	echo ">>> Cleaning up"
-	cleanup_dir "${OBJDIR}"
-	cleanup_dir "${BINUTILSDIR}"
-	cleanup_dir "${GCCDIR}"
+	cleanup_dir "${WORKDIR}"
 	
 	echo
@@ -352,47 +351,50 @@
 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"
@@ -403,4 +405,18 @@
 		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
