Special Nmake.exe Macros
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 have to be enclosed in parentheses when invoked. Instead, they can be invoked by specifying only a dollar sign ($). The following table shows the special Nmake.exe macros that can be invoked in this way.
|$@||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|
|F||Base name and extension|
|R||Drive, directory, and base name|
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, either set an environment variable with SET before the recursive call, define a macro in the command for the recursive call, or define a macro in Tools.ini.
The following table shows recursion macros.
|MAKE||Command used originally to invoke Nmake.exe.|
|MAKEDIR||Current directory when Nmake.exe was invoked.|
|MAKEFLAGS||Options currently in effect. Use as /$(MAKEFLAGS)|
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|
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. The 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 any macros with the same name in the .mak file.
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. Using the SET command to change an environment variable in a session does not change the corresponding macro, however.
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 would be 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.
Last updated on Friday, October 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.