Chapter 8: Functions for Transforming Text 95
‘environment’
if variable was inherited from the environment provided to make.
‘environment override’
if variable was inherited from the environment provided to make, and is over-
riding a setting for variable in the makefile as a result of the ‘-e’ option (see
Section 9.7 [Summary of Options], page 104).
‘file’
if variable was defined in a makefile.
‘command line’
if variable was defined on the command line.
‘override’
if variable was defined with an override directive in a makefile (see Section 6.7
[The override Directive], page 68).
‘automatic’
if variable is an automatic variable defined for the execution of the recipe for
each rule (see Section 10.5.3 [Automatic Variables], page 120).
This information is primarily useful (other than for your curiosity) to determine if you
want to believe the value of a variable. For example, suppose you have a makefile foo that
includes another makefile bar. You want a variable bletch to be defined in bar if you
run the command ‘make -f bar’, even if the environment contains a definition of bletch.
However, if foo defined bletch before including bar, you do not want to override that
definition. This could be done by using an override directive in foo, giving that definition
precedence over the later definition in bar; unfortunately, the override directive would
also override any command line definitions. So, bar could include:
ifdef bletch
ifeq "$(origin bletch)" "environment"
bletch = barf, gag, etc.
endif
endif
If bletch has been defined from the environment, this will redefine it.
If you want to override a previous definition of bletch if it came from the environment,
even under ‘-e’, you could instead write:
ifneq "$(findstring environment,$(origin bletch))" ""
bletch = barf, gag, etc.
endif
Here the redefinition takes place if ‘$(origin bletch)’ returns either ‘environment’ or
‘environment override’. See Section 8.2 [Functions for String Substitution and Analysis],
page 84.
8.11 The flavor Function
The flavor function, like the origin function, does not operate on the values of variables
but rather it tells you something about a variable. Specifically, it tells you the flavor of a
variable (see Section 6.2 [The Two Flavors of Variables], page 60).
Kommentare zu diesen Handbüchern