Auto-Dependency Generation 2

Traditional make depend Method

The time-honored method of handling dependency generation is to provide a special target in your makefiles, typically depend, which can be invoked to create dependency information. The command for this target will invoke some kind of dependency tracking tool on all the relevant files in the directory, which will generate makefile-formatted dependency information.

If your version of make supports include you can redirect this to a file and simply include the file. If not, this usually also involves some shell hackery to append the list of dependencies generated to the end of the makefile itself.

Although it’s simple, there are serious problems with this method. First and foremost is that dependencies are only rebuilt when the user explicitly requests it; if the user doesn’t run make depend regularly they could become badly out-of-date and make will not properly rebuild targets. Thus, we cannot say this is seamless and accurate.

A secondary problem is that it is inefficient to run make depend, particularly after the first time.

第二个问题是, 运行 make depend 是没有效率的, 特别是在第一次之后。

Since it modifies makefiles, you typically must do it as a separate build step, which means an extra

既然make depend 会修改makefiles, 你必须作为一个独立的编译步骤。意味着每一个子目录的make的额外的调用的开销,以及make depend 工具本身的开销。并且,它会检查每一个文件的依赖, 甚至没有发生改变。

invocation of every make in every make, etc., in addition to the overhead of the dependency-generation tool itself. Also, it rechecks every file’s dependencies, even those which haven’t changed.

So, we’ll see how we can do better.

猜你喜欢

转载自daojin.iteye.com/blog/2276140