This patch added arm toolchain support for coreboot building system.

xcompile will find the different toolchain for X86 and ARM
architectures and when
we decided the target architecture using `make menuconfig` or so, makefile will
choose the right toolchain.

Signed-off-by: Yang Bai <[email protected]>

Index: src/Kconfig
===================================================================
--- src/Kconfig (revision 6567)
+++ src/Kconfig (working copy)
@@ -116,10 +116,19 @@
        bool
        default n

+# This option is used to set the architecture of a mainboard to ARM.
+config ARCH_ARM
+        bool
+       default n
+
 if ARCH_X86
 source src/arch/x86/Kconfig
 endif

+if ARCH_ARM
+source src/arch/arm/Kconfig
+endif
+
 menu "Chipset"

 comment "CPU"
Index: src/arch/arm/Kconfig
===================================================================
--- src/arch/arm/Kconfig        (revision 0)
+++ src/arch/arm/Kconfig        (revision 0)
@@ -0,0 +1,3 @@
+menu "Architecture (ARM)"
+
+endmenu
Index: util/xcompile/xcompile
===================================================================
--- util/xcompile/xcompile      (revision 6567)
+++ util/xcompile/xcompile      (working copy)
@@ -3,6 +3,7 @@
 # This file is part of the coreboot project.
 #
 # Copyright (C) 2007-2010 coresystems GmbH
+# Copyright (C) 2011 Yang Bai <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -34,20 +35,27 @@
        fi
 done

-GCCPREFIX=invalid
-TMPFILE=`mktemp /tmp/temp.XXXX 2>/dev/null || echo /tmp/temp.78gOIUGz`
-touch $TMPFILE
+TWIDTH=32
+for TARCH in i386 littlearm; do

-# This should be a loop over all supported architectures
-TARCH=i386
-TWIDTH=32
-for gccprefixes in `pwd`/util/crossgcc/xgcc/bin/${TARCH}-elf-
${TARCH}-elf- ""; do
+    GCCPREFIX=invalid
+
+    if [ ${TARCH} == "i386" ]; then
+       CARCH=${TARCH}-elf
+    elif [ ${TARCH} == "littlearm" ]; then
+       CARCH=arm-none-eabi
+    fi
+
+    TMPFILE=`mktemp /tmp/temp.XXXX 2>/dev/null || echo /tmp/temp.78gOIUGz`
+    touch $TMPFILE
+
+    for gccprefixes in `pwd`/util/crossgcc/xgcc/bin/${CARCH}- ${CARCH}- ""; do
        if ! which ${gccprefixes}as 2>/dev/null >/dev/null; then
-               continue
+           continue
        fi
        rm -f ${TMPFILE}.o
        if ${gccprefixes}as -o ${TMPFILE}.o ${TMPFILE}; then
-               TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o`
+               TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o | grep "file 
format"`
                if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then
                        GCCPREFIX=$gccprefixes
                        ASFLAGS=
@@ -56,47 +64,44 @@
                        break
                fi
        fi
-       if ${gccprefixes}as --32 -o ${TMPFILE}.o ${TMPFILE}; then
-               TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o`
+       if [ ${TARCH} == "i386" ]; then
+           if ${gccprefixes}as --32 -o ${TMPFILE}.o ${TMPFILE}; then
+               TYPE=`${gccprefixes}objdump -p ${TMPFILE}.o | grep "file 
format"`
                if [ ${TYPE##* } == "elf${TWIDTH}-${TARCH}" ]; then
-                       GCCPREFIX=$gccprefixes
-                       ASFLAGS=--32
-                       CFLAGS="-m32 "
-                       LDFLAGS="-b elf32-i386"
-                       break
+                   GCCPREFIX=$gccprefixes
+                   ASFLAGS=--32
+                   CFLAGS="-m32 "
+                   LDFLAGS="-b elf32-i386"
+                   break
                fi
+           fi
        fi
-done
-rm -f $TMPFILE ${TMPFILE}.o
+    done
+    rm -f $TMPFILE ${TMPFILE}.o

-if [ "$GCCPREFIX" = "invalid" ]; then
-       echo '$(error no suitable gcc found)'
-       exit 1
-fi
-
-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 "
-
-if which gcc 2>/dev/null >/dev/null; then
-       HOSTCC=gcc
-else
-       HOSTCC=cc
-fi
-
-cat << EOF
+    if [ "$GCCPREFIX" != "invalid" ]; then
+       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 "
+       cat << EOF
 # elf${TWIDTH}-${TARCH} toolchain
-AS:=${GCCPREFIX}as ${ASFLAGS}
-CC:=${GCCPREFIX}gcc ${CFLAGS}
-AR:=${GCCPREFIX}ar
-LD:=${GCCPREFIX}ld ${LDFLAGS}
-STRIP:=${GCCPREFIX}strip
-NM:=${GCCPREFIX}nm
-OBJCOPY:=${GCCPREFIX}objcopy
-OBJDUMP:=${GCCPREFIX}objdump
-
-# native toolchain
-HOSTCC:=${HOSTCC}
+AS_${TARCH}:=${GCCPREFIX}as ${ASFLAGS}
+CC_${TARCH}:=${GCCPREFIX}gcc ${CFLAGS}
+AR_${TARCH}:=${GCCPREFIX}ar
+LD_${TARCH}:=${GCCPREFIX}ld ${LDFLAGS}
+STRIP_${TARCH}:=${GCCPREFIX}strip
+NM_${TARCH}:=${GCCPREFIX}nm
+OBJCOPY_${TARCH}:=${GCCPREFIX}objcopy
+OBJDUMP_${TARCH}:=${GCCPREFIX}objdump
 EOF
+   else
+       cat <<EOF
+# elf${TWIDTH}-${TARCH} toolchain
+NO_${TARCH}_TOOLCHAIN:=1
+EOF
+    fi

+unset AS CC AR LD STRIP NM OBJCOPY OBJDUMP GCCPREFIX ASFLAGS CFLAGS
LDFLAGS CARCH
+
+done
Index: Makefile
===================================================================
--- Makefile    (revision 6567)
+++ Makefile    (working copy)
@@ -101,7 +101,42 @@

 include $(HAVE_DOTCONFIG)

+# Set the toolchain variables
+# FOR X86
+ifeq ($(CONFIG_ARCH_X86),y)
+ifeq ($(NO_i386_TOOLCHAIN),1)
+$(error No suitable gcc for X86 found)
+else
 ifneq ($(INNER_SCANBUILD),y)
+CC:=$(CC_i386)
+endif
+AS:=$(AS_i386)
+AR:=$(AR_i386)
+LD:=$(LD_i386)
+STRIP:=$(STRIP_i386)
+NM:=$(NM_i386)
+OBJCOPY:=$(OBJCOPY_i386)
+OBJDUMP:=$(OBJDUMP_i386)
+endif
+endif
+
+# FOR ARM
+ifeq ($(CONFIG_ARCH_ARM),y)
+ifeq ($(NO_littlearm_TOOLCHAIN),1)
+$(error No suitable gcc for ARM found)
+else
+CC:=$(CC_littlearm)
+AS:=$(AS_littlearm)
+AR:=$(AR_littlearm)
+LD:=$(LD_littlearm)
+STRIP:=$(STRIP_littlearm)
+NM:=$(NM_littlearm)
+OBJCOPY:=$(OBJCOPY_littlearm)
+OBJDUMP:=$(OBJDUMP_littlearm)
+endif
+endif
+
+ifneq ($(INNER_SCANBUILD),y)
 ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
 CC:=clang -m32
 HOSTCC:=clang



-- 
    """
    Keep It Simple,Stupid.
    """

Chinese Name: 白杨
Nick Name: Hamo
Homepage: http://hamobai.com/
GPG KEY ID: 0xA4691A33
Key fingerprint = 09D5 2D78 8E2B 0995 CF8E  4331 33C4 3D24 A469 1A33

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to