Skip to content

Commit 6796e80

Browse files
committed
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>
1 parent 55a6d00 commit 6796e80

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/Kbuild.include

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))
130130
# PHONY targets skipped in both cases.
131131
newer-prereqs = $(filter-out $(PHONY),$?)
132132

133+
if-changed-cond = $(newer-prereqs)$(cmd-check)
134+
133135
# Execute command if command has changed or prerequisite(s) are updated.
134-
if_changed = $(if $(newer-prereqs)$(cmd-check), \
136+
if_changed = $(if $(if-changed-cond), \
135137
$(cmd); \
136138
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
137139

138140
# Execute the command and also postprocess generated .d dependencies file.
139-
if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:)
141+
if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
140142

141143
cmd_and_fixdep = \
142144
$(cmd); \
@@ -146,7 +148,7 @@ cmd_and_fixdep = \
146148
# Usage: $(call if_changed_rule,foo)
147149
# Will check if $(cmd_foo) or any of the prerequisites changed,
148150
# and if so will execute $(rule_foo).
149-
if_changed_rule = $(if $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:)
151+
if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:)
150152

151153
###
152154
# why - tell why a target got built

0 commit comments

Comments
 (0)