kbuild: add dtbs_prepare target
PATCH 1/1 kbuild: add dtbs_prepare target
Factor out the common prerequisites for DT compilation into the new target, dtbs_prepare.
Add comments in case you wonder why include/config/kernel.release is the prerequisite. Our policy is that installation targets must not (re)compile any build artifacts in the tree. If we make modules_install depend on include/config/kernel.release and it is executed under the root privilege, it may be owned by root.
---
Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Makefile +10 -4
@@ -1367,16 +1367,22 @@ endif ifneq ($(dtstree),) -%.dtb: include/config/kernel.release scripts_dtc +%.dtb: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -%.dtbo: include/config/kernel.release scripts_dtc +%.dtbo: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -PHONY += dtbs dtbs_install dtbs_check -dtbs: include/config/kernel.release scripts_dtc +PHONY += dtbs dtbs_prepare dtbs_install dtbs_check +dtbs: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) +# include/config/kernel.release is not actually required for building DTBs, +# but for installing DTBs because INSTALL_DTBS_PATH contains $(KERNELRELEASE). +# We do not want to move it to dtbs_install. The policy is installation +# targets (, which may run as root) must not modify the tree. +dtbs_prepare: include/config/kernel.release scripts_dtc + ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) export CHECK_DTBS=y dtbs: dt_binding_check
Signature · 1 line
2.34.1
Quoted 20 lines · On Sat, 16 Jul 2022 18:31:22 +0900 Masahiro Yamada wrote:
Factor out the common prerequisites for DT compilation into the new target,
dtbs_prepare.Add comments in case you wonder why
include/config/kernel.releaseis the prerequisite. Our policy is that installation targets must not (re)compile any build artifacts in the tree. If we makemodules_installdepend oninclude/config/kernel.releaseand it is executed under the root privilege, it may be owned by root.Signed-off-by Masahiro Yamada <[email protected]>---
Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Makefile +0
-0
Makefile endif · line 1374
Quoted 10 lines
Makefile +2
-2@@ -1367,16 +1367,22 @@ endif ifneq ($(dtstree),) -%.dtb: include/config/kernel.release scripts_dtc +%.dtb: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -%.dtbo: include/config/kernel.release scripts_dtc +%.dtbo: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
Is there a reason, why both rules are not unified? I guess it is, but I can't see it.
Makefile endif · line 1383
Quoted 11 lines
Makefile +6
-2-PHONY += dtbs dtbs_install dtbs_check -dtbs: include/config/kernel.release scripts_dtc +PHONY += dtbs dtbs_prepare dtbs_install dtbs_check +dtbs: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) +# include/config/kernel.release is not actually required for building DTBs, +# but for installing DTBs because INSTALL_DTBS_PATH contains $(KERNELRELEASE). +# We do not want to move it to dtbs_install. The policy is installation +# targets (, which may run as root) must not modify the tree.
Is the comma after the opening parenthesis intended?
Kind regards,
Nicolas
Quoted 7 lines
Makefile +2
-0+dtbs_prepare: include/config/kernel.release scripts_dtc + ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) export CHECK_DTBS=y dtbs: dt_binding_checkSignature · 1 line
2.34.1
Quoted 29 lines · Nicolas Schier
Quoted 27 lines · On Sat, 16 Jul 2022 18:31:22 +0900 Masahiro Yamada wrote:
Factor out the common prerequisites for DT compilation into the new target,
dtbs_prepare.Add comments in case you wonder why
include/config/kernel.releaseis the prerequisite. Our policy is that installation targets must not (re)compile any build artifacts in the tree. If we makemodules_installdepend oninclude/config/kernel.releaseand it is executed under the root privilege, it may be owned by root.Signed-off-by Masahiro Yamada <[email protected]>---
Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Makefile +1
-1@@ -1367,16 +1367,22 @@ endif ifneq ($(dtstree),) -%.dtb: include/config/kernel.release scripts_dtc +%.dtb: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
Quoted 6 lines
Makefile endif · line 1374
Quoted 3 lines
Makefile +1
-1-%.dtbo: include/config/kernel.release scripts_dtc +%.dtbo: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@Is there a reason, why both rules are not unified? I guess it is, but I can't see it.
See the GNU Make manual:
https://www.gnu.org/software/make/manual/html_node/Pattern-Examples.html
The last paragraph, "This pattern rule has two targets ..."
%.dtb %.dtbo: dtbs_prepare
...
means foo.dtb and foo.dtbo are generated at the same time by the rule. This is strange.
Quoted 8 lines
Quoted 8 lines
Makefile +2
-2-PHONY += dtbs dtbs_install dtbs_check -dtbs: include/config/kernel.release scripts_dtc +PHONY += dtbs dtbs_prepare dtbs_install dtbs_check +dtbs: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree)
Quoted 6 lines
Makefile endif · line 1383
Quoted 4 lines
Makefile +4
-0+# include/config/kernel.release is not actually required for building DTBs, +# but for installing DTBs because INSTALL_DTBS_PATH contains $(KERNELRELEASE). +# We do not want to move it to dtbs_install. The policy is installation +# targets (, which may run as root) must not modify the tree.Is the comma after the opening parenthesis intended?
I will rephrase the comment in v2.
Quoted 11 lines
Kind regards,
NicolasQuoted 7 lines
Makefile +2
-1+dtbs_prepare: include/config/kernel.release scripts_dtc + ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) export CHECK_DTBS=y dtbs: dt_binding_check --2.34.1
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 46 lines · Masahiro Yamada
Quoted 29 lines · Nicolas Schier
Quoted 27 lines · On Sat, 16 Jul 2022 18:31:22 +0900 Masahiro Yamada wrote:
Factor out the common prerequisites for DT compilation into the new target,
dtbs_prepare.Add comments in case you wonder why
include/config/kernel.releaseis the prerequisite. Our policy is that installation targets must not (re)compile any build artifacts in the tree. If we makemodules_installdepend oninclude/config/kernel.releaseand it is executed under the root privilege, it may be owned by root.Signed-off-by Masahiro Yamada <[email protected]>---
Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Makefile +1
-1@@ -1367,16 +1367,22 @@ endif ifneq ($(dtstree),) -%.dtb: include/config/kernel.release scripts_dtc +%.dtb: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@Quoted 6 lines
Makefile endif · line 1374
Quoted 3 lines
Makefile +1
-1-%.dtbo: include/config/kernel.release scripts_dtc +%.dtbo: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@Is there a reason, why both rules are not unified? I guess it is, but I can't see it.
See the GNU Make manual:
https://www.gnu.org/software/make/manual/html_node/Pattern-Examples.htmlThe last paragraph, "This pattern rule has two targets ..."
Quoted 5 lines
%.dtb %.dtbo:
dtbs_prepare...means foo.dtb and foo.dtbo are generated at the same time by the rule. This is strange.
uh, I'm working with Makefile since years but I wasn't aware of that. Thanks a lot for the pointer and explanation!
Kind regards,
Nicolas
Quoted 39 lines
Quoted 9 lines
Quoted 9 lines
Makefile +2
-2-PHONY += dtbs dtbs_install dtbs_check -dtbs: include/config/kernel.release scripts_dtc +PHONY += dtbs dtbs_prepare dtbs_install dtbs_check +dtbs: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree)Quoted 6 lines
Makefile endif · line 1383
Quoted 4 lines
Makefile +4
-0+# include/config/kernel.release is not actually required for building DTBs, +# but for installing DTBs because INSTALL_DTBS_PATH contains $(KERNELRELEASE). +# We do not want to move it to dtbs_install. The policy is installation +# targets (, which may run as root) must not modify the tree.Is the comma after the opening parenthesis intended?
I will rephrase the comment in v2.
Quoted 11 lines
Kind regards,
NicolasQuoted 7 lines
Makefile +2
-1+dtbs_prepare: include/config/kernel.release scripts_dtc + ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) export CHECK_DTBS=y dtbs: dt_binding_check --2.34.1
Signature · 2 lines
Best Regards Masahiro Yamada
Signature · 3 lines
epost|xmpp: [email protected] irc://oftc.net/nsc ↳ gpg: 18ed 52db e34f 860e e9fb c82b 7d97 0932 55a0 ce7f -- frykten for herren er opphav til kunnskap --
Quoted 10 lines · Masahiro Yamada
Factor out the common prerequisites for DT compilation into the new target,
dtbs_prepare.Add comments in case you wonder why
include/config/kernel.releaseis the prerequisite. Our policy is that installation targets must not (re)compile any build artifacts in the tree. If we makemodules_installdepend oninclude/config/kernel.releaseand it is executed under the root privilege, it may be owned by root.Signed-off-by Masahiro Yamada <[email protected]>
With the comment fixed:
Quoted 36 lines
---
Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)Makefile +10
-4@@ -1367,16 +1367,22 @@ endif ifneq ($(dtstree),) -%.dtb: include/config/kernel.release scripts_dtc +%.dtb: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -%.dtbo: include/config/kernel.release scripts_dtc +%.dtbo: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ -PHONY += dtbs dtbs_install dtbs_check -dtbs: include/config/kernel.release scripts_dtc +PHONY += dtbs dtbs_prepare dtbs_install dtbs_check +dtbs: dtbs_prepare $(Q)$(MAKE) $(build)=$(dtstree) +# include/config/kernel.release is not actually required for building DTBs, +# but for installing DTBs because INSTALL_DTBS_PATH contains $(KERNELRELEASE). +# We do not want to move it to dtbs_install. The policy is installation +# targets (, which may run as root) must not modify the tree. +dtbs_prepare: include/config/kernel.release scripts_dtc + ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) export CHECK_DTBS=y dtbs: dt_binding_check
Signature · 2 lines
With best wishes Dmitry