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