summaryrefslogtreecommitdiffstats
path: root/scripts/Kbuild.include
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2022-12-11 03:54:47 +0100
committerMasahiro Yamada <masahiroy@kernel.org>2022-12-13 14:29:10 +0100
commit6768fa4bcb6c1618248f135d04b9287ba2724ae0 (patch)
tree0d49fcbba647b32e81d9da19192092dce67485e4 /scripts/Kbuild.include
parentkbuild: do not sort after reading modules.order (diff)
downloadlinux-6768fa4bcb6c1618248f135d04b9287ba2724ae0.tar.xz
linux-6768fa4bcb6c1618248f135d04b9287ba2724ae0.zip
kbuild: add read-file macro
Since GNU Make 4.2, $(file ...) supports the read operater '<', which is useful to read a file without forking a new process. No warning is shown even if the input file is missing. For older Make versions, it falls back to the cat command. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu> Reviewed-by: Alexander Lobakin <alexandr.lobakin@intel.com> Tested-by: Alexander Lobakin <alexandr.lobakin@intel.com>
Diffstat (limited to 'scripts/Kbuild.include')
-rw-r--r--scripts/Kbuild.include14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 3be7c2d75667..21e76ba0de17 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -10,6 +10,10 @@ empty :=
space := $(empty) $(empty)
space_escape := _-_SPACE_-_
pound := \#
+define newline
+
+
+endef
###
# Comparison macros.
@@ -62,6 +66,16 @@ kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
###
+# Read a file, replacing newlines with spaces
+#
+# Make 4.2 or later can read a file by using its builtin function.
+ifneq ($(filter-out 3.% 4.0 4.1, $(MAKE_VERSION)),)
+read-file = $(subst $(newline),$(space),$(file < $1))
+else
+read-file = $(shell cat $1 2>/dev/null)
+endif
+
+###
# Easy method for doing a status message
kecho := :
quiet_kecho := echo