From afba83ad89d5b17fc49f47df3a8c031a23815d1a Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:12 +0300 Subject: kbuild: de-duplicate fixdep usage Backported from the linux kernel commit e4aca4595005 ("kbuild: de-duplicate fixdep usage") A lot of the kernels kbuild depend on that patch. Backport it and pull in the 'rule_as_o_S'a rule as well. This might end up being unused but it doesn't break anything and makes diffing the files easier. Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/Kbuild.include') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 054dd157485..7468223d323 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -266,10 +266,13 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ # Execute the command and also postprocess generated .d dependencies file. if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ @set -e; \ + $(cmd_and_fixdep), @:) + +cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd, @:) + mv -f $(dot-target).tmp $(dot-target).cmd; # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, -- cgit v1.2.3 From a73c41c398a1cbbe9aa7ffb644729e6cf7595845 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:19 +0300 Subject: kbuild: add real-prereqs shorthand for $(filter-out FORCE, $^) Backport from kernel commit afa974b77128 ("kbuild: add real-prereqs shorthand for $(filter-out FORCE,$^)") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts/Kbuild.include') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 7468223d323..2ef687ea895 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -27,6 +27,10 @@ basetarget = $(basename $(notdir $@)) # filename of first prerequisite with directory and extension stripped baseprereq = $(basename $(notdir $<)) +### +# real prerequisites without phony targets +real-prereqs = $(filter-out $(PHONY), $^) + ### # Escape single quote for use in echo statements escsq = $(subst $(squote),'\$(squote)',$1) -- cgit v1.2.3 From cc571e29a8ecbba909cbb04ba062db026f70ae8b Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:22 +0300 Subject: kbuild: let fixdep directly write to .*.cmd files Backport from kernel commit 392885ee82d3 ("kbuild: let fixdep directly write to .*.cmd files") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scripts/Kbuild.include') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 2ef687ea895..6ef66c451eb 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -274,9 +274,8 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ cmd_and_fixdep = \ $(echo-cmd) $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ - rm -f $(depfile); \ - mv -f $(dot-target).tmp $(dot-target).cmd; + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ + rm -f $(depfile) # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, -- cgit v1.2.3 From daf8f5af4c9e542ac75b2ddf7f2831b73833b49d Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Tue, 20 May 2025 08:21:25 +0300 Subject: kbuild: change if_changed_rule for multi-line recipe Backport from kernel commit 3a2429e1faf4 ("kbuild: change if_changed_rule for multi-line recipe") Signed-off-by: Ilias Apalodimas --- scripts/Kbuild.include | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'scripts/Kbuild.include') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 6ef66c451eb..c0d3440a4b3 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -226,7 +226,7 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) # printing commands -cmd = @$(echo-cmd) $(cmd_$(1)) +cmd = @set -e; $(echo-cmd) $(cmd_$(1)) # Add $(obj)/ for paths that are not absolute objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) @@ -268,21 +268,17 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) # Execute the command and also postprocess generated .d dependencies file. -if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ - @set -e; \ - $(cmd_and_fixdep), @:) +if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),$(cmd_and_fixdep),@:) cmd_and_fixdep = \ - $(echo-cmd) $(cmd_$(1)); \ + $(cmd); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ rm -f $(depfile) # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, # and if so will execute $(rule_foo). -if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ - @set -e; \ - $(rule_$(1)), @:) +if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)),$(rule_$(1)),@:) ### # why - tell why a a target got build -- cgit v1.2.3