VPATH is used in Kbuild to make pattern rules search for prerequisites in both $(objtree) and $(srctree). Some of *.c, *.S files are not real sources, but generated by tools such as flex, bison, perl. In contrast, I doubt the benefit of --include-dir=$(abs_srctree) because it is always clear which Makefiles are real sources, and which are not. So, my hope is to add $(srctree)/ prefix to all check-in Makefiles, then remove --include-dir=$(abs_srctree) flag in the future. I am touching only some Kbuild core parts for now. Treewide fixes will be needed to achieve this goal.
Unified · Split
| @@ -339,14 +339,14 @@ __build_one_by_one: · 338 unmodified lines | |||
| 339 | 339 | ||
| 340 | else # !mixed-build | 340 | else # !mixed-build |
| 341 | 341 | ||
| 342 | include scripts/Kbuild.include | 342 | include $(srctree)/scripts/Kbuild.include |
| 343 | 343 | ||
| 344 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) | 344 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) |
| 345 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) | 345 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) |
| 346 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) | 346 | KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) |
| 347 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION | 347 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION |
| 348 | 348 | ||
| 349 | include scripts/subarch.include | 349 | include $(srctree)/scripts/subarch.include |
| 350 | 350 | ||
| 351 | # Cross compiling and selecting different set of gcc/bin-utils | 351 | # Cross compiling and selecting different set of gcc/bin-utils |
| 352 | # --------------------------------------------------------------------------- | 352 | # --------------------------------------------------------------------------- |
| @@ -592,7 +592,7 @@ ifdef config-build · 239 unmodified lines | |||
| 592 | # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. | 592 | # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. |
| 593 | # KBUILD_DEFCONFIG may point out an alternative default configuration | 593 | # KBUILD_DEFCONFIG may point out an alternative default configuration |
| 594 | # used for 'make defconfig' | 594 | # used for 'make defconfig' |
| 595 | include arch/$(SRCARCH)/Makefile | 595 | include $(srctree)/arch/$(SRCARCH)/Makefile |
| 596 | export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT | 596 | export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT |
| 597 | 597 | ||
| 598 | config: outputmakefile scripts_basic FORCE | 598 | config: outputmakefile scripts_basic FORCE |
| @@ -679,7 +679,7 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc · 80 unmodified lines | |||
| 679 | export RETPOLINE_CFLAGS | 679 | export RETPOLINE_CFLAGS |
| 680 | export RETPOLINE_VDSO_CFLAGS | 680 | export RETPOLINE_VDSO_CFLAGS |
| 681 | 681 | ||
| 682 | include arch/$(SRCARCH)/Makefile | 682 | include $(srctree)/arch/$(SRCARCH)/Makefile |
| 683 | 683 | ||
| 684 | ifdef need-config | 684 | ifdef need-config |
| 685 | ifdef may-sync-config | 685 | ifdef may-sync-config |
| @@ -14,10 +14,10 @@ src := $(subst /generated,,$(obj)) · 13 unmodified lines | |||
| 14 | 14 | ||
| 15 | # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. | 15 | # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. |
| 16 | ifneq ($(SRCARCH),um) | 16 | ifneq ($(SRCARCH),um) |
| 17 | include $(generic)/Kbuild | 17 | include $(srctree)/$(generic)/Kbuild |
| 18 | endif | 18 | endif |
| 19 | 19 | ||
| 20 | include scripts/Kbuild.include | 20 | include $(srctree)/scripts/Kbuild.include |
| 21 | 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))) |
| @@ -35,27 +35,27 @@ subdir-ccflags-y := · 34 unmodified lines | |||
| 35 | # Read auto.conf if it exists, otherwise ignore | 35 | # Read auto.conf if it exists, otherwise ignore |
| 36 | -include include/config/auto.conf | 36 | -include include/config/auto.conf |
| 37 | 37 | ||
| 38 | include scripts/Kbuild.include | 38 | include $(srctree)/scripts/Kbuild.include |
| 39 | 39 | ||
| 40 | # The filename Kbuild has precedence over Makefile | 40 | # The filename Kbuild has precedence over Makefile |
| 41 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | 41 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) |
| 42 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) | 42 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) |
| 43 | include $(kbuild-file) | 43 | include $(kbuild-file) |
| 44 | 44 | ||
| 45 | include scripts/Makefile.lib | 45 | include $(srctree)/scripts/Makefile.lib |
| 46 | 46 | ||
| 47 | # Do not include hostprogs rules unless needed. | 47 | # Do not include hostprogs rules unless needed. |
| 48 | # $(sort ...) is used here to remove duplicated words and excessive spaces. | 48 | # $(sort ...) is used here to remove duplicated words and excessive spaces. |
| 49 | hostprogs := $(sort $(hostprogs)) | 49 | hostprogs := $(sort $(hostprogs)) |
| 50 | ifneq ($(hostprogs),) | 50 | ifneq ($(hostprogs),) |
| 51 | include scripts/Makefile.host | 51 | include $(srctree)/scripts/Makefile.host |
| 52 | endif | 52 | endif |
| 53 | 53 | ||
| 54 | # Do not include userprogs rules unless needed. | 54 | # Do not include userprogs rules unless needed. |
| 55 | # $(sort ...) is used here to remove duplicated words and excessive spaces. | 55 | # $(sort ...) is used here to remove duplicated words and excessive spaces. |
| 56 | userprogs := $(sort $(userprogs)) | 56 | userprogs := $(sort $(userprogs)) |
| 57 | ifneq ($(userprogs),) | 57 | ifneq ($(userprogs),) |
| 58 | include scripts/Makefile.userprogs | 58 | include $(srctree)/scripts/Makefile.userprogs |
| 59 | endif | 59 | endif |
| 60 | 60 | ||
| 61 | ifndef obj | 61 | ifndef obj |
| @@ -8,7 +8,7 @@ src := $(obj) · 7 unmodified lines | |||
| 8 | PHONY := __clean | 8 | PHONY := __clean |
| 9 | __clean: | 9 | __clean: |
| 10 | 10 | ||
| 11 | include scripts/Kbuild.include | 11 | include $(srctree)/scripts/Kbuild.include |
| 12 | 12 | ||
| 13 | # The filename Kbuild has precedence over Makefile | 13 | # The filename Kbuild has precedence over Makefile |
| 14 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | 14 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) |
| @@ -14,7 +14,7 @@ PHONY := __dtbs_install · 13 unmodified lines | |||
| 14 | __dtbs_install: | 14 | __dtbs_install: |
| 15 | 15 | ||
| 16 | include include/config/auto.conf | 16 | include include/config/auto.conf |
| 17 | include scripts/Kbuild.include | 17 | include $(srctree)/scripts/Kbuild.include |
| 18 | include $(src)/Makefile | 18 | include $(src)/Makefile |
| 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-))) |
| @@ -12,7 +12,7 @@ · 11 unmodified lines | |||
| 12 | PHONY := __headers | 12 | PHONY := __headers |
| 13 | __headers: | 13 | __headers: |
| 14 | 14 | ||
| 15 | include scripts/Kbuild.include | 15 | include $(srctree)/scripts/Kbuild.include |
| 16 | 16 | ||
| 17 | src := $(srctree)/$(obj) | 17 | src := $(srctree)/$(obj) |
| 18 | gen := $(objtree)/$(subst include/,include/generated/,$(obj)) | 18 | gen := $(objtree)/$(subst include/,include/generated/,$(obj)) |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | |||
| 6 | PHONY := __modinst | 6 | PHONY := __modinst |
| 7 | __modinst: | 7 | __modinst: |
| 8 | 8 | ||
| 9 | include scripts/Kbuild.include | 9 | include $(srctree)/scripts/Kbuild.include |
| 10 | 10 | ||
| 11 | modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order)) | 11 | modules := $(sort $(shell cat $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order)) |
| 12 | 12 | ||
| @@ -41,10 +41,10 @@ PHONY := __modpost · 40 unmodified lines | |||
| 41 | __modpost: | 41 | __modpost: |
| 42 | 42 | ||
| 43 | include include/config/auto.conf | 43 | include include/config/auto.conf |
| 44 | include scripts/Kbuild.include | 44 | include $(srctree)/scripts/Kbuild.include |
| 45 | 45 | ||
| 46 | # for ld_flags | 46 | # for ld_flags |
| 47 | include scripts/Makefile.lib | 47 | include $(srctree)/scripts/Makefile.lib |
| 48 | 48 | ||
| 49 | MODPOST = scripts/mod/modpost \ | 49 | MODPOST = scripts/mod/modpost \ |
| 50 | $(if $(CONFIG_MODVERSIONS),-m) \ | 50 | $(if $(CONFIG_MODVERSIONS),-m) \ |
| @@ -6,7 +6,7 @@ · 5 unmodified lines | |||
| 6 | PHONY := __modsign | 6 | PHONY := __modsign |
| 7 | __modsign: | 7 | __modsign: |
| 8 | 8 | ||
| 9 | include scripts/Kbuild.include | 9 | include $(srctree)/scripts/Kbuild.include |
| 10 | 10 | ||
| 11 | modules := $(sort $(shell cat modules.order)) | 11 | modules := $(sort $(shell cat modules.order)) |
| 12 | 12 | ||