Update xcompile to search for x86_64 toolchain.
[coreboot.git] / util / xcompile / xcompile
index 19103c7ade61b06d168380ad9452c2d4842ecf1d..3930460f025052085cec285284b79b0a98e6991b 100644 (file)
@@ -21,7 +21,7 @@
 testcc()
 {
        echo "_start(void) {}" > .$$$$.c
-       $1 -nostdlib $2 .$$$$.c -o .$$$$.tmp 2>/dev/null >/dev/null
+       $1 -nostdlib -Werror $2 .$$$$.c -o .$$$$.tmp 2>/dev/null >/dev/null
        ret=$?
        rm -f .$$$$.c .$$$$.tmp
        return $ret
@@ -35,13 +35,20 @@ for make in make gmake gnumake; do
 done
 
 GCCPREFIX=invalid
+XGCCPATH=${1:-"`pwd`/util/crossgcc/xgcc/bin/"}
+echo '# XGCCPATH='${XGCCPATH}
 TMPFILE=`mktemp /tmp/temp.XXXX 2>/dev/null || echo /tmp/temp.78gOIUGz`
 touch $TMPFILE
 
-# This should be a loop over all supported architectures
-TARCH=i386
+# This loops over all supported architectures in TARCH
+TARCH=('i386' 'x86_64')
 TWIDTH=32
-for gccprefixes in `pwd`/util/crossgcc/xgcc/bin/${TARCH}-elf- ${TARCH}-elf- ""; do
+for search_for in "${TARCH[@]}"; do
+       TARCH_SEARCH=("${TARCH_SEARCH[@]}" ${XGCCPATH}${search_for}-elf- ${search_for}-elf-)
+done
+echo '# TARCH_SEARCH='${TARCH_SEARCH[@]}
+
+for gccprefixes in "${TARCH_SEARCH[@]}" ""; do
        if ! which ${gccprefixes}as 2>/dev/null >/dev/null; then
                continue
        fi
@@ -61,8 +68,8 @@ for gccprefixes in `pwd`/util/crossgcc/xgcc/bin/${TARCH}-elf- ${TARCH}-elf- "";
                if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then
                        GCCPREFIX=$gccprefixes
                        ASFLAGS=--32
-                       CFLAGS="-m32 "
-                       LDFLAGS="-b elf32-i386"
+                       CFLAGS="-m32 -Wl,-b,elf32-i386 -Wl,-melf_i386 "
+                       LDFLAGS="-b elf32-i386 -melf_i386"
                        break
                fi
        fi
@@ -78,6 +85,10 @@ CC="${GCCPREFIX}gcc"
 testcc "$CC" "$CFLAGS-Wa,--divide " && CFLAGS="$CFLAGS-Wa,--divide "
 testcc "$CC" "$CFLAGS-fno-stack-protector " && CFLAGS="$CFLAGS-fno-stack-protector "
 testcc "$CC" "$CFLAGS-Wl,--build-id=none " && CFLAGS="$CFLAGS-Wl,--build-id=none "
+# GCC 4.6 is much more picky about unused variables. Turn off it's warnings for
+# now:
+testcc "$CC" "$CFLAGS-Wno-unused-but-set-variable " && \
+              CFLAGS="$CFLAGS-Wno-unused-but-set-variable "
 
 if which gcc 2>/dev/null >/dev/null; then
        HOSTCC=gcc
@@ -85,6 +96,12 @@ else
        HOSTCC=cc
 fi
 
+if [ "`${XGCCPATH}/iasl 2>/dev/null | grep -c ACPI`" -gt 0 ]; then
+       IASL=${XGCCPATH}iasl
+else
+       IASL=iasl
+fi
+
 cat << EOF
 # elf${TWIDTH}-${TARCH} toolchain
 AS:=${GCCPREFIX}as ${ASFLAGS}
@@ -96,6 +113,8 @@ NM:=${GCCPREFIX}nm
 OBJCOPY:=${GCCPREFIX}objcopy
 OBJDUMP:=${GCCPREFIX}objdump
 
+IASL:=${IASL}
+
 # native toolchain
 HOSTCC:=${HOSTCC}
 EOF