Uredi

Deli z drugimi prek


NMAKE makefile contents and features

A makefile contains:

For a sample, see Sample makefile.

NMAKE supports other features, such as wildcards, long filenames, comments, and escapes for special characters.

Wildcards and NMAKE

NMAKE expands filename wildcards (* and ?) in dependency lines. A wildcard specified in a command is passed to the command; NMAKE doesn't expand it.

Long filenames in a makefile

Enclose long filenames in double quotation marks, as follows:

all : "VeryLongFileName.exe"

Comments in a makefile

Precede a comment with a number sign (#). NMAKE ignores text from the number sign to the next newline character.

Examples:

# Comment on line by itself
OPTIONS = /MAP  # Comment on macro definition line

all.exe : one.obj two.obj  # Comment on dependency line
    link one.obj two.obj
# Comment in commands block
#   copy *.obj \objects  # Command turned into comment
    copy one.exe \release

.obj.exe:  # Comment on inference rule line
    link $<

my.exe : my.obj ; link my.obj  # Err: cannot comment this
# Error: # must be the first character
.obj.exe: ; link $<  # Error: cannot comment this

To specify a literal number sign, precede it with a caret (^), as follows:

DEF = ^#define  #Macro for a C preprocessing directive

Special characters in a makefile

To use an NMAKE special character as a literal character, place a caret (^) in front of it as an escape. NMAKE ignores carets that precede other characters. The special characters are:

: ; # ( ) $ ^ \ { } ! @ —

A caret (^) within a quoted string is treated as a literal caret character. A caret at the end of a line inserts a literal newline character in a string or macro.

In macros, a backslash (\) followed by a newline character is replaced by a space.

In commands, a percent symbol (%) is a file specifier. To represent % literally in a command, specify a double percent sign (%%) in place of a single one. In other situations, NMAKE interprets a single % literally, but it always interprets a double %% as a single %. Therefore, to represent a literal %%, specify either three percent signs, %%%, or four percent signs, %%%%.

To use the dollar sign ($) as a literal character in a command, specify two dollar signs ($$). This method can also be used in other situations where ^$ works.

See also

NMAKE Reference