Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+17 -3
+1 -1
Makefile
··· 376 376 include $(srctree)/scripts/Kbuild.include 377 377 378 378 # Read KERNELRELEASE from include/config/kernel.release (if it exists) 379 - KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 379 + KERNELRELEASE = $(call read-file, include/config/kernel.release) 380 380 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 381 381 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 382 382
+14
scripts/Kbuild.include
··· 10 10 space := $(empty) $(empty) 11 11 space_escape := _-_SPACE_-_ 12 12 pound := \# 13 + define newline 14 + 15 + 16 + endef 13 17 14 18 ### 15 19 # Comparison macros. ··· 64 60 # The path to Kbuild or Makefile. Kbuild has precedence over Makefile. 65 61 kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 66 62 kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile) 63 + 64 + ### 65 + # Read a file, replacing newlines with spaces 66 + # 67 + # Make 4.2 or later can read a file by using its builtin function. 68 + ifneq ($(filter-out 3.% 4.0 4.1, $(MAKE_VERSION)),) 69 + read-file = $(subst $(newline),$(space),$(file < $1)) 70 + else 71 + read-file = $(shell cat $1 2>/dev/null) 72 + endif 67 73 68 74 ### 69 75 # Easy method for doing a status message
+1 -1
scripts/Makefile.modfinal
··· 13 13 include $(srctree)/scripts/Makefile.lib 14 14 15 15 # find all modules listed in modules.order 16 - modules := $(shell cat $(MODORDER)) 16 + modules := $(call read-file, $(MODORDER)) 17 17 18 18 __modfinal: $(modules) 19 19 @:
+1 -1
scripts/Makefile.modinst
··· 9 9 include include/config/auto.conf 10 10 include $(srctree)/scripts/Kbuild.include 11 11 12 - modules := $(shell cat $(MODORDER)) 12 + modules := $(call read-file, $(MODORDER)) 13 13 14 14 ifeq ($(KBUILD_EXTMOD),) 15 15 dst := $(MODLIB)/kernel