Skip to content

Commit

Permalink
kbuild: replace sed with $(subst ) or $(patsubst )
Browse files Browse the repository at this point in the history
For simple text replacement, it is better to use a built-in function
instead of sed if possible. You can save one process forking.

I do not mean to replace all sed invocations because GNU Make itself
does not support regular expression (unless you use guile).

I just replaced simple ones.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Masahiro Yamada committed Apr 24, 2021
1 parent 879a320 commit 6e0839f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Documentation/devicetree/bindings/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ define rule_chkdt
$(call cmd,mk_schema)
endef

DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||')
DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_cmd)))

override DTC_FLAGS := \
-Wno-avoid_unnecessary_addr_size \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ endif
# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
# and from include/config/auto.conf.cmd to detect the compiler upgrade.
CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1 | sed 's/\#//g')
CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head -n 1))

ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
ifneq ($(CROSS_COMPILE),)
Expand Down

0 comments on commit 6e0839f

Please sign in to comment.