Index: tools/toolchain.sh
===================================================================
--- tools/toolchain.sh	(revision cdc8a39124d8fd8674ce793822f2622b0c811c64)
+++ tools/toolchain.sh	(revision 322ac35ce567118aec7f9c14409afc6f40ebcfb6)
@@ -62,4 +62,7 @@
 GCC="gcc-${GCC_VERSION}.tar.bz2"
 GDB="gdb-${GDB_VERSION}.tar.bz2"
+
+REAL_INSTALL=true
+INSTALL_DIR="${BASEDIR}/PKG"
 
 #
@@ -135,5 +138,5 @@
 	echo
 	echo "Syntax:"
-	echo " $0 <platform>"
+	echo " $0 [--no-install] <platform>"
 	echo
 	echo "Possible target platforms are:"
@@ -152,7 +155,12 @@
 	echo " 2-way      same as 'all', but 2-way 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 "The toolchain is installed into directory specified by the"
+	echo "CROSS_PREFIX environment variable. If the variable is not"
+	echo "defined, /usr/local/cross/ is used as default."
+	echo "If --no-install is present, the toolchain still uses the"
+	echo "CROSS_PREFIX as the target directory but the installation"
+	echo "copies the files into PKG/ subdirectory without affecting"
+	echo "the actual root file system. That is only useful if you do"
+	echo "not want to run the script under the super user."
 	echo
 	
@@ -301,8 +309,8 @@
 	
 	echo ">>> Removing previous content"
-	cleanup_dir "${PREFIX}"
+	$REAL_INSTALL && cleanup_dir "${PREFIX}"
 	cleanup_dir "${WORKDIR}"
 	
-	create_dir "${PREFIX}" "destination directory"
+	$REAL_INSTALL && create_dir "${PREFIX}" "destination directory"
 	create_dir "${OBJDIR}" "GCC object directory"
 	
@@ -315,4 +323,5 @@
 	unpack_tarball "${BASEDIR}/${GDB}" "GDB"
 	
+	
 	echo ">>> Processing binutils (${PLATFORM})"
 	cd "${BINUTILSDIR}"
@@ -320,10 +329,22 @@
 	
 	change_title "binutils: configure (${PLATFORM})"
-	CFLAGS=-Wno-error ./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --disable-nls --disable-werror
+	CFLAGS=-Wno-error ./configure \
+		"--target=${TARGET}" \
+		"--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
+		--disable-nls --disable-werror
 	check_error $? "Error configuring binutils."
 	
 	change_title "binutils: make (${PLATFORM})"
-	make all install
-	check_error $? "Error compiling/installing binutils."
+	make all
+	check_error $? "Error compiling binutils."
+	
+	change_title "binutils: install (${PLATFORM})"
+	if $REAL_INSTALL; then
+		make install
+	else
+		make install "DESTDIR=${INSTALL_DIR}"
+	fi
+	check_error $? "Error installing binutils."
+	
 	
 	echo ">>> Processing GCC (${PLATFORM})"
@@ -332,10 +353,25 @@
 	
 	change_title "GCC: configure (${PLATFORM})"
-	"${GCCDIR}/configure" "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-" --with-gnu-as --with-gnu-ld --disable-nls --disable-threads --enable-languages=c,objc,c++,obj-c++ --disable-multilib --disable-libgcj --without-headers --disable-shared --enable-lto --disable-werror
+	PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" "${GCCDIR}/configure" \
+		"--target=${TARGET}" \
+		"--prefix=${PREFIX}" "--program-prefix=${TARGET}-" \
+		--with-gnu-as --with-gnu-ld --disable-nls --disable-threads \
+		--enable-languages=c,objc,c++,obj-c++ \
+		--disable-multilib --disable-libgcj --without-headers \
+		--disable-shared --enable-lto --disable-werror
 	check_error $? "Error configuring GCC."
 	
 	change_title "GCC: make (${PLATFORM})"
-	PATH="${PATH}:${PREFIX}/bin" make all-gcc install-gcc
-	check_error $? "Error compiling/installing GCC."
+	PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all-gcc
+	check_error $? "Error compiling GCC."
+	
+	change_title "GCC: install (${PLATFORM})"
+	if $REAL_INSTALL; then
+		PATH="${PATH}:${PREFIX}/bin" make install-gcc
+	else
+		PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install-gcc "DESTDIR=${INSTALL_DIR}"
+	fi
+	check_error $? "Error installing GCC."
+	
 	
 	echo ">>> Processing GDB (${PLATFORM})"
@@ -344,10 +380,21 @@
 	
 	change_title "GDB: configure (${PLATFORM})"
-	./configure "--target=${TARGET}" "--prefix=${PREFIX}" "--program-prefix=${TARGET}-"
+	PATH="$PATH:${INSTALL_DIR}/${PREFIX}/bin" ./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."
+	PATH="${PATH}:${PREFIX}/bin:${INSTALL_DIR}/${PREFIX}/bin" make all
+	check_error $? "Error compiling GDB."
+	
+	change_title "GDB: make (${PLATFORM})"
+	if $REAL_INSTALL; then
+		PATH="${PATH}:${PREFIX}/bin" make install
+	else
+		PATH="${PATH}:${INSTALL_DIR}/${PREFIX}/bin" make install "DESTDIR=${INSTALL_DIR}"
+	fi
+	check_error $? "Error installing GDB."
+	
 	
 	cd "${BASEDIR}"
@@ -360,4 +407,9 @@
 	echo ">>> Cross-compiler for ${TARGET} installed."
 }
+
+if [ "$1" = "--no-install" ]; then
+	REAL_INSTALL=false
+	shift
+fi
 
 if [ "$#" -lt "1" ]; then
