Roland Ver. 4.5 Informações Técnicas Página 73

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 212
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 72
Chapter 6: How to Use Variables 63
For example:
foo := a.o b.o c.o
bar := $(foo:%.o=%.c)
sets bar to a.c b.c c.c’.
6.3.2 Computed Variable Names
Computed variable names are a complicated concept needed only for sophisticated makefile
programming. For most purposes you need not consider them, except to know that making
a variable with a dollar sign in its name might have strange results. However, if you are the
type that wants to understand everything, or you are actually interested in what they do,
read on.
Variables may be referenced inside the name of a variable. This is called a computed
variable name or a nested variable reference. For example,
x = y
y = z
a := $($(x))
defines a as z’: the $(x) inside $($(x)) expands to y’, so $($(x)) expands to $(y)
which in turn expands to z’. Here the name of the variable to reference is not stated
explicitly; it is computed by expansion of $(x)’. The reference $(x) here is nested within
the outer variable reference.
The previous example shows two levels of nesting, but any number of levels is possible.
For example, here are three levels:
x = y
y = z
z = u
a := $($($(x)))
Here the innermost $(x) expands to y’, so $($(x)) expands to $(y) which in turn
expands to z’; now we have $(z)’, which becomes u’.
References to recursively-expanded variables within a variable name are re-expanded in
the usual fashion. For example:
x = $(y)
y = z
z = Hello
a := $($(x))
defines a as Hello’: $($(x)) becomes $($(y)) which becomes $(z) which becomes
Hello’.
Nested variable references can also contain modified references and function invocations
(see Chapter 8 [Functions for Transforming Text], page 83), just like any other reference.
For example, using the subst function (see Section 8.2 [Functions for String Substitution
and Analysis], page 84):
Vista de página 72
1 2 ... 68 69 70 71 72 73 74 75 76 77 78 ... 211 212

Comentários a estes Manuais

Sem comentários