Hi,
I don't know if this is the right way, but here's a diff to xcompile
that lets the user pick a toolchain by setting the $CROSS environment
variable. Yes, the idea is shamelessly stolen from SLOF ;-) I found
this usefuly as the host compiler on my system won't produce a working
binary whereas GCC 4.3.1 and binutils 2.18 compiled from the GNU
tarballs work.
Regards,
Philip
---
Make xcompile less smart and allow user to pick a toolchain by setting $CROSS
Signed-off-by: Philip Schulz <philip.s.schulz(a)googlemail.com>
diff -r 9bfb3ac80f66 util/xcompile/xcompile
--- a/util/xcompile/xcompile Tue Jul 29 20:42:48 2008 +0200
+++ b/util/xcompile/xcompile Wed Jul 30 21:32:26 2008 +0200
@@ -53,54 +53,69 @@
exit 1
}
-case "$ARCH" in
-"x86_64")
- echo "CC_x86 := gcc -m32"
- CC="gcc -m32"
+if [ -n "${CROSS:+1}" ] ; then
+ # If $CROSS is set, assume the user knows what he/she is doing
- searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)"
- searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as) --32"
- searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld) -b
elf32-i386 -melf_i386"
- searchgnu nm >/dev/null && echo "NM_x86 := $(searchgnu nm)"
- searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)"
- ;;
-"x86")
- if [ "$OS" != "Darwin" ]; then
- echo "CC_x86 := gcc"
- CC="gcc"
+ CC="${CROSS}gcc"
+ echo "CC_${ARCH} := ${CROSS}gcc"
+ echo "AR_${ARCH} := ${CROSS}ar"
+ echo "AS_${ARCH} := ${CROSS}as"
+ echo "LD_${ARCH} := ${CROSS}ld"
+ echo "NM_${ARCH} := ${CROSS}nm"
+ echo "OBJCOPY_${ARCH} := ${CROSS}objcopy"
+else
+ # $CROSS is not set, so try to be smart and figure out the right
+ # settings automatically
+
+ case "$ARCH" in
+ "x86_64")
+ echo "CC_x86 := gcc -m32"
+ CC="gcc -m32"
searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)"
- searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as)"
- searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld)"
+ searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as) --32"
+ searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld) -b
elf32-i386 -melf_i386"
searchgnu nm >/dev/null && echo "NM_x86 := $(searchgnu nm)"
searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)"
- else
- CC=`find /opt/local/bin/ -name "i386-elf-gcc-*"`
- if [ "$CC" == "" ]; then
- echo "ERROR: Please install i386-elf-gcc from MacPorts" >&2
- exit 1
+ ;;
+ "x86")
+ if [ "$OS" != "Darwin" ]; then
+ echo "CC_x86 := gcc"
+ CC="gcc"
+
+ searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)"
+ searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as)"
+ searchgnu ld >/dev/null && echo "LD_x86 := $(searchgnu ld)"
+ searchgnu nm >/dev/null && echo "NM_x86 := $(searchgnu nm)"
+ searchgnu objcopy >/dev/null && echo "OBJCOPY_x86 := $(searchgnu objcopy)"
+ else
+ CC=`find /opt/local/bin/ -name "i386-elf-gcc-*"`
+ if [ "$CC" == "" ]; then
+ echo "ERROR: Please install i386-elf-gcc from MacPorts" >&2
+ exit 1
+ fi
+ echo "CC_x86 := $CC"
+ echo "AR_x86 := i386-elf-ar"
+ echo "AS_x86 := i386-elf-as --divide"
+ echo "LD_x86 := i386-elf-ld"
+ echo "NM_x86 := i386-elf-nm"
+ echo "OBJCOPY_x86 := i386-elf-objcopy"
+ echo "INTLCFLAGS := -I/opt/local/include"
+ echo "INTLLIBS := -L/opt/local/lib -lintl"
fi
- echo "CC_x86 := $CC"
- echo "AR_x86 := i386-elf-ar"
- echo "AS_x86 := i386-elf-as --divide"
- echo "LD_x86 := i386-elf-ld"
- echo "NM_x86 := i386-elf-nm"
- echo "OBJCOPY_x86 := i386-elf-objcopy"
- echo "INTLCFLAGS := -I/opt/local/include"
- echo "INTLLIBS := -L/opt/local/lib -lintl"
- 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"
- ;;
-esac
+ ;;
+ *)
+ # 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"
+ ;;
+ esac
+fi
# This is where we test for various flags and other things