Delayed Existence Checks

1 minute read

All Make variants process makefiles by looking for rules to build targets in the dependency tree. If no target rule is present, Make looks for a file on disk with the same name as the target. If this existence check fails, Make notes it has no rule to build the target.

eMake also exhibits this behavior, but for performance reasons it delays the existence check for a target without a makefile rule until just before that target is needed. The effect of this optimization is that eMake might run more commands to update targets (than GNU Make or NMAKE) before it discovers it has no rule to make a target.

For example, consider the following makefile:

all: nonexistent aa bb aa: @echo $@ bb: @echo $@

GNU Make begins by looking for a rule for nonexistent and, when it does not find the rule, it does a file existence check. When that fails, GNU Make terminates immediately with:

make: *** No rule to make target ’nonexistent’, needed by ’all’. Stop.

Similarly, NMAKE fails with:

NMAKE : fatal error U1073: don’t know how to make ’nonexistent’ Stop.

eMake delays the existence check for nonexistent until it is ready to run the all target. First, eMake finishes running commands to update the aa and bb prerequisites. eMake fails in the same way, but executes more targets first:

aa bb make: *** No rule to make target ’nonexistent’, needed by ’all’. Stop.

Of course, when the existence check succeeds (as it does in any successful build), there is no behavioral difference between eMake and GNU Make or Microsoft NMAKE.