NMAKE can assume an “inferred dependent” for a target if there is an applicable inference rule. An inference rule is applicable if:
The toext in the rule matches the extension of the target being evaluated.
The fromext in the rule matches the extension of a file that has the same base name as the target and that exists in the current or specified directory.
The fromext is in the .SUFFIXES list.
No other fromext in a matching rule is listed in .SUFFIXES with a higher priority.
No explicitly specified dependent has a higher priority extension.
If an existing dependent matches an inference rule and has an extension with a higher .SUFFIXES priority, NMAKE does not infer a dependent.
NMAKE does not necessarily execute the commands block in an inference rule for an inferred dependent. If the target's description block contains commands, NMAKE executes the description block's commands and not the commands in the inference rule. The effect of an inferred dependent is illustrated in the following example:
project.obj :
cl /Zi /c project.c
If a makefile contains this description block and if the current directory contains a file named PROJECT.C and no other files, NMAKE uses the predefined inference rule for .c.obj to infer the dependent project.c. It does not execute the predefined rule's command, cl /c project.c. Instead, it runs the command specified in the makefile.
Inferred dependents can cause unexpected side effects. In the following examples, assume that both PROJECT.ASM and PROJECT.C exist and that .SUFFIXES contains the default setting. If the makefile contains
project.obj : project.c
NMAKE infers the dependent project.asm ahead of project.c because .SUFFIXES lists .asm before .c and because a rule for .asm.obj exists. If either PROJECT.ASM or PROJECT.C is out-of-date, NMAKE executes the commands in the rule for .asm.obj.
However, if the dependency in the preceding example is followed by a commands block, NMAKE executes those commands and not the commands in the inference rule for the inferred dependent.
Another side effect occurs because NMAKE builds a target if it is out-of-date with respect to any of its dependents, whether explicitly specified or inferred. For example, if PROJECT.OBJ is up-to-date with respect to PROJECT.C but not with respect to PROJECT.ASM, and if the makefile contains
project.obj : project.c
cl /Zi /c project.c
NMAKE infers the dependent project.asm and updates the target using the command specified in this description block.