继续翻译

5.6 Interrupting or Killing `make'
==================================

If `make' gets a fatal signal while a shell is executing, it may delete
the target file that the recipe was supposed to update.  This is done
if the target file's last-modification time has changed since `make'
first checked it.

   The purpose of deleting the target is to make sure that it is remade
from scratch when `make' is next run.  Why is this?  Suppose you type
`Ctrl-c' while a compiler is running, and it has begun to write an
object file `foo.o'.  The `Ctrl-c' kills the compiler, resulting in an
incomplete file whose last-modification time is newer than the source
file `foo.c'.  But `make' also receives the `Ctrl-c' signal and deletes
this incomplete file.  If `make' did not do this, the next invocation
of `make' would think that `foo.o' did not require updating--resulting
in a strange error message from the linker when it tries to link an
object file half of which is missing.

   You can prevent the deletion of a target file in this way by making
the special target `.PRECIOUS' depend on it.  Before remaking a target,
`make' checks to see whether it appears on the prerequisites of
`.PRECIOUS', and thereby decides whether the target should be deleted
if a signal happens.  Some reasons why you might do this are that the
target is updated in some atomic fashion, or exists only to record a
modification-time (its contents do not matter), or must exist at all
times to prevent other sorts of trouble.

5.6 打断或者杀死 make
==================================

如果shell 正在运行时,make 获得一个严重的信号,它可能会删除掉正打算变更的文件。如果目的文件的最近修改时间变更了就会发生。

删除目的文件的目的是确保下次 make 运行时它可以再次被重新生成。为何如此?设想一下你正当编译器在运行时,你输入了 Ctrl-C, 此时编译器已经开始写一个目标文件 foo.o。 Ctrl-C 杀死了编译器,导致了一个不完整的文件,它的最后修改时间比源文件要新。但是make 也收到了 Ctrl-C 信号,并且删除了此不完整的文件。如果make  不这样做,make 下次激活时就会认为 foo.o不需要修改--导致链接器准备链接此目标文件时,将要报告奇怪的错误。

你可以通过设置 特殊目的 .PRECIOUS ,令它依赖于特定目的文件,来防止删除。在重新生成一个目的之前,make 检查是否此目的文件出现在.PRECIOUS 目的的前提条件里,然后如果一个信号发生了据此决定是否要删除一个目的。这么做的原因是有些目的是会自动化地变更的或者仅仅是为了记录变更时间(内容如何无关紧要),或者必须一直存在以防止其它的困扰。

后文待续