Roland Ver. 4.5 Technické informace Strana 94

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 212
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 93
84 GNU make
8.2 Functions for String Substitution and Analysis
Here are some functions that operate on strings:
$(subst from,to,text)
Performs a textual replacement on the text text: each occurrence of from is
replaced by to. The result is substituted for the function call. For example,
$(subst ee,EE,feet on the street)
substitutes the string fEEt on the strEEt’.
$(patsubst pattern,replacement,text)
Finds whitespace-separated words in text that match pattern and replaces them
with replacement. Here pattern may contain a % which acts as a wildcard,
matching any number of any characters within a word. If replacement also con-
tains a %’, the % is replaced by the text that matched the % in pattern. Only
the first % in the pattern and replacement is treated this way; any subsequent
% is unchanged.
% characters in patsubst function invocations can be quoted with preceding
backslashes (‘\’). Backslashes that would otherwise quote % characters can be
quoted with more backslashes. Backslashes that quote % characters or other
backslashes are removed from the pattern before it is compared file names or
has a stem substituted into it. Backslashes that are not in danger of quoting ‘%
characters go unmolested. For example, the pattern the\%weird\\%pattern\\
has the%weird\ preceding the operative % character, and pattern\\ fol-
lowing it. The final two backslashes are left alone because they cannot affect
any % character.
Whitespace between words is folded into single space characters; leading and
trailing whitespace is discarded.
For example,
$(patsubst %.c,%.o,x.c.c bar.c)
produces the value x.c.o bar.o’.
Substitution references (see Section 6.3.1 [Substitution References], page 62)
are a simpler way to get the effect of the patsubst function:
$(var:pattern=replacement)
is equivalent to
$(patsubst pattern,replacement,$(var))
The second shorthand simplifies one of the most common uses of patsubst:
replacing the suffix at the end of file names.
$(var:suffix=replacement)
is equivalent to
$(patsubst %suffix,%replacement,$(var))
For example, you might have a list of object files:
objects = foo.o bar.o baz.o
To get the list of corresponding source files, you could simply write:
Zobrazit stránku 93
1 2 ... 89 90 91 92 93 94 95 96 97 98 99 ... 211 212

Komentáře k této Příručce

Žádné komentáře