[PATCH] MIPS: try to select cross-compiler (if not set)
Antony Pavlov
antonynpavlov at gmail.com
Tue Jul 26 03:17:45 EDT 2011
Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
arch/mips/Makefile | 15 +++++++++++++++
scripts/Kbuild.include | 11 +++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 1ec2107..4d635c6 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -17,6 +17,21 @@ else
64bit-emul = elf64btsmip
endif
+ifdef CONFIG_32BIT
+tool-archpref = $(32bit-tool-archpref)
+UTS_MACHINE := mips
+endif
+ifdef CONFIG_64BIT
+tool-archpref = $(64bit-tool-archpref)
+UTS_MACHINE := mips64
+endif
+
+ifneq ($(SUBARCH),$(ARCH))
+ ifeq ($(CROSS_COMPILE),)
+ CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-)
+ endif
+endif
+
CPPFLAGS += -D__MIPS__ -fno-strict-aliasing -fno-merge-constants
cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 95e7746..0e6e2c7 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -56,6 +56,17 @@ endef
# gcc support functions
# See documentation in Documentation/kbuild/makefiles.txt
+# cc-cross-prefix
+# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
+# Return first prefix where a prefix$(CC) is found in PATH.
+# If no $(CC) found in PATH with listed prefixes return nothing
+cc-cross-prefix = \
+ $(word 1, $(foreach c,$(1), \
+ $(shell set -e; \
+ if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
+ echo $(c); \
+ fi)))
+
# output directory for tests below
TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
--
1.7.5.4
More information about the barebox
mailing list