summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2021-08-13 15:30:04 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2021-09-03 08:17:19 +0900
commit6796e80409b9031458e33dc39a3ac8aa3b93855b (patch)
treea41568b3062e43015f3a01a58f4cbea33a36be24 /scripts
parent55a6d00ed0c1b4d20d7966d00fda6848d776658d (diff)
downloadlinux-6796e80409b9031458e33dc39a3ac8aa3b93855b.tar.bz2
kbuild: macrofy the condition of if_changed and friends
Add a new macro that expands into $(newer-prereqs)$(cmd-check). It makes it easier to add common code for if_changed, if_changed_dep, and if_changed_rule. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include8
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index f247e691562d..c3c975a92318 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -130,13 +130,15 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))
# PHONY targets skipped in both cases.
newer-prereqs = $(filter-out $(PHONY),$?)
+if-changed-cond = $(newer-prereqs)$(cmd-check)
+
# Execute command if command has changed or prerequisite(s) are updated.
-if_changed = $(if $(newer-prereqs)$(cmd-check), \
+if_changed = $(if $(if-changed-cond), \
$(cmd); \
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
# Execute the command and also postprocess generated .d dependencies file.
-if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:)
+if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
cmd_and_fixdep = \
$(cmd); \
@@ -146,7 +148,7 @@ cmd_and_fixdep = \
# 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 $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:)
+if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:)
###
# why - tell why a target got built