A macro definition follows this form:

name=character-string
name+=character-string
name=+character-string

Macro names are case_sensitive by default. The character-string can be any string of characters. The first character of the macro must be in column one. NMAKE32 ignores spaces surrounding the name.

The character-string can be a null string and can contain embedded spaces. Do not enclose the macro string in quotation marks. Quotation marks are used when macros defined on the command line contain embedded spaces.

The "+=" form of a macro assignment causes the character-string value to be appended to the end of the current value of name, while the "=+" form causes character-string to be prepended to the beginning of the current value of name. Values are concatenated, spaces are not added.

NMAKE32 also allows the user to recursively define a macro, by using the macro name in the definition. This results in a permanent change to the original macro.

Examples:

Suppose you have a macro named CFLAGS which is used to define the flags for your C compiler, and you wish to add a flag. The original definition would be:

    CFLAGS = -Fo$@ -c

You can then append to this definition a new flag:

    CFLAGS += -Zi

The resulting string definition for CFLAGS is then:

    -Fo$@ -c -Zi

If the new flag had been prepended:

    CFLAGS =+ -Zi

The resulting string definition for CFLAGS is then:

    -Zi -Fo$@ -c

This could also be done using recursion and appending a new flag:

    CFLAGS = $(CFLAGS) -Zi

The resulting string definition for CFLAGS is:

    -Fo$@ -c -Zi

Macros on the Command Line

A macro may also be defined on the command line when calling NMAKE32. Command-line macro definitions follow this form:

name=character-string

If the macro contains embedded spaces or special characters defined in the shell, enclose it in double quotation marks (").

Inherited Macros

NMAKE32 inherits all current environment variables as macros. For example, if you have a PATH environment variable defined as PATH = C:\TOOLS\BIN, the string C:\TOOLS\BIN is substituted when you use $(PATH) in the description file.

Inherited macros may be redefined by including a line such as the one in the example above in a description file. While NMAKE32 is executing, the macro takes on the redefined definition. However, when NMAKE32 terminates the environment variable resumes its original value.

The /E (override environment variable) option disables inherited macro redefinition. If you use this option, NMAKE32 ignores any attempt to redefine an inherited macro, except from the command line.


[Back] [Next]