Roland Ver. 4.5 Technical Information Seite 76

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 212
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 75
66 GNU make
defines a variable named objects. Whitespace around the variable name and immediately
after the = is ignored.
Variables defined with = are recursively expanded variables. Variables defined with
:=’ or ‘::=’ are simply expanded variables; these definitions can contain variable references
which will be expanded before the definition is made. See Section 6.2 [The Two Flavors of
Variables], page 60.
The variable name may contain function and variable references, which are expanded
when the line is read to find the actual variable name to use.
There is no limit on the length of the value of a variable except the amount of memory
on the computer. You can split the value of a variable into multiple physical lines for
readability (see Section 3.1.1 [Splitting Long Lines], page 12).
Most variable names are considered to have the empty string as a value if you have never
set them. Several variables have built-in initial values that are not empty, but you can set
them in the usual ways (see Section 10.3 [Variables Used by Implicit Rules], page 115).
Several special variables are set automatically to a new value for each rule; these are called
the automatic variables (see Section 10.5.3 [Automatic Variables], page 120).
If you’d like a variable to be set to a value only if it’s not already set, then you can
use the shorthand operator ?= instead of =’. These two settings of the variable FOO are
identical (see Section 8.10 [The origin Function], page 94):
FOO ?= bar
and
ifeq ($(origin FOO), undefined)
FOO = bar
endif
The shell assignment operator != can be used to execute a program and set a variable
to its output. This operator first evaluates the right-hand side, then passes that result to
the shell for execution. If the result of the execution ends in a newline, that one newline is
removed; all other newlines are replaced by spaces. The resulting string is then placed into
the named recursively-expanded variable. For example:
hash != printf ’\043’
file_list != find . -name ’*.c’
If the result of the execution could produce a $, and you don’t intend what follows that
to be interpreted as a make variable or function reference, then you must replace every $
with $$ as part of the execution. Alternatively, you can set a simply expanded variable to
the result of running a program using the shell function call. See Section 8.13 [The shell
Function], page 97. For example:
hash := $(shell printf ’\043’)
var := $(shell find . -name "*.c")
6.6 Appending More Text to Variables
Often it is useful to add more text to the value of a variable already defined. You do this
with a line containing +=’, like this:
objects += another.o
Seitenansicht 75
1 2 ... 71 72 73 74 75 76 77 78 79 80 81 ... 211 212

Kommentare zu diesen Handbüchern

Keine Kommentare