Hi,

the attached patch looks for i386-elf-* and i386-linux-* in the generic case, where more options can be added easily.

I _think_ I wrote it sufficiently portable to make it run even on ancient shell tools (no tail(1) use, after the gnu kids killed it, no test -z, ...), but please review and test it.

Maybe it could be extended to replace the special cases in the script?


Regards,
Patrick Georgi
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
 
-- 
linuxbios mailing list
[email protected]
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to