NMAKE May Assume Inferred Dependent Files

ID: Q92735

The information in this article applies to:

SUMMARY

In a Microsoft NMAKE makefile, an inference rule can create one or more inferred dependent files. According to page 659 of the Microsoft C/C++ "Environment and Tools" manual for version 7.0, NMAKE considers inferred dependent files and places them into the dependency list. In some cases, this behavior may appear incorrect. However, as the first makefile in the text below illustrates, this is expected behavior.

The second makefile below illustrates the correct method. Changing the macro substitution from "$(?: = " to "$(obj: = " succeeds because the substitution creates an explicit macro [$(objs)] instead of a predefined macro [$(?)]. NMAKE uses the explicit macro as a source for inferred dependent files.

MORE INFORMATION

The following two makefiles compile TEST1.C, TEST2.C, and TEST3.C using the user-defined inference rule, and generates a linker response file for the Microsoft LINK utility.

NOTE: This is a 16-bit specific example.

Makefile 1 (Incorrect)

   objs = test1.obj test2.obj test3.obj
   .c.obj:
      cl /c /AM /FPi87 /Od /f $*.c

   test1.exe : $(objs)
      link /NOI /NOPACKC /ST:2048 @<<make.lrf
   $(?: = +^
   )

   NUL

   my.def;
   <<NOKEEP

Makefile 2 (Correct)

   objs = test1.obj test2.obj test3.obj
   .c.obj:
      cl /c /AM /FPi87 /Od /f $*.c

   test1.exe : $(objs)
      link /NOI /NOPACKC /ST:2048 @<<make.lrf
   $(objs: = +^
   )

   NUL

   my.def;
   <<NOKEEP

Additional reference words: kbinf kbinf 1.20 1.30 1.40 1.50 KBCategory: kbtool KBSubcategory: NmakeIss

Last Reviewed: February 15, 1995