Special Nmake.exe Macros (Windows CE 5.0)
Nmake.exe provides several special macros to represent various file names and commands. One use for some of these macros is in the predefined inference rules.
Like all macros, the macros provided by Nmake.exe are case-sensitive.
These macros do not need to be enclosed in parentheses when invoked. Instead, they can be invoked by specifying a dollar sign ($).
The following table shows the special Nmake.exe macros that can be invoked in this way.
Macro | Description |
---|---|
$@ | Current target's full name, including path, base name, and file name extension, as currently specified. |
$$@ | Current target's full name, including path, base name, and file name extension, as currently specified.
Valid only as a dependent in a dependency. |
$* | Current target's path and base name without a file name extension. |
$** | All dependents of the current target. |
$? | All dependents with a later time stamp than the current target. |
$< | Dependent file with a later time stamp than the current target.
Valid only in commands in inference rules. |
To specify part of a predefined file name macro, append a macro modifier and enclose the modified macro in parentheses.
The following table shows Nmake.exe macro modifiers.
Modifier | Resulting file name part |
---|---|
D | Drive and directory |
B | Base name |
F | Base name and extension |
R | Drive, directory, and base name |
Recursive Macros
Use recursion macros to call Nmake.exe recursively.
Recursive sessions inherit command-line and environment-variable macros and Tools.ini information. They do not inherit inference rules defined by a .mak file or .SUFFIXES and .PRECIOUS lists.
To pass macros to a recursive Nmake.exe session, do one of the following:
- Set an environment variable with SET before the recursive call
- Define a macro in the command for the recursive call
- Define a macro in Tools.ini
The following table shows recursion macros.
Macro | Description |
---|---|
MAKE | Command used originally to invoke Nmake.exe. |
MAKEDIR | Current directory when Nmake.exe was invoked. |
MAKEFLAGS | Set the value to parameters used when invoking Nmake.exe. Do not include forward slashes when setting this variable.
For example, the following command means that the Nmake copyright message is suppressed, and that Nmake.exe must perform a build of all evaluated targets.
For more information about the parameters, see Nmake Tool. |
Command Macros
Command macros are predefined for Microsoft products. Options macros represent options for these products and are undefined by default. Both are used in predefined inference rules and can be used in description blocks or user-defined inference rules.
Command macros can be redefined to represent part or all of a command line, including options.
Options macros generate a null string if they are left undefined.
The following table shows command macros.
Microsoft product | Command macro | Defined as | Option macros |
---|---|---|---|
C compiler | cl | CFLAGS | |
C++ compiler | CPP | cl | CPPFLAGS |
C++ compiler | CXX | cl | CXXFLAGS |
Resource compiler | RC | rc | RFLAGS |
Nmake.exe inherits macro definitions for environment variables that exist before the start of the session. If a variable was set in the OS environment, it is available as an Nmake.exe macro.
Inherited names are converted to uppercase. Inheritance occurs before preprocessing.
Use the /E option to cause macros that are inherited from environment variables to override macros with the same name in the .mak file.
Environment Variable Macros
Environment variable macros can be redefined in the session, and this changes the corresponding environment variable.
You can also change environment variables with the SET command; however, using the SET command to change an environment variable in a session does not change the corresponding macro.
The following code example shows how to redefine an environment variable macro.
PATH=$(PATH);\nonesuch
all:
echo %PATH%
In this example, PATH=$(PATH) changes the corresponding environment variable PATH; it appends \nonesuch to your path.
If an environment variable is defined as a string that is syntactically incorrect in a .mak file, no macro is created and no warning is generated.
If a variable's value contains a dollar sign ($), Nmake.exe interprets it as the beginning of a macro invocation. Using the macro can cause unexpected behavior.
See Also
Send Feedback on this topic to the authors