Roland Ver. 4.5 Información técnica Pagina 77

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 212
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 76
Chapter 6: How to Use Variables 67
This takes the value of the variable objects, and adds the text another.o’ to it (preceded
by a single space). Thus:
objects = main.o foo.o bar.o utils.o
objects += another.o
sets objects to main.o foo.o bar.o utils.o another.o’.
Using += is similar to:
objects = main.o foo.o bar.o utils.o
objects := $(objects) another.o
but differs in ways that become important when you use more complex values.
When the variable in question has not been defined before, += acts just like normal
=’: it defines a recursively-expanded variable. However, when there is a previous defini-
tion, exactly what += does depends on what flavor of variable you defined originally. See
Section 6.2 [The Two Flavors of Variables], page 60, for an explanation of the two flavors
of variables.
When you add to a variable’s value with +=’, make acts essentially as if you had included
the extra text in the initial definition of the variable. If you defined it first with ‘:=’ or ::=’,
making it a simply-expanded variable, += adds to that simply-expanded definition, and
expands the new text before appending it to the old value just as := does (see Section 6.5
[Setting Variables], page 65, for a full explanation of := or ::=’). In fact,
variable := value
variable += more
is exactly equivalent to:
variable := value
variable := $(variable) more
On the other hand, when you use += with a variable that you defined first to be
recursively-expanded using plain =’, make does something a bit different. Recall that when
you define a recursively-expanded variable, make does not expand the value you set for
variable and function references immediately. Instead it stores the text verbatim, and saves
these variable and function references to be expanded later, when you refer to the new
variable (see Section 6.2 [The Two Flavors of Variables], page 60). When you use += on
a recursively-expanded variable, it is this unexpanded text to which make appends the new
text you specify.
variable = value
variable += more
is roughly equivalent to:
temp = value
variable = $(temp) more
except that of course it never defines a variable called temp. The importance of this comes
when the variable’s old value contains variable references. Take this common example:
CFLAGS = $(includes) -O
...
CFLAGS += -pg # enable profiling
Vista de pagina 76
1 2 ... 72 73 74 75 76 77 78 79 80 81 82 ... 211 212

Comentarios a estos manuales

Sin comentarios