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


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.

Best Solution

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.