On Thu, 2026-09-24 at 09:50 -0700, Jon Forrest wrote:
> I have a mental model of how all this works. Please let me know
> if it's wrong.
> 
> "Checking each prerequisite" means making sure that any files the
> prerequisite mentions exist (among other things).
> 
> "They" means the two approaches we're discussing.
> 
> Make builds a dependency graph by reading the makefile. Then, make
> descends to the lowest vertex and starts building targets from
> prerequisites. At this point if a prerequisite doesn't exist,
> and there's no deeper rule for it, then the error message I mentioned
> is generated.

This isn't really correct, at least not in the details.

The way make works is it first reads all makefiles and constructs an
internal acyclical directed graph representing all the relationships
between targets and their prerequisites.

Then, make starts at the node in that graph representing the goal
target to be built.

The first thing it does it recursively consider each of the
prerequisites, or child nodes.

If a node has no prerequisites, or when all prerequisites have been
considered, then make will compare the modification time of all those
prerequisites (if any) against the modification time of the current
target, and if any prerequisite has a newer timestamp then it's
considered out of date and the recipe is invoked to rebuild it.  If a
node has no children then it's considered up-to-date if it exists, or
out of date if it doesn't.

You can see that there is no difference between "target" and
"prerequisite" that is inherent in the node itself: any node is a
target when it's being considered and the child nodes are
prerequisites, but then when make considers each prerequisite, that
node is now the target and ITS child nodes are prerequisites.

Reply via email to