Macros

 

Predefined General Macros [Top]

Make predefines several macros. Of those macros the following ones cannot be redefined:

Name Value
.NEWSOURCES the list of target sources newer than the target.
.SOURCE the inferred source or, if none, the first explicit source.
.SOURCES the complete list of sources for a target.
.TARGET the name of the target being made.
.TARGETROOT the root name of the target being made.
.VERSION the VCS version from the .XXX_STORAGE directive.
BUILTINS name of the built-ins file used.
CWD the directory in which Make started.
FIRSTTARGET the first command-line target or the first makefile target.
INPUTFILE the current makefile being processed.
MAKEARGS all command-line arguments.
MAKEDIR same as the macro CWD.
MAKEMACROS all command-line macros.
MAKEPID the process id of this Make process.
MAKESTATUS the status with which Make is exiting.
MAKETARGETS all command-line targets.
MAKEVERSION the version of this Make executable.
status the exit status of the last shell line executed.

 

Predefined State Macros [Top]

The following predefined macros contain the state of Make's command-line flags and directives. The "Flag" column is the equivalent command-line flag for that directive (if any).

Name Flag Value
.ALWAYS -a 0 or 1
.AUTODEPEND -A 0 or 1
.AUTODEPEND_MODE   the list of autodependency options.
.CASE_MACRO   0 or 1
.CASE_TARGET   0 or 1
.DEBUG -# the current debug options
.DEBUG_PRINT -p 0 or 1
.DEBUG_RUN -d 0 or 1
.EIGHT_DOT_THREE   0 or 1
.ENVMACRO   Inverted state of the .NOENVMACROS directive.
.ENV_OVERRIDE -e 0 or 1
.GLOBAL_PATH   0 or 1
.IGNORE -i 0 or 1
.IGNORE_MFLAGS -z 0 or 1
.KEEPDIR -D 0 or 1
.KEEPWORKING -k 0 or 1
.MAKE_MAKEFILE -M 0 or 1
.MEMSWAP   the list of .MEMSWAP names
.MISER -m 0 or 1
.MISER_MODE   the list of miser modes
.MS_NMAKE -EN 0 or 1
.NOEXECUTE -n 0 or 1
.OPTIONS   list of optional features
.OPUS_52X -E2 list of compatibility features
.OPUS_MAKE -EO 0 or 1
.POLY_MAKE -EP 0 or 1
.QUERY -q 0 or 1
.REGEX_BACK   the regex literal backslash
.REGEX_CHAR   the regex escape character
.REGEX_DOT   the regex literal dot
.REGEX_WILD   the regex "match any character"
.REJECT_RULES -r 0 or 1
.REREAD   0 or 1
.RULE_CHAR   the rule character
.SHELL   the shell program and shell flags
.SILENT -s 0 or 1
.SUFFIXES   the list of suffixes
.TOUCH -t or -T 0 (neither flag), 1 (-t), 2 (-T)
.UNIXPATHS   0 or 1
.VCS_MODE   The list of version control modes.

 

Built-In Macros [Top]

The following macros are also defined by Make, but can be changed by you. The value in quotes is Make's default value.

Name Value
AS assembler: "masm"
CC C compiler: "cl" or "cc"
FC FORTRAN compiler: "f77l"
LIBEXE object librarian program: "lib"
LINK object linker: "link "
MAKE path name to the Make executable.
MAKEFILE first makefile read.
OS the current operating system: "MSDOS", "OS2", "unix", "NT" or "Win95").
OSRELEASE the minor operating system number.
OSVERSION the major operating system number.
PVCSGET program that gets files from PVCS storage: "get "
PVCSGETFLAGS flags to $(PVCSGET): "-q -r "
RC resource compiler program: "rc"
RCSGET program that gets files from RCS storage:"co "
RCSGETFLAGS flags to $(RCSGET): ""
SHELLSUFFIX MS-DOS file extension for batch files: ".bat"
SSGET program that gets files from SourceSafe storage: "ss"
SSGETFLAGS flags to $(SSGET): "get"
STAMPOBJ program that timestamps object files: "stampobj"
TLIBGET program that gets files from TLIB storage: "tlib"
TLIBGETFLAGS flags to $(TLIBGET): "EBS"

 

Macro Modifiers [Top]

When a macro is expanded, the expanded value can be modified with macro modifiers. To modify a macro, expand it with:

$(name,modifier[,modifier]...) 

name is macro expanded, then each modifier is applied in succession to the elements of the expanded value.

Modifier Action
number Select the "number"th element of the value.
>string Append string to each element.
<string Prepend string to each element.
from=to Substitute all occurrences of from with to.
*F, *D Wild-card match for files or directories.
@ Include file contents or project file list from SourceSafe, Source Integrity or TLIB.
@F[R], @P[R] For SourceSafe, @F include project files only, @P includes project subprojects only. Optional "R" recurses through subprojects.
@/from/to/[g] File lines matched by regex from are included, with from replaced by to. If "g" is given, all from matches are substituted on the matched lines. Otherwise, only the first from match is substituted.
A/, A\, A Convert to absolute name using "/", "\" or the default path separator.
B Select the base part of the element.
D Select the directory part of the element.
E Select the extension part of the element.
F Select the file part of the element.
LC Convert the element to lower case.
Mregex Choose elements that match regular expression regex.
M"spec" Choose elements that match file specification spec.
Nregex Choose elements that do not match regular expression regex.
N"spec" Choose elements that do not match file specification spec.
P Select the path part of the element.
R Select the root part of the element.
S/from/to/[g] Substitutes from (a regular expression) to to. If "g" is given, all from matches are substituted. Otherwise, only the first from match is substituted.
UC Convert the element to upper case.
Wstr Replace whitespace between macro elements with str, where str can contain the following special sequences:
Sequence Value
  \n a newline character
  \r a return character
  \t a tab character
  \\ a literal backslash
  \ddd an octal character ddd (1 to 3 digits)
  \xdd a hexadecimal character dd (1 or 2 digits)
X Target names are expanded into path names.
Z Select the drive part of the element.