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
On Mon, Jul 23, 2007 at 09:11:59PM +0200, Patrick Georgi wrote:
PREFIX=$candidate
break
[..]
- PREFIX="i386-elf-"
- CC="${PREFIX}gcc"
This can't work so well right?
The way I read it PREFIX will always be reassigned.
Plus, you changed the default from i386-linux to i386-elf.
(May not be a bad thing, but please document it if intentional.)
//Peter
Peter Stuge wrote:
This can't work so well right?
sorry, I forgot to remove my older variant. Thanks! Updated patch attached
(May not be a bad thing, but please document it if intentional.)
Document where - inline? or is i386-linux-* recommended anywhere? (couldn't find it anywhere in the source)
i386-elf should make the intent "no operating system below the generated code" more clear in my opinion, and it builds without libc and headers here (of course, linking "normal" executables won't work then), which is why i386-elf seems to be the more appropriate prefix.
Regards, Patrick Georgi
Index: util/xcompile/xcompile =================================================================== --- util/xcompile/xcompile (revision 463) +++ util/xcompile/xcompile (working copy) @@ -91,14 +91,29 @@ 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 + + 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