Commit 910b4046 authored by Sam Ravnborg's avatar Sam Ravnborg

kbuild: introduce cc-cross-prefix

cc-cross-prefix is useful for the architecture that like
to provide a default CROSS_COMPILE value,
but may have several to select between.

Sample usage:

ifneq ($(SUBARCH),$(ARCH))
        ifeq ($(CROSS_COMPILE),)
               CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
        endif
endif

Actual usage by the different archs will taken care of later.
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 50a8ec31
...@@ -518,6 +518,28 @@ more details, with real examples. ...@@ -518,6 +518,28 @@ more details, with real examples.
In this example for a specific GCC version the build will error out explaining In this example for a specific GCC version the build will error out explaining
to the user why it stops. to the user why it stops.
cc-cross-prefix
cc-cross-prefix is used to check if there exist a $(CC) in path with
one of the listed prefixes. The first prefix where there exist a
prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found
then nothing is returned.
Additional prefixes are separated by a single space in the
call of cc-cross-prefix.
This functionality is usefull for architecture Makefile that try
to set CROSS_COMPILE to well know values but may have several
values to select between.
It is recommended only to try to set CROSS_COMPILE is it is a cross
build (host arch is different from target arch). And is CROSS_COMPILE
is already set then leave it with the old value.
Example:
#arch/m68k/Makefile
ifneq ($(SUBARCH),$(ARCH))
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-)
endif
endif
=== 4 Host Program support === 4 Host Program support
Kbuild supports building executables on the host for use during the Kbuild supports building executables on the host for use during the
......
...@@ -56,6 +56,17 @@ endef ...@@ -56,6 +56,17 @@ endef
# gcc support functions # gcc support functions
# See documentation in Documentation/kbuild/makefiles.txt # 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 # output directory for tests below
TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment