3 # This file is part of the coreboot project.
5 # Copyright (C) 2007-2010 coresystems GmbH
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; version 2 of the License.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 echo "_start(void) {}" > .$$$$.c
24 $1 -nostdlib $2 .$$$$.c -o .$$$$.tmp 2>/dev/null >/dev/null
26 rm -f .$$$$.c .$$$$.tmp
30 for make in make gmake gnumake; do
31 if [ "`$make --version 2>/dev/null | grep -c GNU`" -gt 0 ]; then
38 XGCCPATH="`pwd`/util/crossgcc/xgcc/bin/"
39 TMPFILE=`mktemp /tmp/temp.XXXX 2>/dev/null || echo /tmp/temp.78gOIUGz`
42 # This should be a loop over all supported architectures
45 for gccprefixes in ${XGCCPATH}${TARCH}-elf- ${TARCH}-elf- ""; do
46 if ! which ${gccprefixes}as 2>/dev/null >/dev/null; then
50 if ${gccprefixes}as -o ${TMPFILE}.o ${TMPFILE}; then
51 TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o`
52 if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then
53 GCCPREFIX=$gccprefixes
60 if ${gccprefixes}as --32 -o ${TMPFILE}.o ${TMPFILE}; then
61 TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o`
62 if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then
63 GCCPREFIX=$gccprefixes
66 LDFLAGS="-b elf32-i386"
71 rm -f $TMPFILE ${TMPFILE}.o
73 if [ "$GCCPREFIX" = "invalid" ]; then
74 echo '$(error no suitable gcc found)'
79 testcc "$CC" "$CFLAGS-Wa,--divide " && CFLAGS="$CFLAGS-Wa,--divide "
80 testcc "$CC" "$CFLAGS-fno-stack-protector " && CFLAGS="$CFLAGS-fno-stack-protector "
81 testcc "$CC" "$CFLAGS-Wl,--build-id=none " && CFLAGS="$CFLAGS-Wl,--build-id=none "
83 if which gcc 2>/dev/null >/dev/null; then
89 if [ "`${XGCCPATH}/iasl 2>/dev/null | grep -c ACPI`" -gt 0 ]; then
96 # elf${TWIDTH}-${TARCH} toolchain
97 AS:=${GCCPREFIX}as ${ASFLAGS}
98 CC:=${GCCPREFIX}gcc ${CFLAGS}
100 LD:=${GCCPREFIX}ld ${LDFLAGS}
101 STRIP:=${GCCPREFIX}strip
103 OBJCOPY:=${GCCPREFIX}objcopy
104 OBJDUMP:=${GCCPREFIX}objdump