Multiple Dependency Blocks Are Not CumulativeLast reviewed: January 24, 1995Article ID: Q59526 |
The information in this article applies to:
SUMMARYIf 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.EXEIf 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 INFORMATIONThe 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
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |