Skip to content

Commit a2430b2

Browse files
committed
kbuild: add kbuild-file macro
While building, installing, cleaning, Kbuild visits sub-directories and includes 'Kbuild' or 'Makefile' that exists there. Add 'kbuild-file' macro, and reuse it from scripts/Makefie.* Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Tested-by: Alexander Lobakin <[email protected]>
1 parent 5724ac5 commit a2430b2

File tree

6 files changed

+12
-14
lines changed

6 files changed

+12
-14
lines changed

scripts/Kbuild.include

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ escsq = $(subst $(squote),'\$(squote)',$1)
4040
# Quote a string to pass it to C files. foo => '"foo"'
4141
stringify = $(squote)$(quote)$1$(quote)$(squote)
4242

43+
###
44+
# The path to Kbuild or Makefile. Kbuild has precedence over Makefile.
45+
kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
46+
kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
47+
4348
###
4449
# Easy method for doing a status message
4550
kecho := :

scripts/Makefile.asm-generic

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ PHONY := all
1010
all:
1111

1212
src := $(subst /generated,,$(obj))
13-
-include $(src)/Kbuild
13+
14+
include $(srctree)/scripts/Kbuild.include
15+
-include $(kbuild-file)
1416

1517
# $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case.
1618
ifneq ($(SRCARCH),um)
1719
include $(srctree)/$(generic)/Kbuild
1820
endif
1921

20-
include $(srctree)/scripts/Kbuild.include
21-
2222
redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y))
2323
redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f)))
2424
redundant := $(sort $(redundant))

scripts/Makefile.build

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ subdir-ccflags-y :=
3838

3939
include $(srctree)/scripts/Kbuild.include
4040
include $(srctree)/scripts/Makefile.compiler
41-
42-
# The filename Kbuild has precedence over Makefile
43-
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
44-
include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
45-
41+
include $(kbuild-file)
4642
include $(srctree)/scripts/Makefile.lib
4743

4844
# Do not include hostprogs rules unless needed.

scripts/Makefile.clean

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ PHONY := __clean
99
__clean:
1010

1111
include $(srctree)/scripts/Kbuild.include
12-
13-
# The filename Kbuild has precedence over Makefile
14-
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
15-
include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile)
12+
include $(kbuild-file)
1613

1714
# Figure out what we need to build from the various variables
1815
# ==========================================================================

scripts/Makefile.dtbinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ __dtbs_install:
1515

1616
include include/config/auto.conf
1717
include $(srctree)/scripts/Kbuild.include
18-
include $(src)/Makefile
18+
include $(kbuild-file)
1919

2020
dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
2121
subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m))

scripts/Makefile.modpost

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ obj := $(KBUILD_EXTMOD)
9393
src := $(obj)
9494

9595
# Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
96-
include $(or $(wildcard $(src)/Kbuild), $(src)/Makefile)
96+
include $(kbuild-file)
9797

9898
module.symvers-if-present := $(wildcard Module.symvers)
9999
output-symdump := $(KBUILD_EXTMOD)/Module.symvers

0 commit comments

Comments
 (0)