Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision e4a14979ffc3c37b48afa97e8633a1ada35d2418)
+++ tools/autotool.py	(revision 1570759bf686aaccb9a8f7946b0e3bfa891ffa14)
@@ -181,4 +181,72 @@
 		print_error(["Failed to determine the value %s." % key,
 		             "Please contact the developers of HelenOS."])
+
+def get_target(config):
+	target = None
+	gnu_target = None
+	
+	if (config['PLATFORM'] == "abs32le"):
+		check_config(config, "CROSS_TARGET")
+		target = config['CROSS_TARGET']
+		
+		if (config['CROSS_TARGET'] == "arm32"):
+			gnu_target = "arm-linux-gnueabi"
+		
+		if (config['CROSS_TARGET'] == "ia32"):
+			gnu_target = "i686-pc-linux-gnu"
+		
+		if (config['CROSS_TARGET'] == "mips32"):
+			gnu_target = "mipsel-linux-gnu"
+			common['CC_ARGS'].append("-mabi=32")
+	
+	if (config['PLATFORM'] == "amd64"):
+		target = config['PLATFORM']
+		gnu_target = "amd64-linux-gnu"
+	
+	if (config['PLATFORM'] == "arm32"):
+		target = config['PLATFORM']
+		gnu_target = "arm-linux-gnueabi"
+	
+	if (config['PLATFORM'] == "ia32"):
+		target = config['PLATFORM']
+		gnu_target = "i686-pc-linux-gnu"
+	
+	if (config['PLATFORM'] == "ia64"):
+		target = config['PLATFORM']
+		gnu_target = "ia64-pc-linux-gnu"
+	
+	if (config['PLATFORM'] == "mips32"):
+		check_config(config, "MACHINE")
+		common['CC_ARGS'].append("-mabi=32")
+		
+		if ((config['MACHINE'] == "lgxemul") or (config['MACHINE'] == "msim")):
+			target = config['PLATFORM']
+			gnu_target = "mipsel-linux-gnu"
+		
+		if (config['MACHINE'] == "bgxemul"):
+			target = "mips32eb"
+			gnu_target = "mips-linux-gnu"
+	
+	if (config['PLATFORM'] == "mips64"):
+		check_config(config, "MACHINE")
+		common['CC_ARGS'].append("-mabi=64")
+		
+		if (config['MACHINE'] == "msim"):
+			target = config['PLATFORM']
+			gnu_target = "mips64el-linux-gnu"
+	
+	if (config['PLATFORM'] == "ppc32"):
+		target = config['PLATFORM']
+		gnu_target = "ppc-linux-gnu"
+	
+	if (config['PLATFORM'] == "sparc64"):
+		target = config['PLATFORM']
+		gnu_target = "sparc64-linux-gnu"
+	
+	if (target is None) or (gnu_target is None):
+		print_error(["Failed to determine target for compiler.",
+		             "Please contact the developers of HelenOS."])
+	
+	return (target, gnu_target)
 
 def check_app(args, name, details):
@@ -642,62 +710,6 @@
 		common['CC_ARGS'] = []
 		if (config['COMPILER'] == "gcc_cross"):
-			if (config['PLATFORM'] == "abs32le"):
-				check_config(config, "CROSS_TARGET")
-				target = config['CROSS_TARGET']
+			target, gnu_target = get_target(config)
 				
-				if (config['CROSS_TARGET'] == "arm32"):
-					gnu_target = "arm-linux-gnueabi"
-				
-				if (config['CROSS_TARGET'] == "ia32"):
-					gnu_target = "i686-pc-linux-gnu"
-				
-				if (config['CROSS_TARGET'] == "mips32"):
-					gnu_target = "mipsel-linux-gnu"
-					common['CC_ARGS'].append("-mabi=32")
-			
-			if (config['PLATFORM'] == "amd64"):
-				target = config['PLATFORM']
-				gnu_target = "amd64-linux-gnu"
-			
-			if (config['PLATFORM'] == "arm32"):
-				target = config['PLATFORM']
-				gnu_target = "arm-linux-gnueabi"
-			
-			if (config['PLATFORM'] == "ia32"):
-				target = config['PLATFORM']
-				gnu_target = "i686-pc-linux-gnu"
-			
-			if (config['PLATFORM'] == "ia64"):
-				target = config['PLATFORM']
-				gnu_target = "ia64-pc-linux-gnu"
-			
-			if (config['PLATFORM'] == "mips32"):
-				check_config(config, "MACHINE")
-				common['CC_ARGS'].append("-mabi=32")
-				
-				if ((config['MACHINE'] == "lgxemul") or (config['MACHINE'] == "msim")):
-					target = config['PLATFORM']
-					gnu_target = "mipsel-linux-gnu"
-				
-				if (config['MACHINE'] == "bgxemul"):
-					target = "mips32eb"
-					gnu_target = "mips-linux-gnu"
-			
-			if (config['PLATFORM'] == "mips64"):
-				check_config(config, "MACHINE")
-				common['CC_ARGS'].append("-mabi=64")
-				
-				if (config['MACHINE'] == "msim"):
-					target = config['PLATFORM']
-					gnu_target = "mips64el-linux-gnu"
-			
-			if (config['PLATFORM'] == "ppc32"):
-				target = config['PLATFORM']
-				gnu_target = "ppc-linux-gnu"
-			
-			if (config['PLATFORM'] == "sparc64"):
-				target = config['PLATFORM']
-				gnu_target = "sparc64-linux-gnu"
-			
 			path = "%s/%s/bin" % (cross_prefix, target)
 			prefix = "%s-" % gnu_target
@@ -723,8 +735,12 @@
 		
 		if (config['COMPILER'] == "clang"):
+			target, gnu_target = get_target(config)
+			path = "%s/%s/bin" % (cross_prefix, target)
+			prefix = "%s-" % gnu_target
+			
 			common['CC'] = "clang"
 			check_app([common['CC'], "--version"], "Clang compiler", "preferably version 1.0 or newer")
-			check_gcc(None, "", common, PACKAGE_GCC)
-			check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
+			check_gcc(path, prefix, common, PACKAGE_GCC)
+			check_binutils(path, prefix, common, PACKAGE_BINUTILS)
 		
 		# Platform-specific utilities
