D. J. Bernstein
Data structures and program structures
Rebuilding target files when source files have changed
Files in other directories are targets
There are three basic points here:
- If dhcp.c includes ../lib/socket.h
then dhcp.o has to be rebuilt when ../lib/socket.h is changed.
For example, a Makefile for dhcp.o
has to list ../lib/socket.h as a prerequisite for dhcp.o.
- If ../lib/socket.h is itself a target that depends on other files,
and if the user asks to rebuild dhcp.o
when those other files have changed,
then ../lib/socket.h has to be rebuilt first.
This means that the Makefile for dhcp.o
has to include the prerequisites and build commands for ../lib/socket.h.
- Maintaining a Makefile in the current directory
with the prerequisites and build commands
for dhcp.o and ../lib/socket.h,
along with a Makefile in the ../lib directory
with the prerequisites and build commands
for ../lib/socket.h,
is more difficult and error-prone
than setting up a single Makefile that covers both directories.
These points are explained in more detail in Peter Miller's paper
Recursive make considered harmful.
In principle,
the same points should apply to files in system directories.
For example,
if I install a new version of GMP,
I'd like to automatically recompile all the applications
that depend on /usr/include/gmp.h and the other modified files.
In practice,
this seems rather painful
without prerequisite tracking in the filesystem.
(Dare I mention cross-Internet targets?
I think not.)