make: Recipe Syntax
1
1 5.1 Recipe Syntax
1 =================
1
1 Makefiles have the unusual property that there are really two distinct
11 syntaxes in one file. Most of the makefile uses 'make' syntax (⇒
Writing Makefiles Makefiles.). However, recipes are meant to be
1 interpreted by the shell and so they are written using shell syntax.
1 The 'make' program does not try to understand shell syntax: it performs
1 only a very few specific translations on the content of the recipe
1 before handing it to the shell.
1
1 Each line in the recipe must start with a tab (or the first character
11 in the value of the '.RECIPEPREFIX' variable; ⇒Special
Variables), except that the first recipe line may be attached to the
1 target-and-prerequisites line with a semicolon in between. _Any_ line
1 in the makefile that begins with a tab and appears in a "rule context"
1 (that is, after a rule has been started until another rule or variable
1 definition) will be considered part of a recipe for that rule. Blank
1 lines and lines of just comments may appear among the recipe lines; they
1 are ignored.
1
1 Some consequences of these rules include:
1
1 * A blank line that begins with a tab is not blank: it's an empty
1 recipe (⇒Empty Recipes).
1
1 * A comment in a recipe is not a 'make' comment; it will be passed to
1 the shell as-is. Whether the shell treats it as a comment or not
1 depends on your shell.
1
1 * A variable definition in a "rule context" which is indented by a
1 tab as the first character on the line, will be considered part of
1 a recipe, not a 'make' variable definition, and passed to the
1 shell.
1
11 * A conditional expression ('ifdef', 'ifeq', etc. ⇒Syntax of
Conditionals Conditional Syntax.) in a "rule context" which is
1 indented by a tab as the first character on the line, will be
1 considered part of a recipe and be passed to the shell.
1
Menu