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.*
Showing the changes to scripts (6 of 6 files). Show all
Unified · Split
| @@ -40,6 +40,11 @@ escsq = $(subst $(squote),'\$(squote)',$1) · 39 unmodified lines | ||
| 40 | 40 | # Quote a string to pass it to C files. foo => '"foo"' |
| 41 | 41 | stringify = $(squote)$(quote)$1$(quote)$(squote) |
| 42 | 42 | |
| 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 | + | |
| 43 | 48 | ### |
| 44 | 49 | # Easy method for doing a status message |
| 45 | 50 | kecho := : |
| @@ -10,15 +10,15 @@ PHONY := all · 9 unmodified lines | ||
| 10 | 10 | all: |
| 11 | 11 | |
| 12 | 12 | src := $(subst /generated,,$(obj)) |
| 13 | −-include $(src)/Kbuild | |
| 13 | + | |
| 14 | +include $(srctree)/scripts/Kbuild.include | |
| 15 | +-include $(kbuild-file) | |
| 14 | 16 | |
| 15 | 17 | # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. |
| 16 | 18 | ifneq ($(SRCARCH),um) |
| 17 | 19 | include $(srctree)/$(generic)/Kbuild |
| 18 | 20 | endif |
| 19 | 21 | |
| 20 | −include $(srctree)/scripts/Kbuild.include | |
| 21 | − | |
| 22 | 22 | redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) |
| 23 | 23 | redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f))) |
| 24 | 24 | redundant := $(sort $(redundant)) |
| @@ -38,11 +38,7 @@ subdir-ccflags-y := · 37 unmodified lines | ||
| 38 | 38 | |
| 39 | 39 | include $(srctree)/scripts/Kbuild.include |
| 40 | 40 | 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) | |
| 46 | 42 | include $(srctree)/scripts/Makefile.lib |
| 47 | 43 | |
| 48 | 44 | # Do not include hostprogs rules unless needed. |
| @@ -9,10 +9,7 @@ PHONY := __clean · 8 unmodified lines | ||
| 9 | 9 | __clean: |
| 10 | 10 | |
| 11 | 11 | 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) | |
| 16 | 13 | |
| 17 | 14 | # Figure out what we need to build from the various variables |
| 18 | 15 | # ========================================================================== |
| @@ -15,7 +15,7 @@ __dtbs_install: · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | include include/config/auto.conf |
| 17 | 17 | include $(srctree)/scripts/Kbuild.include |
| 18 | −include $(src)/Makefile | |
| 18 | +include $(kbuild-file) | |
| 19 | 19 | |
| 20 | 20 | dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-))) |
| 21 | 21 | subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m)) |
| @@ -93,7 +93,7 @@ obj := $(KBUILD_EXTMOD) · 92 unmodified lines | ||
| 93 | 93 | src := $(obj) |
| 94 | 94 | |
| 95 | 95 | # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS |
| 96 | −include $(or $(wildcard $(src)/Kbuild), $(src)/Makefile) | |
| 96 | +include $(kbuild-file) | |
| 97 | 97 | |
| 98 | 98 | module.symvers-if-present := $(wildcard Module.symvers) |
| 99 | 99 | output-symdump := $(KBUILD_EXTMOD)/Module.symvers |