虚假目标的时间戳

Timestamp for phony target

如何在 makefile 中为 .PHONY 个目标添加时间戳

phony_Target:Real_Target .phony_Target_Token_File
    $(shell run_some_commands)
    touch .phony_Target_Token_File

这是我能想到的最好的。但是当 .phony_Target_Token_File 不存在时它会崩溃(因为这被视为未满足的先决条件)。

有没有更聪明的方法?

.PHONY 目标不遵守先决条件时间戳来确定它们是否应该 运行。他们总是 运行。这就是他们的目的。1.

我想您可能正在寻找一个 empty target 用作某个事件发生的标记。