Dependencies are built automatically. When compiling source-files into intermediate object files, each source-file is accompanied by an according dependency file. If the source-file is named x, then the dependency file is named .x.d. Typically these dependency files contain header files. For binary linking the same rules apply. Dependency files for binaries typically contain libraries. Dependency files are deleted on ``make cleanall''.
For generating of dependency files, we use two methods: If the host system provides and uses the dynamic linker ld.so, we use libgendep [3] to build the dependency files. libgendep uses the LD_PRELOAD method to overload the open()- and fopen()-functions of libc during compilation or linking. All files opened read-only are added to the list of dependencies for the current target. This is a flexible solution, as it can be used on a broad range of compilers, linkers and other tools. To enable this tool, set HAVE_LDSO (Section 8.1.3) to nonempty in your local configuration files.
If the host system does not provide ld.so, we fall back to the second method of dependency file generation: For compilation of C and C++ files, we use gcc to generate dependency files and postprocess those. For linking, we use a heuristic that mimics the behavior of the linker ld. Please note, that this heuristic does not reflect the exact behavior of the linker for efficiency reasons and has several problems (see below). For IDL compilation with dice, we use dice to generate according dependency files and postprocess those.
With both methods, dependency files are created automatically and they are used automatically. We avoid a typical error when dealing with dependency files: If a dependency file poses a dependency of a source-file src.c to an include file inc.h, and inc.h is deleted with the appropriate modification in src.c, the build process may fail: The make process notifies the dependency because of the unmodified dependency file, but make does not know how to build inc.h (albeit it is not needed anymore). Hence, make throws an error. We circumvent this by adding a rule ``inc.h:'' to the dependency file. The result is, that make rebuilds src.c if inc.h disappears -- exactly what we want.
However, the fall-back method for libraries has a problem with invalid symbolic links: If a symbolic but invalid link is found within the library directories, this is used for the library dependencies. This might be the wrong choice (as the actual library might appear later in the search path), resulting in an abortion of the compilation process.
L4 Checker 2012-04-11