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

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 212
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 102
Chapter 8: Functions for Transforming Text 93
8.8 The value Function
The value function provides a way for you to use the value of a variable without having it
expanded. Please note that this does not undo expansions which have already occurred; for
example if you create a simply expanded variable its value is expanded during the definition;
in that case the value function will return the same result as using the variable directly.
The syntax of the value function is:
$(value variable)
Note that variable is the name of a variable, not a reference to that variable. Therefore
you would not normally use a $ or parentheses when writing it. (You can, however, use a
variable reference in the name if you want the name not to be a constant.)
The result of this function is a string containing the value of variable, without any
expansion occurring. For example, in this makefile:
FOO = $PATH
all:
@echo $(FOO)
@echo $(value FOO)
The first output line would be ATH, since the “$P” would be expanded as a make variable,
while the second output line would be the current value of your $PATH environment variable,
since the value function avoided the expansion.
The value function is most often used in conjunction with the eval function (see
Section 8.9 [Eval Function], page 93).
8.9 The eval Function
The eval function is very special: it allows you to define new makefile constructs that
are not constant; which are the result of evaluating other variables and functions. The
argument to the eval function is expanded, then the results of that expansion are parsed
as makefile syntax. The expanded results can define new make variables, targets, implicit
or explicit rules, etc.
The result of the eval function is always the empty string; thus, it can be placed virtually
anywhere in a makefile without causing syntax errors.
It’s important to realize that the eval argument is expanded twice; first by the eval
function, then the results of that expansion are expanded again when they are parsed
as makefile syntax. This means you may need to provide extra levels of escaping for “$”
characters when using eval. The value function (see Section 8.8 [Value Function], page 93)
can sometimes be useful in these situations, to circumvent unwanted expansions.
Here is an example of how eval can be used; this example combines a number of concepts
and other functions. Although it might seem overly complex to use eval in this example,
rather than just writing out the rules, consider two things: first, the template definition (in
PROGRAM_template) could need to be much more complex than it is here; and second, you
might put the complex, “generic” part of this example into another makefile, then include
it in all the individual makefiles. Now your individual makefiles are quite straightforward.
Vista de página 102
1 2 ... 98 99 100 101 102 103 104 105 106 107 108 ... 211 212

Comentários a estes Manuais

Sem comentários