NMAKE Help (nmake.hlp) (Table of Contents; Topic list)
Inferred Dependents
                                             Up Contents Index Back
─────NMAKE──────────────────────────────────────────────────────────────────
 
     NMAKE can assume an inferred dependent for a target if there is an
     applicable inference rule.
 
          .fromext.toext:
            commands
 
          target : dependent
 
     See: Dependents
          Inference Rules
          Targets
 
     Rules for Inferred Dependents
 
     An inference rule is applicable if:
 
        ■ <toext> matches the extension of <target>.
 
        ■ <fromext> matches the extension of a file in the current or
          specified directory that has the same base name as <target>.
 
        ■ <fromext> is in the .SUFFIXES list.
          See: .SUFFIXES Directive
 
        ■ No other <toext> rule has a <fromext> with a higher priority.
 
        ■ <dependent> does not have higher priority (or is unspecifed)
 
     If <dependent> is specifed, matches an inference rule, and has a
     higher .SUFFIXES priority, NMAKE does not infer a dependent.
 
     Effect of an Inferred Dependent
 
     NMAKE does not necessarily execute the <commands> in an inference
     rule for an inferred dependent. If <target>'s description block
     contains commands, NMAKE executes the description block's commands
     and not the inference rule's commands. The effect is as follows:
 
          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 rule for .c.obj to infer the dependent
     called project.c. It does not execute the predefined rule's
     command (cl /c project.c). Instead, it runs the specified command.
 
     Caution
 
     Inferred dependents can cause unexpected side effects.
 
     Assume that both PROJECT.ASM and PROJECT.C exist, that .SUFFIXES
     contains the default setting, and that the following dependency
     line is in the makefile:
 
          project.obj : project.c
 
     Given this dependency line, NMAKE infers a dependent called
     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 is followed by a commands block,
     NMAKE executes the specified 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 they
     are explicitly specified or inferred.
 
     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
 
     then NMAKE infers the dependent project.asm and unnecessarily
     updates project.obj using the command cl /Zi /c project.c.
                                    -♦-