]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - scripts/Kbuild.include
kbuild: introduce cc-cross-prefix
[karo-tx-linux.git] / scripts / Kbuild.include
index de7bb284c6116d8ea3997ae224a25e3081aaf619..b96ea8d6a5ed0eb375a4db068cdb2c564407cd42 100644 (file)
@@ -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))/)