DESCRIPTION
This reference page offers a summary of the syntax of a makefile's contents, using a style similar to BNF (Backus Naur Form). Items enclosed in [ ] are optional, while items enclosed in { } can appear zero or more times.
makefile → { makefile-line } makefile-line → macro-definition → target-definition → attribute-definition → conditional
A line is a possibly empty sequence of characters, terminated by a nonescaped newline character; that is, one not immediately preceded by a backslash (\). A line can be extended over several input lines by placing a \ at the end of each line to be continued.
A comment begins with a # and extends to the end of the line. In the following, an expression is defined as
expression → string → string == string → string != string
where string is defined as a literal sequence of characters, or the sequence of characters resulting from the expansion of a macro.
A conditional is defined as
conditional → .IF expression makefile { .ELSIF expression makefile } [ .ELSE makefile ] .END
A rule-definition is defined as
rule-definition → targets [ attributes ] op [prerequisites] [ ; recipe ] recipe targets → target { target }
A target may be a special-target.
Any number of attributes may follow a target in a rule-definition.
attribute → .IGNORE → .SILENT → .PRECIOUS → .LIBRARY → .PROLOG → .EPILOG → .SETDIR=path
An attribute-definition is like a rule-definition, except that a recipe is not allowed. An attribute-definition is given as
attribute-definition → attribute { attribute } : targets
The op defines the type of rule.
op → : → :: → :^ → :! → :- → :|
The prerequisites are a list (possibly empty) of targets that must be brought up-to-date before making the current target. The prerequisites may optionally be followed by a semicolon (;) and a recipe.
A recipe normally follows; it consists of a number of lines, all starting with at least one tab character, or a group-recipe, which is written between brackets ([ ]).
recipe → { [+@-] line } → [[+@-]lines]
A special-target is a keyword that is given as a target in a rule-definition. The following special targets are allowed:
special-target → .BRACEEXPAND → .ERROR → .EXPORT → .GROUPEPILOG → .GROUPPROLOG → .IMPORT → .INCLUDE → .INCLUDEDIRS → .MAKEFILES → .NOAUTODEPEND → .REMOVE → .SOURCE → .SOURCE.suffix → .SUFFIXES → .POSIX
A macro-definition is recognized as a string followed by an = character. There are three forms of macros:
macro = string assign string to macro macro := string expand macro definitions string, then assign macro += string append string to end of macro
If string is empty, macro is assigned the null string (unless you use the += operator; in this case, the macros contents are not touched). White space on either side of the =, :=, or += is ignored.
Macros are expanded by $(macro) or ${macro}. If a macro name is a single letter, it can also be expanded by $n, where n is the name.
If the .BRACEEXPAND special target is set, make expands a token sequence (separated by white space) prepending a prefix string and appending a suffix string to each token:
string1{ token-list }string2
Future versions of MKS Make may not support this obsolescent feature.
A macro can also be modified as it is expanded. The syntax for this is
$(macro {:modifier})
where any number of modifiers can be supplied, separated by :.
modifier →b →d →f →l → s/string/new_string/ → suffix_string=new_suffix_string → t"string" →u →^"string" →+"string"
The :s modifier is a substitute operator; occurrences of the given pattern that are matched are replaced by the indicated value. The :t modifier tokenizes the macro string definition, placing the given string between each name in the indicated string. That string may contain the following escape sequences:
\" → " \\ → \ \a → alert or <bel> \b → <backspace> \f → <form feed> \n → <newline> \r → <carriage return> \t → <tab> \v → <vertical tab>
The :u modifier maps all characters in the expansion to uppercase.
The :l modifier maps all characters in the expansion to lowercase.
The :^ modifier adds a prefix to all of the tokens in the expanded macro.
The :+ modifier adds a suffix to all of the tokens in the expanded macro.
A number of built-in macros are defined by MKS Make.
$@ full target name $$@ dynamic expansion of $@ $% full target name, or name of archive library $$% dynamic expansion of $% $* $@ without suffix; same as $(@:db) $$* dynamic expansion of $* $> library name for current target (library member) $$> dynamic expansion of $> $? all recently changed prerequisites $< in normal rules, those prerequisites prompting execution of current rule; in inference rules, the prerequisite of the current rule $& all prerequisites $^ prerequisites in current rule
MKS Make also uses control-macros, whose value is either maintained by make, or used to control the corresponding attribute.
control-macros → DIRSEPSTR → .EPILOG → GROUPFLAGS → GROUPSHELL → GROUPSUFFIX → .IGNORE → INCDEPTH → MAKE → MAKECMD → MAKEDIR → MAKEFLAGS → MAKESTARTUP → MFLAGS → NULL → .PRECIOUS → .PROLOG → PWD → SHELL → SHELLFLAGS → SHELLMETAS → .SILENT
For example, the .SILENT macro is like the .SILENT attribute, except that using the macro assigns the .SILENT attribute to all targets.
AVAILABILITY
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC Windchill Requirements and Validation
SEE ALSO
- Commands:
- make
PTC MKS Toolkit 10.5 Documentation Build 40.