10.2 Running NMAKE

You invoke NMAKE with the following syntax:

NMAKE [[options]] [[macros]] [[targets]]

The options field lists NMAKE options, which are described in Section 10.4, “Command-Line Options.”

The macros field lists macro definitions, which allow you to change text in the description file. The syntax for macros is described in “User-Defined Macros” in Section 10.3.4.1, “Macros.”

The targets field lists targets to build. NMAKE rebuilds only the targets listed on the command line. If you don't specify any targets, NMAKE builds only the first target in the description file. (This behavior departs significantly from that of MAKE. See Section 10.10, “Differences between NMAKE and MAKE.”)

Summary: NMAKE follows the instructions you specify in a description file.

NMAKE searches the current directory for the name of a description file you specify with the /F option. It halts and displays an error message if the file does not exist. If you do not use the /F option to specify a description file, NMAKE searches the current directory for a description file named MAKEFILE. If MAKEFILE does not exist, NMAKE checks the command line for target files and tries to build them using predefined inference rules (either default or defined in TOOLS.INI). This feature lets you use NMAKE without a description file (as long as NMAKE has a predefined inference rule for the target). If the command line does not specify any target files, NMAKE halts and displays an error message.

Example

NMAKE /S "program=sample" sort.exe search.exe

This command supplies four arguments: an option (/S), a macro definition ("program=sample"), and two target specifications (sort.exe and search.exe).

The command does not specify a description file, so NMAKE looks for the default description file, MAKEFILE. The /S option tells NMAKE not to display the commands as they are executed. (See Section 10.4, “Command-Line Options.”) The macro definition performs a text substitution throughout the description file, replacing every instance of program with sample. The target specifications tell NMAKE to update the targets SORT.EXE and SEARCH.EXE.