Microsoft KB Archive/59526

From BetaArchive Wiki
Knowledge Base


Multiple Dependency Blocks Are Not Cumulative

Article ID: 59526

Article Last Modified on 12/1/2003



APPLIES TO

  • Microsoft Program Maintenance Utility 1.2
  • Microsoft Program Maintenance Utility 1.2
  • Microsoft Program Maintenance Utility 1.2
  • Microsoft Program Maintenance Utility 1.2
  • Microsoft Program Maintenance Utility 1.2
  • Microsoft Program Maintenance Utility 1.2
  • Microsoft Program Maintenance Utility 1.3
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4
  • Microsoft Program Maintenance Utility 1.4



This article was previously published under Q59526

SUMMARY

If a target is specified in more than one dependency block, some files may not be built. For example, consider a make file that contains dependencies such as the following:

   MYAPP.EXE :: MYAPP1.obj
   MYAPP.EXE :: MYAPP2.obj
   MYAPP.EXE :: MYAPP3.obj
      link MYAPP.exe

   MYAPP.EXE :: MYAPP.RES
      RC MYAPP.RES MYAPP.EXE

                

If MYAPP1.OBJ and MYAPP2.OBJ are newer than MYAPP.EXE, but MYAPP3.OBJ is not, NMAKE does not build MYAPP.EXE. To further confuse the issue, the following is the output from NMAKE when the /d (display file dates) option is specified:

      C:\>NMAKE /d myapp.mak

   myapp.exe                    Wed Mar 07 08:42:38 1990
     myapp1.obj                 Thu Mar 08 15:25:44 1990
   ** myapp1.obj newer than myapp.exe
     myapp2.obj                 Wed Mar 08 08:38:56 1990
   ** myapp2.obj newer than myapp.exe
     myapp3.obj                 Thu Mar 01 09:49:52 1990
     myapp.res                  Thu Mar 01 09:49:52 1990
   'myapp.exe' is up-to-date
                

Obviously, NMAKE determines that the MYAPP1.OBJ and MYAPP2.OBJ files have later dates, but it does not link MYAPP.EXE.

MORE INFORMATION

The multiple dependency construct, specified by a double colon (::) following the name of the target, is very useful in NMAKE because it allows the programmer to specify various operations to occur with a target file based on various dependent files. For example, when you build an application for the Microsoft Windows operating system, the makefile can specify that when one or more .OBJ files change, NMAKE must run LINK to rebuild the application. On the other hand, if the resource file changes but the .OBJ files do not, NMAKE must only run the Resource Compiler to update the application.

However, this feature has limits. The command block for each target dependency must immediately follow its specification. Multiple dependencies are not cumulative like normal dependencies are. Therefore, the following modification to the example above works as anticipated:

   MYAPP.EXE :: MYAPP1.obj
      link MYAPP.exe

   MYAPP.EXE :: MYAPP2.obj
      link MYAPP.exe

   MYAPP.EXE :: MYAPP3.obj
      link MYAPP.exe

   MYAPP.EXE :: MYAPP.RES
      RC MYAPP.RES MYAPP.EXE     /* Not valid for RC under NT.

                

Another method involves placing all dependencies on the same line as the target, as follows:

   MYAPP.EXE:: MYAPP1.obj MYAPP2.obj MYAPP3.obj
      link MYAPP.exe

   MYAPP.EXE:: MYAPP.RES
      RC MYAPP.RES MYAPP.EXE     /* Not valid for RC for NT.
                


Additional query words: kbinf 1.10 1.20 1.30 1.40 1.50

Keywords: KB59526