GNU make manual 翻译( 一百零五)
继续翻译
4.8 Empty Target Files to Record Events ======================================= The "empty target" is a variant of the phony target; it is used to hold recipes for an action that you request explicitly from time to time. Unlike a phony target, this target file can really exist; but the file's contents do not matter, and usually are empty. The purpose of the empty target file is to record, with its last-modification time, when the rule's recipe was last executed. It does so because one of the commands in the recipe is a `touch' command to update the target file. The empty target file should have some prerequisites (otherwise it doesn't make sense). When you ask to remake the empty target, the recipe is executed if any prerequisite is more recent than the target; in other words, if a prerequisite has changed since the last time you remade the target. Here is an example: print: foo.c bar.c lpr -p $? touch print With this rule, `make print' will execute the `lpr' command if either source file has changed since the last `make print'. The automatic variable `$?' is used to print only those files that have changed (*note Automatic Variables::).
4.8 用于记录事件的空的Target 文件
=======================================
空目的是伪目的的变种;它被用于保持你一次又一次显式运行的片段,而不像一个伪目的,这个目的文件可以确实存在;但是文件内容是什么无所谓,而且通常是空的。
空目的文件的作用是用来通过最后修改时间来记录,片段何时进行了最后一次运行。它这么作是因为片段中的命令中有一个 touch 命令来修改目的文件。
空目的文件应当有一些前提条件(否则没有什么意义)。当你要求更新空目的,如果任何前提条件比目的新,则片段得到执行;换句话说,就是自从上次你重新建立了目的,前提条件改变了,则片段得到执行。这里是一个例子:
print: foo.c bar.c
lpr -p $?
touch print
对此规则,如果任何一个源文件发生了变化则make print 将要执行 lpr 命令。自动变量$?用于列出上次变化后的文件名(*note Automatic Variables::)
后文待续