Using directives, you can construct description files similar
to batch files. NMAKE provides directives that:
- Conditionally execute commands
- Display error messages
- Include the contents of other files
- Turn some NMAKE options on or off
Each directive begins with an exclamation point ( ! ) in the
first column of the description file. Spaces can be placed between
the exclamation point and the directive keyword.
The list below describes the directives:
- !IF expression
- Executes the statements between the !IF keyword and the next
!ELSE or !ENDIF directive if expression evaluates to a
nonzero value.
The expression used with the !IF directive can consist
of integer constants, string constants, or exit codes returned by
programs. Integer constants can use the C unary operators for numerical
negation ( - ), one's complement ( ~ ), and
logical negation ( ! ). You can also use any of
the C binary operators listed below:
- Operator
- Description
- +
- Addition
- -
- Subtraction
- *
- Multiplication
- /
- Division
- %
- Modulus
- &
- Bitwise AND
- |
- Bitwise OR
- ^^
- Bitwise XOR
- &&
- Logical AND
- ||
- Logical OR
- <<
- Left shift
- >>
- Right shift
- ==
- Equality
- !=
- Inequality
- <
- Less than
- >
- Greater than
- <=
- Less than or equal to
- >=
- Greater than or equal to
- You can use parentheses to group expressions.
- Values are assumed to be decimal values unless specified with
a leading 0 (octal) or leading 0x (hexadecimal).
- Strings are enclosed by quotation marks ( " ).
You can use the equality ( == ) and inequality
( != ) operators to compare two strings.
- You can invoke a program in an expression by enclosing the program name
in square brackets ( [ ] ). The exit code returned
by the program is used in the expression.
- !ELSE
- Executes the statements between the !ELSE and !ENDIF directives
if the statements preceding the !ELSE directive were not executed.
- !ENDIF
- Marks the end of the !IF, !IFDEF, or !IFNDEF block of statements.
- !IFDEF macroname
- Executes the statements between the !IFDEF keyword and the
next !ELSE or !ENDIF directive if macroname is defined
in the description file. If a macro has been defined as null, it
is still considered to be defined.
- !IFNDEF macroname
- Executes the statements between the !IFNDEF keyword and the
next !ELSE or !ENDIF directive if macroname is not defined
in the description file.
- !UNDEF macroname
- Undefines a previously defined macro.
- !ERROR text
- Prints text and then stops execution.
- !INCLUDE filename
- Reads and evaluates the file filename before continuing
with the current description file. If filename is enclosed
by angle brackets (<>), NMAKE searches for the
file in the directories specified by the INCLUDE macro; otherwise,
it looks only in the current directory. The INCLUDE macro is initially
set to the value of the INCLUDE environment variable.
- !CMDSWITCHES {+|-}opt
- Turns on or off one of four NMAKE options: /D, /I,
/N, and /S. If no options are specified, the options are reset to
the values they had when NMAKE was started. To turn an option on,
precede it with a plus sign (+); to turn it off, precede it with
a minus sign (-). This directive updates the MAKEFLAGS macro.
See Special macros.