Index: util/xcompile/xcompile
===================================================================
--- util/xcompile/xcompile	(revision 463)
+++ util/xcompile/xcompile	(working copy)
@@ -91,14 +91,30 @@
 	fi
 	;;
 *)
-	# FIXME: This should be detected.
-	CC="i386-linux-gcc"
-	echo "CC_x86 := i386-linux-gcc"
-	echo "AR_x86 := i386-linux-ar"
-	echo "AS_x86 := i386-linux-as"
-	echo "LD_x86 := i386-linux-ld"
-	echo "NM_x86 := i386-linux-nm"
-	echo "OBJCOPY_x86 := i386-linux-objcopy"
+	# add more candidates here as appropriate
+	for candidate in \
+		i386-elf- \
+		i386-linux- \
+	; do
+		version=`${candidate}gcc --version |grep "(GCC)" |awk '{print $3;}'`
+		if [ -n "$version" ]; then
+			PREFIX=$candidate
+			break
+		fi
+	done
+	if [ "x$PREFIX" = "x" ]; then
+		echo "# warning: using default compiler for x86 target."
+		echo "# may or may not work - but likely won't"
+	fi
+
+	PREFIX="i386-elf-"
+	CC="${PREFIX}gcc"
+	echo "CC_x86 := ${PREFIX}gcc"
+	echo "AR_x86 := ${PREFIX}ar"
+	echo "AS_x86 := ${PREFIX}as"
+	echo "LD_x86 := ${PREFIX}ld"
+	echo "NM_x86 := ${PREFIX}nm"
+	echo "OBJCOPY_x86 := ${PREFIX}objcopy"
 	;;
 esac
 
