开发者

GNU make: “Nothing to be done for 'target'” vs. “'target' is up to date”

开发者 https://www.devze.com 2023-02-28 04:33 出处:网络
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 th

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.


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.


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"

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号