diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-02-19 23:23:56 -0500 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-02-27 07:41:27 -0500 |
| commit | bd55f96fa9fc29702ec30d75a4290bdadb00209d (patch) | |
| tree | 8848f6aab1d11366e62a767e3e36dd4cf021c240 /scripts | |
| parent | 88110713ca9dfbb0b6cb8bbb46ef6ecb313d6681 (diff) | |
kbuild: refactor cc-cross-prefix implementation
- $(word 1, <text>) is equivalent to $(firstword <text>)
- hardcode "gcc" instead of $(CC)
- minimize the shell script part
A little more notes in case $(filter-out -%, ...) is not clear.
arch/mips/Makefile passes prefixes depending on the configuration.
CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- \
$(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-)
In the Kconfig stage (e.g. when you run 'make defconfig'), neither
CONFIG_32BIT nor CONFIG_64BIT is defined. So, $(tool-archpref) is
empty. As a result, "-linux -linux-gnu- -unknown-linux-gnu" is passed
into cc-cross-prefix. The command 'which' assumes arguments starting
with a hyphen as command options, then emits the following messages:
Illegal option -l
Illegal option -l
Illegal option -u
I think it is strange to define CROSS_COMPILE depending on the CONFIG
options since you need to feed $(CC) to Kconfig, but it is how MIPS
Makefile currently works. Anyway, it would not hurt to filter-out
invalid strings beforehand.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Kbuild.include | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index d93250b33bf6..c1e15a4aee36 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
| @@ -71,14 +71,10 @@ endef | |||
| 71 | 71 | ||
| 72 | # cc-cross-prefix | 72 | # cc-cross-prefix |
| 73 | # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) | 73 | # Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) |
| 74 | # Return first prefix where a prefix$(CC) is found in PATH. | 74 | # Return first <prefix> where a <prefix>gcc is found in PATH. |
| 75 | # If no $(CC) found in PATH with listed prefixes return nothing | 75 | # If no gcc found in PATH with listed prefixes return nothing |
| 76 | cc-cross-prefix = \ | 76 | cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \ |
| 77 | $(word 1, $(foreach c,$(1), \ | 77 | $(if $(shell which $(c)gcc), $(c)))) |
| 78 | $(shell set -e; \ | ||
| 79 | if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \ | ||
| 80 | echo $(c); \ | ||
| 81 | fi))) | ||
| 82 | 78 | ||
| 83 | # output directory for tests below | 79 | # output directory for tests below |
| 84 | TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) | 80 | TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) |
