1.4.6 Microsoft Program Maintenance Utility

The Microsoft Program Maintenance Utility (NMAKE) updates applications by keeping track of the dates of their source files. NMAKE is included with CL version 6.0.

Although NMAKE comes with CL, and not with the SDK, it is especially important for Windows applications because of the number of files required to create a Windows application. This utility uses a text file, called a makefile, that contains a list of the commands and files needed to build a Windows application. The makefile commands compile and link the various files. NMAKE executes the commands only if the files named in those commands have changed. This saves time if, for example, you have made only a minor change to a single file.

The following example shows the content of a typical makefile for a Windows application:

# The following line allows NMAKE to use this file as well.
all: generic.exe

# Update the resources if necessary.

generic.res: generic.rc generic.h
    rc /r generic.rc

# Update the object file if necessary.

generic.obj: generic.c generic.h
    cl /AS /c /DLINT_ARGS /Gsw /Oat /W2 /Zped generic.c

# Update the executable file if necessary.
# (If it is necessary, add the resources to it.)

generic.exe: generic.obj generic.def
    link /nod generic, , , slibcew libw, generic.def
    mapsym generic
    rc generic.res


# If the .RES file is new and the .EXE file is not,
# compile only the resources. Note that you can update
# the .RC file without having to either recompile or
# relink the file.

generic.exe: generic.res
    rc generic.res

Typically, a makefile has the same name as the application it builds, although any name is allowed. Following is an NMAKE command that uses the commands in the file GENERIC:

nmake generic

For more information about NMAKE, see the CL documentation.