make 如何判断文件何时未被修改?
How does make tell when a file hasn't been modified?
Make 可以判断自上次 make
调用以来文件是否已被修改。我想它将文件的修改时间与上次构建的时间进行比较。为此,它必须将最新时间存储在磁盘上,对吧?
有人知道它是否以及在何处或如何做到这一点吗?
谢谢。
它不会那样做。
相反,它将目标的修改时间与其依赖项的修改时间进行比较。所以当你有一个规则
foo-sorted: foo; sort $< > $@
比较foo-sorted
和foo
的修改时间。
我猜你看起来并没有很难找到答案:
http://www.gnu.org/software/make/ If a target file is newer than all of its dependencies, then it is already up to date, and it does not need to be regenerated.
http://www.gnu.org/software/make/manual/html_node/Rule-Syntax.html The criterion for being out of date is specified in terms of the prerequisites, which consist of file names separated by spaces. [...] A target is out of date if it does not exist or if it is older than any of the prerequisites (by comparison of last-modification times). The idea is that the contents of the target file are computed based on information in the prerequisites, so if any of the prerequisites changes, the contents of the existing target file are no longer necessarily valid.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html The make utility examines time relationships and shall update those derived files (called targets) that have modified times earlier than the modified times of the files (called prerequisites) from which they are derived.
Make 可以判断自上次 make
调用以来文件是否已被修改。我想它将文件的修改时间与上次构建的时间进行比较。为此,它必须将最新时间存储在磁盘上,对吧?
有人知道它是否以及在何处或如何做到这一点吗?
谢谢。
它不会那样做。
相反,它将目标的修改时间与其依赖项的修改时间进行比较。所以当你有一个规则
foo-sorted: foo; sort $< > $@
比较foo-sorted
和foo
的修改时间。
我猜你看起来并没有很难找到答案:
http://www.gnu.org/software/make/ If a target file is newer than all of its dependencies, then it is already up to date, and it does not need to be regenerated.
http://www.gnu.org/software/make/manual/html_node/Rule-Syntax.html The criterion for being out of date is specified in terms of the prerequisites, which consist of file names separated by spaces. [...] A target is out of date if it does not exist or if it is older than any of the prerequisites (by comparison of last-modification times). The idea is that the contents of the target file are computed based on information in the prerequisites, so if any of the prerequisites changes, the contents of the existing target file are no longer necessarily valid.
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html The make utility examines time relationships and shall update those derived files (called targets) that have modified times earlier than the modified times of the files (called prerequisites) from which they are derived.