GNU make:“无需对“目标”执行任何操作;与“目标”相比是最新的ÉD;

发布于 2024-11-02 23:33:18 字数 86 浏览 5 评论 0原文

GNU 如何决定发出哪些消息?我使用的 Makefile 导致当目标更新时,不对“目标”消息执行任何操作。但我认为“目标”是最新的会更合适。

How does GNU make decide which of the messages to emit? The Makefile I am using causes Nothing to be done for 'target' messages to be emitted when the target is up do date. But I think 'target' is up to date would be more appropriate.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

探春 2024-11-09 23:33:18

主要区别在于 gmake 是否有构建目标的规则。如果目标没有规则,但目标存在,那么 gmake 会说,“没什么可做的”,例如,“我不知道如何更新这个东西,但它已经存在,所以我猜有无事可做。”如果有规则,但目标已经是最新的,那么 gmake 会说“是最新的”,例如“我确实有更新这个东西的说明,但它似乎已经是最新的 -到目前为止,所以我不会做任何事情。”

这是一个具体的例子:

$ echo "upToDate: older ; @echo done" > Makefile
$ touch older ; sleep 2 ; touch upToDate ; touch nothingToDo
$ ls --full-time -l older upToDate nothingToDo
-rw-r--r-- 1 ericm ericm 0 2011-04-20 11:13:04.970243002 -0700 nothingToDo
-rw-r--r-- 1 ericm ericm 0 2011-04-20 11:13:02.960243003 -0700 older
-rw-r--r-- 1 ericm ericm 0 2011-04-20 11:13:04.960243001 -0700 upToDate
$ gmake upToDate
gmake: `upToDate' is up to date.
$ gmake nothingToDo
gmake: Nothing to be done for `nothingToDo'.

由于 gmake 没有“nothingToDo”规则,但文件已经存在,因此您会收到“nothing to be do”消息。如果“nothingToDo”不存在,您将收到熟悉的“无规则可制定”消息。

相反,由于 gmake 有“upToDate”规则,并且文件看起来是最新的,因此您会收到“is up to date”消息。

The chief difference is in whether gmake has a rule to build the target or not. If there is no rule for the target, but the target exists, then gmake will say, "Nothing to be done", as in, "I don't know how to update this thing, but it already exists, so I guess there's nothing to be done." If there is a rule, but the target is already up-to-date, then gmake will say, "is up to date", as in, "I do have instructions for updating this thing, but it appears to already be up-to-date, so I'm not going to do anything."

Here's a concrete example:

$ echo "upToDate: older ; @echo done" > Makefile
$ touch older ; sleep 2 ; touch upToDate ; touch nothingToDo
$ ls --full-time -l older upToDate nothingToDo
-rw-r--r-- 1 ericm ericm 0 2011-04-20 11:13:04.970243002 -0700 nothingToDo
-rw-r--r-- 1 ericm ericm 0 2011-04-20 11:13:02.960243003 -0700 older
-rw-r--r-- 1 ericm ericm 0 2011-04-20 11:13:04.960243001 -0700 upToDate
$ gmake upToDate
gmake: `upToDate' is up to date.
$ gmake nothingToDo
gmake: Nothing to be done for `nothingToDo'.

Since gmake has no rule for "nothingToDo", but the file already exists, you get the "nothing to be done" message. If "nothingToDo" did not exist, you would instead get the familiar, "No rule to make" message.

In contrast, because gmake has a rule for "upToDate", and the file appears to be up-to-date, you get the "is up to date" message.

や莫失莫忘 2024-11-09 23:33:18

我研究了这个问题,并测试了很多场景,得到的结果是:

如果目标没有配方并且没有执行任何先决条件的配方,则 Nothing to be do for "top target" 将打印

如果目标有配方,但未执行配方,则打印 is up to date

如果现有文件没有规则,则将该现有文件作为目标也打印 Nothing to be did for "xxx"

I research this problem, and test a lot of scenes, the result I got is:

If the target has no recipe and if no any prerequisites' recipes are executed, then Nothing to be done for "top target" will printed

If the target has recipe, but the recipe is not executed, then is up to date is printed.

If no rules for a existing file, and make that existing file as target also print Nothing to be done for "xxx"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文