The cmd-check for KBUILD_NOCMDDEP=1 may not be clear until you see commit c4d5ee13984f ("kbuild: make KBUILD_NOCMDDEP=1 handle empty built-in.o"). When a phony target (i.e. FORCE) is the only prerequisite, Kbuild uses a tricky way to detect that the target does not exist. Add more comments.
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -170,9 +170,13 @@ cmd = @$(if $(cmd_$(1)),set -e; $($(quiet)log_print) $(delete-on-interrupt) $(cm · 169 unmodified lines | |||
| 170 | ifneq ($(KBUILD_NOCMDDEP),1) | 170 | ifneq ($(KBUILD_NOCMDDEP),1) |
| 171 | # Check if both commands are the same including their order. Result is empty | 171 | # Check if both commands are the same including their order. Result is empty |
| 172 | # string if equal. User may override this check using make KBUILD_NOCMDDEP=1 | 172 | # string if equal. User may override this check using make KBUILD_NOCMDDEP=1 |
| 173 | # If the target does not exist, the *.cmd file should not be included so | ||
| 174 | # $(savedcmd_$@) gets empty. Then, target will be built even if $(newer-prereqs) | ||
| 175 | # happens to become empty. | ||
| 173 | cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(savedcmd_$@))), \ | 176 | cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(savedcmd_$@))), \ |
| 174 | $(subst $(space),$(space_escape),$(strip $(cmd_$1)))) | 177 | $(subst $(space),$(space_escape),$(strip $(cmd_$1)))) |
| 175 | else | 178 | else |
| 179 | # We still need to detect missing targets. | ||
| 176 | cmd-check = $(if $(strip $(savedcmd_$@)),,1) | 180 | cmd-check = $(if $(strip $(savedcmd_$@)),,1) |
| 177 | endif | 181 | endif |
| 178 | 182 | ||
| @@ -186,6 +190,8 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))) · 7 unmodified lines | |||
| 186 | 190 | ||
| 187 | # Find any prerequisites that are newer than target or that do not exist. | 191 | # Find any prerequisites that are newer than target or that do not exist. |
| 188 | # PHONY targets skipped in both cases. | 192 | # PHONY targets skipped in both cases. |
| 193 | # If there is no prerequisite other than phony targets, $(newer-prereqs) becomes | ||
| 194 | # empty even if the target does not exist. cmd-check saves this corner case. | ||
| 189 | newer-prereqs = $(filter-out $(PHONY),$?) | 195 | newer-prereqs = $(filter-out $(PHONY),$?) |
| 190 | 196 | ||
| 191 | # It is a typical mistake to forget the FORCE prerequisite. Check it here so | 197 | # It is a typical mistake to forget the FORCE prerequisite. Check it here so |