Nmake Tool

The Nmake tool (Nmake.exe) is a 32-bit tool that you use to build projects based on commands contained in a .mak file.

The following example shows the syntax for Nmake.exe.

NMAKE [option] [macros] [targets] [@CommandFile]

Nmake.exe builds only specified targets or, if none are specified, the first target in the .mak file. The first .mak file target can be a pseudotarget that builds other targets. Nmake.exe uses .mak files specified with /F; if /F is not specified, it uses the .mak file in the current directory. If no .mak file is specified, Nmake.exe uses inference rules to build command-line targets.

The CommandFile text file contains command-line input. Other input can precede or follow @CommandFile. A path is permitted. In CommandFile, line breaks are treated as spaces. Enclose macro definitions in quotation marks (" ") if they contain spaces.

Nmake.exe options are preceded by either a slash mark (/) or a hyphen (-) and are not case-sensitive. Use !CMDSWITCHES to change option settings in a .mak file or in Tools.ini.

The following table shows available Nmake.exe options.

Option Description
/A Forces a build of all evaluated targets, even if the targets are not out-of-date with respect to dependents. Does not force a build of unrelated targets.
/B Forces a build even if the time stamps are equal. Recommended only for very fast systems with a resolution of two seconds or less.
/C Suppresses default output, including nonfatal Nmake.exe errors or warnings, time stamps, and the Nmake.exe copyright message. Suppresses warnings issued by /K.
/D Displays the time stamps of each evaluated target and dependent and a message when a target does not exist. Useful with /P for debugging a .mak file. Use !CMDSWITCHES to set or clear /D for part of a .mak file.
/E Causes environment variables to override .mak file macro definitions.
/Ffilename Specifies filename as a .mak file. Spaces or tabs can precede filename. Specify /F once for each .mak file. To supply a .mak file from standard input, specify a hyphen (-) for filename. To end keyboard input, press F6 or CTRL+Z.
/HELP, /? Displays a brief summary of Nmake.exe command-line syntax.
/I Ignores exit codes from all commands. To set or clear /I for part of a .mak file, use !CMDSWITCHES. To ignore exit codes for part of a .mak file, use a hyphen (-) command modifier or .IGNORE. Overrides /K if both are specified.
/K Continues building unrelated dependencies, if a command returns an error. Also issues a warning and returns an exit code of 1. By default, Nmake.exe stops if any command returns a nonzero exit code. Warnings from /K are suppressed by /C. /I overrides /K if both are specified.
/N Displays, but does not execute, commands. Preprocessing commands are executed. Does not display commands in recursive Nmake.exe calls. Useful for debugging .mak files and checking time stamps. To set or clear /N for part of a .mak file, use !CMDSWITCHES.
/NOLOGO Suppresses the Nmake.exe copyright message.
/P Displays information, such as macro definitions, inference rules, targets, and .SUFFIXES list, to standard output, and then runs the build. If no .mak file or command-line target exists, it displays information only. Use with /D to debug a .mak file.
/Q Checks the time stamps of targets, but does not run the build. Returns a zero exit code if all targets are up-to-date and a nonzero exit code if any target is not up-to-date. Preprocessing commands are executed. Useful when running Nmake.exe from a batch file.
/R Clears the .SUFFIXES list and ignores inference rules and macros that are defined in the Tools.ini file or that are predefined.
/S Suppresses the display of executed commands. To suppress the display in part of a .mak file, use the @ command modifier or .SILENT. To set or clear /S for part of a .mak file, use !CMDSWITCHES.
/T Updates the time stamps of command-line targets, or the first .mak file target, and executes preprocessing commands, but does not run the build.
/U Must be used in conjunction with /N. Dumps inline Nmake.exe files so that the /N output can be used as a batch file.
/X Sends Nmake.exe error output to filename instead of to a standard error output. Spaces or tabs can precede filename. To send standard error output, specify a hyphen (-) for filename. Does not affect output from commands to standard error output.
/Y Disables batch-mode inference rules. When this option is selected, all batch-mode inference rules are treated as regular inference rules.

Nmake.exe reads Tools.ini before it reads .mak files, unless /R is used. It looks for Tools.ini first in the current directory and then in the directory specified by the INIT environment variable. The section for Nmake.exe settings in the initialization file begins with [NMAKE] and can contain any .mak file information. Specify a comment on a separate line beginning with a number sign (#).

The following table shows Nmake.exe exit codes.

Exit code Description
0 No error, but possibly a warning.
1 Incomplete build. This code is issued only when /K is used.
2 Program error, possibly due to one of the following problems:
  • A syntax error in the .mak file
  • An error or exit code from a command
  • An interruption by the user
4 System error indicating that that the system is out of memory.
255 Target is not up-to-date. This error is issued only when /Q is used.

See Also

Build Phases | Build Tool | Sysgen Tool | Makefile File

 Last updated on Friday, October 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.