Code dependencies in TONTO

It is often the case that when a certain program file is compiled, other dependent files must also be compiled.

There are two ways to tell make about dependencies; either hard code them into the makefile or an included file, or have a script automatically extract them from the source code. TONTO uses the latter method.

The perl script make_dependencies.perl extracts all the USE statements out of the source files, to build a dependency list. (Note however that the script does not look at #include statements.) These are then concatenated together to form a single file containing all USE dependencies, which is then include-ed in the Makefile. Also, TONTO makes use of a make pattern rules to summarise the common mode of compilation for all its modules.

In the stylised example below the source, object, script and module information files have all been separated into their own directories; this makies it tidy for large projects. The VPATH variable in the Makefile tells make to search in these separate directories for dependencies.

Say we have modules a, b, c which are used to construct program z, and b uses a, c uses b, and z uses c. (i.e. a simple linear hierarchy). Also presume each module resides in its own file.

Normally in the Makefile, we just have

b.o : a.o
c.o : b.o
z.x : a.o b.o c.o
where z.x is the executable, and the .o files are the object files.

In our Makefiles, we have

b.o : a.mod
c.o : b.mod
a.mod :
    make a.o
b.mod :
    make b.o
z.x : a.o b.o c.o
where z.x is the executable, and the .o files are the object files, and the .mod files are the module information files.

If the interface to module b stays constant, then modules a and c do not need recompiling, and only module b and program z need recompiling.

If the interface to module b changes, then module a does not need recompiling, and modules b and c and program z need recompiling.