Q59526: Multiple Dependency Blocks Are Not Cumulative
Article: Q59526
Product(s): Microsoft Programming Utilities
Version(s): MS-DOS:1.01,1.1,1.11,1.12,1.13,1.2,1.3,1.4; NT:1.4,1.5; OS/2:1.01,1.11,1.12,1.13,1.21
Operating System(s):
Keyword(s):
Last Modified: 30-OCT-1999
-------------------------------------------------------------------------------
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, 1.4
- Microsoft NMAKE Utility for OS/2, versions 1.01, 1.11, 1.12, 1.13, 1.21
- Microsoft NMAKE Utility for Windows NT, versions 1.4, 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 query words: kbinf 1.10 1.20 1.30 1.40 1.50
======================================================================
Keywords :
Technology : kbVCsearch kbAudDeveloper kbNMAKESearch kbNMAKE101DOS kbNMAKE110DOS kbNMAKE111DOS kbNMAKE112DOS kbNMAKE113DOS kbNMAKE120DOS kbNMAKE130DOS kbNMAKE140DOS kbNMAKE101OS2 kbNMAKE111OS2 kbNMAKE112OS2 kbNMAKE113OS2 kbNMAKE121OS2 kbNMAKE140NT kbNMAKE150NT
Version : MS-DOS:1.01,1.1,1.11,1.12,1.13,1.2,1.3,1.4; NT:1.4,1.5; OS/2:1.01,1.11,1.12,1.13,1.21
=============================================================================
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.
Copyright Microsoft Corporation 1986-2002.