GNU Make manual says: $? The names of all the prerequisites that are newer than the target, with spaces between them. To reflect this, rename any-prereq to newer-prereqs, which is clearer and more intuitive.
Unified · Split
| @@ -215,15 +215,15 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))) · 214 unmodified lines | |||
| 215 | # but it does not work as expected when .SECONDARY is present. This seems a bug | 215 | # but it does not work as expected when .SECONDARY is present. This seems a bug |
| 216 | # of GNU Make.) | 216 | # of GNU Make.) |
| 217 | # PHONY targets skipped in both cases. | 217 | # PHONY targets skipped in both cases. |
| 218 | any-prereq = $(filter-out $(PHONY),$?) | 218 | newer-prereqs = $(filter-out $(PHONY),$?) |
| 219 | 219 | ||
| 220 | # Execute command if command has changed or prerequisite(s) are updated. | 220 | # Execute command if command has changed or prerequisite(s) are updated. |
| 221 | if_changed = $(if $(any-prereq)$(cmd-check), \ | 221 | if_changed = $(if $(newer-prereqs)$(cmd-check), \ |
| 222 | $(cmd); \ | 222 | $(cmd); \ |
| 223 | printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) | 223 | printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) |
| 224 | 224 | ||
| 225 | # Execute the command and also postprocess generated .d dependencies file. | 225 | # Execute the command and also postprocess generated .d dependencies file. |
| 226 | if_changed_dep = $(if $(any-prereq)$(cmd-check),$(cmd_and_fixdep),@:) | 226 | if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:) |
| 227 | 227 | ||
| 228 | cmd_and_fixdep = \ | 228 | cmd_and_fixdep = \ |
| 229 | $(cmd); \ | 229 | $(cmd); \ |
| @@ -233,7 +233,7 @@ cmd_and_fixdep = \ · 3 unmodified lines | |||
| 233 | # Usage: $(call if_changed_rule,foo) | 233 | # Usage: $(call if_changed_rule,foo) |
| 234 | # Will check if $(cmd_foo) or any of the prerequisites changed, | 234 | # Will check if $(cmd_foo) or any of the prerequisites changed, |
| 235 | # and if so will execute $(rule_foo). | 235 | # and if so will execute $(rule_foo). |
| 236 | if_changed_rule = $(if $(any-prereq)$(cmd-check),$(rule_$(1)),@:) | 236 | if_changed_rule = $(if $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:) |
| 237 | 237 | ||
| 238 | ### | 238 | ### |
| 239 | # why - tell why a target got built | 239 | # why - tell why a target got built |
| @@ -258,7 +258,7 @@ ifeq ($(KBUILD_VERBOSE),2) · 18 unmodified lines | |||
| 258 | why = \ | 258 | why = \ |
| 259 | $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ | 259 | $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ |
| 260 | $(if $(wildcard $@), \ | 260 | $(if $(wildcard $@), \ |
| 261 | $(if $(any-prereq),- due to: $(any-prereq), \ | 261 | $(if $(newer-prereqs),- due to: $(newer-prereqs), \ |
| 262 | $(if $(cmd-check), \ | 262 | $(if $(cmd-check), \ |
| 263 | $(if $(cmd_$@),- due to command line change, \ | 263 | $(if $(cmd_$@),- due to command line change, \ |
| 264 | $(if $(filter $@, $(targets)), \ | 264 | $(if $(filter $@, $(targets)), \ |