Skip to content

Commit 3dae6ff

Browse files
committed
kbuild: macrofy the condition of if_changed and friends
JIRA: https://issues.redhat.com/browse/RHEL-2773 commit 6796e80 Author: Masahiro Yamada <masahiroy@kernel.org> Date: Fri Aug 13 15:30:04 2021 +0900 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> Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
1 parent b3dc398 commit 3dae6ff

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
@@ -146,13 +146,15 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))
146146
# PHONY targets skipped in both cases.
147147
newer-prereqs = $(filter-out $(PHONY),$?)
148148

149+
if-changed-cond = $(newer-prereqs)$(cmd-check)
150+
149151
# Execute command if command has changed or prerequisite(s) are updated.
150-
if_changed = $(if $(newer-prereqs)$(cmd-check), \
152+
if_changed = $(if $(if-changed-cond), \
151153
$(cmd); \
152154
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
153155

154156
# Execute the command and also postprocess generated .d dependencies file.
155-
if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:)
157+
if_changed_dep = $(if $(if-changed-cond),$(cmd_and_fixdep),@:)
156158

157159
cmd_and_fixdep = \
158160
$(cmd); \
@@ -162,7 +164,7 @@ cmd_and_fixdep = \
162164
# Usage: $(call if_changed_rule,foo)
163165
# Will check if $(cmd_foo) or any of the prerequisites changed,
164166
# and if so will execute $(rule_foo).
165-
if_changed_rule = $(if $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:)
167+
if_changed_rule = $(if $(if-changed-cond),$(rule_$(1)),@:)
166168

167169
###
168170
# why - tell why a target got built

0 commit comments

Comments
 (0)