[MITgcm-devel] makedepend and indirect dependencies
Oliver Jahn
jahn at MIT.EDU
Wed Feb 23 17:42:51 EST 2011
Below is an interesting excerpt from the makedepend man page.
Basically, makedepend caches indirect dependencies from include files it
has already looked at. This is a problem, since includes within ifdef's
in header files may change depending on which .F file the header file
was included from (an example is the dependence on SIZE.h in LAND_SIZE.h)
ALGORITHM
...
It parses each source and include file
exactly once, maintaining an internal symbol table for each. Thus, the
first file on the command line will take an amount of time proportional
to the amount of time that a normal C preprocessor takes. But on sub-
sequent files, if it encounters an include file that it has already
parsed, it does not parse it again.
For example, imagine you are compiling two files, file1.c and file2.c,
they each include the header file header.h, and the file header.h in
turn includes the files def1.h and def2.h. When you run the command
makedepend file1.c file2.c
makedepend will parse file1.c and consequently, header.h and then
def1.h and def2.h. It then decides that the dependencies for this file
are
file1.o: header.h def1.h def2.h
But when the program parses file2.c and discovers that it, too,
includes header.h, it does not parse the file, but simply adds
header.h, def1.h and def2.h to the list of dependencies for file2.o.
...
BUGS
...
Imagine you are parsing two files, say file1.c and file2.c, each
includes the file def.h. The list of files that def.h includes might
truly be different when def.h is included by file1.c than when it is
included by file2.c. But once makedepend arrives at a list of depen-
dencies for a file, it is cast in concrete.
More information about the MITgcm-devel
mailing list