Recursive make Reloaded
It’s been eight years since recursive make was called” harmful,” but developers still use it. Here’s how to break the habit.
In 1997, Peter Miller wrote a now famous paper entitled “Recursive
make Considered Harmful” (available online at (
http://www.pcug.org.au/~millerp/rmch/recu-make-cons-harm.html), which details why recursive use of
make is slow, problematic, and
unnecessary. But eight years later, it’s still common to see recursive
make used in projects. Even
GNU make itself has a recursive
Makefile!
Yet recursive make is easy to avoid and undo. Let’s look at a short, working example that eliminates recursive make. As you’ll see, you can use the very same model to write new Makefile s that are effective, easy to maintain, and fast. Your improved Makefile s can also leverage parallel compilation for maximum speed.
Recursive make is fundamentally wrong because it breaks the one thing that make is really good at: tracking the dependencies between files. Each call to make generates a separate graph of dependencies between objects and source code. At best, the separate graphs may actually be unrelated, but in many situations may contain the same files.