make: Rule Introduction
1
1 2.1 What a Rule Looks Like
1 ==========================
1
1 A simple makefile consists of "rules" with the following shape:
1
1 TARGET ... : PREREQUISITES ...
1 RECIPE
1 ...
1 ...
1
1 A "target" is usually the name of a file that is generated by a
1 program; examples of targets are executable or object files. A target
11 can also be the name of an action to carry out, such as 'clean' (⇒
Phony Targets).
1
1 A "prerequisite" is a file that is used as input to create the
1 target. A target often depends on several files.
1
1 A "recipe" is an action that 'make' carries out. A recipe may have
1 more than one command, either on the same line or each on its own line.
1 *Please note:* you need to put a tab character at the beginning of every
1 recipe line! This is an obscurity that catches the unwary. If you
1 prefer to prefix your recipes with a character other than tab, you can
11 set the '.RECIPEPREFIX' variable to an alternate character (⇒
Special Variables).
1
1 Usually a recipe is in a rule with prerequisites and serves to create
1 a target file if any of the prerequisites change. However, the rule
1 that specifies a recipe for the target need not have prerequisites. For
1 example, the rule containing the delete command associated with the
1 target 'clean' does not have prerequisites.
1
1 A "rule", then, explains how and when to remake certain files which
1 are the targets of the particular rule. 'make' carries out the recipe
1 on the prerequisites to create or update the target. A rule can also
11 explain how and when to carry out an action. ⇒Writing Rules
Rules.
1
1 A makefile may contain other text besides rules, but a simple
1 makefile need only contain rules. Rules may look somewhat more
1 complicated than shown in this template, but all fit the pattern more or
1 less.
1