Making Trouble
Here is a puzzle for software developers who know about the GNU make tool. Answer after the fold below.
Say we have a makefile target for a file called timestamp
. As you might guess, the file contains the current time as reported by the date
utility. Let’s see what happens when we try to make
it:
$ ls timestamp ls: timestamp: No such file or directory $ make timestamp make: `timestamp' is up to date. $ ls timestamp ls: timestamp: No such file or directory
Hmm. What’s going on here? Perhaps timestamp is a phony target? Maybe the debug output will be more enlightening:
$ make -dr timestamp GNU Make 3.80 [... irrelevant output snipped ...] Updating goal targets.... Considering target file `timestamp'. File `timestamp' does not exist. Finished prerequisites of target file `timestamp'. Must remake target `timestamp'. Successfully remade target file `timestamp'. make: `timestamp' is up to date.
OK that didn’t help. So I bet you’re dying to look at the Makefile.
DATE=/bin/date timestamp : ${DATE) > ${@}
You don’t need to know anything special about makefiles to solve this one. Perhaps the only non-obvious part is that the @
variable refers to “the current target”, in this case the timestamp
file.
Worked it out yet?
[Read more →]