Multiple Dependency Blocks Are Not Cumulative

Last reviewed: January 24, 1995
Article ID: Q59526
The information in this article applies to:
  • Microsoft NMAKE Utility for MS-DOS, versions 1.01, 1.1, 1.11, 1.12, 1.13, 1.2, 1.3, and 1.4
  • Microsoft NMAKE Utility for OS/2, versions 1.01, 1.11, 1.12, 1.13, and 1.21
  • Microsoft NMAKE Utility for Windows NT, versions 1.4 and 1.5

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 reference words: kbinf kbinf 1.10 1.20 1.30 1.40 1.50
KBCategory: kbtool
KBSubcategory: NmakeIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: January 24, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.