Building Makefiles on the Command Line
Use the NMAKE utility to build makefiles. Here is the proper syntax for NMAKE.
nmake [options] [macros] [targets] @commandfile
NMAKE builds only the specified targets. If none are specified, then it builds the first target in the makefile. The first makefile target can be a pseudotarget that builds other targets.
The commandfile string specifies a text file with command-line input. Use the complete path and file name if the command file is not in the current directory. Other input can precede or follow the input provided by the command file. In the command file, line breaks are treated as spaces.
Here is the typical syntax for building a makefile for a Windows CE build. Add any required additional arguments or macros.
nmake /f "makefile" CFG="projectname - configuration" CESubsystem=subsystem,osversion CEVersion=osversion CEConfigname="platform"
Return Values
NMAKE returns the following exit codes:
Code | Meaning |
---|---|
0 | No error (possibly a warning) |
1 | Incomplete build |
2 | Program error, possibly due to one of the following:
|
4 | System error — out of memory |
255 | Target is not up-to-date (issued only when the /Q option is used. |
NMAKE Options
NMAKE options are described in the following table. Options are preceded by either a slash (/) or a dash (-) and are not case sensitive. Use !CMDSWITCHES to change option settings in a make file or Tools.ini.
Note NMAKE looks for Tools.ini, if any, first in the current directory and then in the directory specified by the INIT environment variable. The section for NMAKE settings in the initialization file begins with [NMAKE] and can contain any makefile information. Specify a comment on a separate line beginning with the number sign (#).
Option | Description |
---|---|
/A | Forces the build of all evaluated targets, even if not out-of-date with respect to dependents. Does not force build of unrelated targets. |
/B | Forces build even if timestamps are equal. Recommended only for very fast systems (resolution of two seconds or less). |
/C | Suppress default output, including nonfatal NMAKE errors or warnings, timestamps, and NMAKE copyright message. Suppresses warnings issued by /K. |
/D | Displays timestamps of each target and dependent; displays a message when a target does not exist. Useful with /P for debugging a makefile. Use !CMDSWITCHES to set or clear /D for part of a makefile. |
/E | Causes environment variables to override makefile macro definitions. |
/F makefile | Specifies a makefile. Spaces or tabs can precede makefile. Specify /F once for each makefile. To supply a makefile from standard input, specify a dash (-) for makefile, and end keyboard input with either F6 or CTRL+Z. |
/HELP or /? | Displays a brief summary of NMAKE command-line syntax. |
/I | Ignores exit codes from all commands. To set or clear /I for part of a makefile, use !CMDSWITCHES. To ignore exit codes for part of a makefile, use a dash (-) 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 halts 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 calls. Useful for debugging makefiles and checking timestamps. To set or clear /N for part of a makefile, use !CMDSWITCHES. |
/NOLOGO | Suppress the NMAKE copyright message. |
/P | Displays information (macro definitions, inference rules, targets, .SUFFIXES list) to standard output, and then runs the build. If no makefile or command-line target exists, it displays information only. Use with /D to debug a makefile. |
/Q | Checks timestamps of targets; 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 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 display of executed commands. To suppress display in part of a makefile, use the @ command modifier or .SILENT. To set or clear /S for part of a makefile, use !CMDSWITCHES. |
/T | Updates timestamps of command-line targets (or first makefile target) and executes preprocessing commands but does not run the build. |
/U | Must be used in conjunction with /N. Dumps inline NMAKE files so that the /N output can be used as a batch file. |
/X filename | Sends NMAKE error output to filename instead of standard error. Spaces or tabs can precede filename. To send error output to standard output, specify a dash (-) for filename. Does not affect output from commands to standard error. |
/Y | Disables batch-mode inference rules. When this option is selected, all batch-mode inference rules are treated as regular inference rules. |
WCE NMAKE macros (required)
Macros in on the NMAKE command line replace a particular string in the makefile with another string. Use the following syntax to define a macro:
macroname = string
The macroname can contain any combination of letters, digits, and underscores (_) up to 1,024 characters and is case sensitive. The string can be any sequence of characters (or a null string of zero characters, spaces, or tabs). Enclose the string between double quotation marks (") if it contain spaces.
The following macros are required for a Windows CE build.
Target | Description |
---|---|
CESubsystem=subsystem,osversion | The Windows CE subsystem (normally "windowsce") and operating system version number (such as "3.00") for the Windows CE subsystem. |
CEVersion=osversion | The target version of the Windows CE operating system for the build. Omit the decimal point in the version number (for example, 300). |
CEConfigName="platform" | The project name and the Windows CE Configuration. Type the platform string as it appears in the Set Active Platform dialog box (choose Set Active Platform on the Build menu) or in the Select Active WCE Configuration list on the WCE Configuration toolbar. |
CFG="project - configuration" | The project name and the Windows CE Configuration. Type the configuration string as it appears in the Configurations dialog box (choose Configurations on the Build menu) or in the Select Active Configuration list on the WCE Configuration toolbar. |
Environment Variables
NMAKE inherits macro definitions for environment variables that exist before the start of an NMAKE session. Before you run NMAKE, you should set environment variables for the target Windows CE operating system as described in Environment Variables for Cl.exe and Link.exe.
Examples
The following examples demonstrate the syntax for building makefiles for a Pocket PC and for an H/PC that runs Microsoft Windows CE, Handheld PC Professional Edition, version 3.0:
Pocket PC
nmake /f "Myproj.vcn" CFG="Myproj - Win32 (WCE x86em) Debug" CESubsystem=windowsce,3.00 CEVersion=300 CEConfigName="Pocket PC"
H/PC running H/PC Pro Edition software
nmake /f "Myproj.vcn" CFG="Myproj - Win32 (WCE x86em) Debug" CESubsystem=windowsce,2.11 CEVersion=211 CEConfigName="H/PC Pro 2.11"
See Also
Building Applications on the Command Line, Exporting an NMAKE Makefile, Building Projects and Workspaces on the Command Line, Environment Variables for Cl.exe and Link.exe