继续翻译
4.5.3 How Directory Searches are Performed ------------------------------------------ When a prerequisite is found through directory search, regardless of type (general or selective), the pathname located may not be the one that `make' actually provides you in the prerequisite list. Sometimes the path discovered through directory search is thrown away. The algorithm `make' uses to decide whether to keep or abandon a path found via directory search is as follows: 1. If a target file does not exist at the path specified in the makefile, directory search is performed. 2. If the directory search is successful, that path is kept and this file is tentatively stored as the target. 3. All prerequisites of this target are examined using this same method. 4. After processing the prerequisites, the target may or may not need to be rebuilt: a. If the target does _not_ need to be rebuilt, the path to the file found during directory search is used for any prerequisite lists which contain this target. In short, if `make' doesn't need to rebuild the target then you use the path found via directory search. b. If the target _does_ need to be rebuilt (is out-of-date), the pathname found during directory search is _thrown away_, and the target is rebuilt using the file name specified in the makefile. In short, if `make' must rebuild, then the target is rebuilt locally, not in the directory found via directory search. This algorithm may seem complex, but in practice it is quite often exactly what you want. Other versions of `make' use a simpler algorithm: if the file does not exist, and it is found via directory search, then that pathname is always used whether or not the target needs to be built. Thus, if the target is rebuilt it is created at the pathname discovered during directory search. If, in fact, this is the behavior you want for some or all of your directories, you can use the `GPATH' variable to indicate this to `make'. `GPATH' has the same syntax and format as `VPATH' (that is, a space-or colon-delimited list of pathnames). If an out-of-date target is found by directory search in a directory that also appears in `GPATH', then that pathname is not thrown away. The target is rebuilt using the expanded path.
4.5.3 目录搜索如何执行
------------------------------------------
当一个前提条件通过目录搜索被发现后,无论其类型(通用的或有选择性的),路径名不能使make 在前提条件中实际提供给你的。有时在目录搜索中发现的路径会被舍弃。
make所用的决定是保持还是放弃通过目录搜索获得的路径的算法如下:
1. 如果一个文件不在makefile所指定的路径之下,则目录搜索开始。
2. 如果目录搜索成功,则此路径被保持,并且此文件被暂时性地保留为目的。
3. 所有的此目的的前提条件都会被用同样的方法进行搜索。
4. 当对前提条件的处理结束后,目的将会或不会需要重新建立:
a.如果目的不需要被重新建立,在目录搜索中发现的文件的路径将被用于包含此目的的前提条件中。简短来说,如果make 不需要重新建立目的,那么你就使用在目录搜索中发现的路径。
b. If the target _does_ need to be rebuilt (is out-of-date), the
pathname found during directory search is _thrown away_, and
the target is rebuilt using the file name specified in the
makefile. In short, if `make' must rebuild, then the target
is rebuilt locally, not in the directory found via directory
search.
b. 如果目的需要被重建(陈旧),在目录搜索中发现的路径名会被舍弃,目的会被利用makefile中指定的文件名来重建。简短来说,如果 make 必须重建,则目的利用本地内容来重建,而不是用在目录搜索中发现的目录名来重建。
此算法看上去挺复杂,但在实践中却常常正是你想要的。
其他版本的 make 使用一个简单一点的算法,如果文件不存在,并且在目录搜索发现了此文件,那么此路径名无论目的是否需重建都被使用。所以,如果目的被重建,他将被建立到目录搜索中发现的路径下。
如果,实际上,这是你为所有的目录所期待的结果,你可以用 GPATH 变量来告诉make 这样做。
GPATH 拥有和 VPATH 一样的语法(即 空格或者冒号分隔的路径名)。如果一个过期的目的在目录搜索中被发现,那么此路径名不会被抛弃,此目的会被用扩展的路径名来重建。
后文待续