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
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
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
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
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}
OBJCOPY:=${GCCPREFIX}objcopy
OBJDUMP:=${GCCPREFIX}objdump
+IASL:=${IASL}
+
# native toolchain
HOSTCC:=${HOSTCC}
EOF