Specifying the Order in Which NMAKE Builds Files

Last reviewed: January 24, 1995
Article ID: Q59420
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

It is possible to specify the order in which NMAKE builds target files.

MORE INFORMATION

When NMAKE runs, it first checks its comment line. NMAKE builds any targets specified on the command line in order, from left to right. If the command line does not specify any targets, NMAKE builds the first target in the description file.

NMAKE builds all the dependents in the order in which they are specified on the first target line, from left to right. For most description files, the first target in the file is the ALL pseudotarget. NMAKE builds the specified files in order and builds other files that depend on the specified files according to their rules.

As an example, consider the following description file:

Sample Makefile 1

   all : three.obj two.obj one.obj main.exe

   one.obj : one.c
      cl /c one.c

   two.obj : two.c
      cl /c two.c

   three.obj : three.c
      cl /c three.c

   main.exe : three.obj one.obj two.obj
      link one two three, main;

In this example, NMAKE compiles THREE.C, TWO.C, and ONE.C, then it links MAIN.EXE. The compiler uses this order because the first target specifies the dependents in this order. NMAKE builds the first target unless the command line specifies a different target to build.

Consider the following example that is somewhat different from the example above:

Sample Makefile 2

   all : main.exe

   one.obj : one.c
       cl /c one.c

   two.obj : two.c
       cl /c two.c

   three.obj : three.c
       cl /c three.c

   main.exe : three.obj one.obj two.obj
       link one two three, main;

In this example, NMAKE compiles THREE.C, ONE.C, and TWO.C, then it links MAIN.EXE. NMAKE builds the first target, MAIN.EXE, then it builds the file MAIN.EXE depends on in the specified order.

To summarize, NMAKE looks first at its command line. If no files are specified, it builds the first target in the description file by building each of its dependent files in the specified order. If a file that the first target depends on specifies another target, NMAKE builds the dependent files of that target in the specified order. This continues until all dependent files are built.


Additional reference words: kbinf kbinf 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.