Roland Ver. 4.5 Informacje Techniczne Strona 31

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 212
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 30
Chapter 4: Writing Rules 21
4 Writing Rules
A rule appears in the makefile and says when and how to remake certain files, called the
rule’s targets (most often only one per rule). It lists the other files that are the prerequisites
of the target, and the recipe to use to create or update the target.
The order of rules is not significant, except for determining the default goal: the target
for make to consider, if you do not otherwise specify one. The default goal is the target of
the first rule in the first makefile. If the first rule has multiple targets, only the first target
is taken as the default. There are two exceptions: a target starting with a period is not
a default unless it contains one or more slashes, /’, as well; and, a target that defines a
pattern rule has no effect on the default goal. (See Section 10.5 [Defining and Redefining
Pattern Rules], page 118.)
Therefore, we usually write the makefile so that the first rule is the one for compiling
the entire program or all the programs described by the makefile (often with a target called
all’). See Section 9.2 [Arguments to Specify the Goals], page 99.
4.1 Rule Syntax
In general, a rule looks like this:
targets : prerequisites
recipe
...
or like this:
targets : prerequisites ; recipe
recipe
...
The targets are file names, separated by spaces. Wildcard characters may be used (see
Section 4.3 [Using Wildcard Characters in File Names], page 23) and a name of the form
a(m) represents member m in archive file a (see Section 11.1 [Archive Members as Targets],
page 129). Usually there is only one target per rule, but occasionally there is a reason to
have more (see Section 4.9 [Multiple Targets in a Rule], page 34).
The recipe lines start with a tab character (or the first character in the value of the
.RECIPEPREFIX variable; see Section 6.14 [Special Variables], page 73). The first recipe line
may appear on the line after the prerequisites, with a tab character, or may appear on the
same line, with a semicolon. Either way, the effect is the same. There are other differences
in the syntax of recipes. See Chapter 5 [Writing Recipes in Rules], page 41.
Because dollar signs are used to start make variable references, if you really want a dollar
sign in a target or prerequisite you must write two of them, $$’ (see Chapter 6 [How to Use
Variables], page 59). If you have enabled secondary expansion (see Section 3.8 [Secondary
Expansion], page 18) and you want a literal dollar sign in the prerequisites list, you must
actually write four dollar signs (‘$$$$’).
You may split a long line by inserting a backslash followed by a newline, but this is not
required, as make places no limit on the length of a line in a makefile.
A rule tells make two things: when the targets are out of date, and how to update them
when necessary.
Przeglądanie stron 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 211 212

Komentarze do niniejszej Instrukcji

Brak uwag