DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(make.info.gz) Target-specific

Info Catalog (make.info.gz) Environment (make.info.gz) Using Variables (make.info.gz) Pattern-specific
 
 6.10 Target-specific Variable Values
 ====================================
 
 Variable values in `make' are usually global; that is, they are the
 same regardless of where they are evaluated (unless they're reset, of
 course).  One exception to that is automatic variables ( Automatic
 Variables).
 
    The other exception is "target-specific variable values".  This
 feature allows you to define different values for the same variable,
 based on the target that `make' is currently building.  As with
 automatic variables, these values are only available within the context
 of a target's command script (and in other target-specific assignments).
 
    Set a target-specific variable value like this:
 
      TARGET ... : VARIABLE-ASSIGNMENT
 
 or like this:
 
      TARGET ... : override VARIABLE-ASSIGNMENT
 
 or like this:
 
      TARGET ... : export VARIABLE-ASSIGNMENT
 
    Multiple TARGET values create a target-specific variable value for
 each member of the target list individually.
 
    The VARIABLE-ASSIGNMENT can be any valid form of assignment;
 recursive (`='), static (`:='), appending (`+='), or conditional
 (`?=').  All variables that appear within the VARIABLE-ASSIGNMENT are
 evaluated within the context of the target: thus, any
 previously-defined target-specific variable values will be in effect.
 Note that this variable is actually distinct from any "global" value:
 the two variables do not have to have the same flavor (recursive vs.
 static).
 
    Target-specific variables have the same priority as any other
 makefile variable.  Variables provided on the command-line (and in the
 environment if the `-e' option is in force) will take precedence.
 Specifying the `override' directive will allow the target-specific
 variable value to be preferred.
 
    There is one more special feature of target-specific variables: when
 you define a target-specific variable that variable value is also in
 effect for all prerequisites of this target, and all their
 prerequisites, etc. (unless those prerequisites override that variable
 with their own target-specific variable value).  So, for example, a
 statement like this:
 
      prog : CFLAGS = -g
      prog : prog.o foo.o bar.o
 
 will set `CFLAGS' to `-g' in the command script for `prog', but it will
 also set `CFLAGS' to `-g' in the command scripts that create `prog.o',
 `foo.o', and `bar.o', and any command scripts which create their
 prerequisites.
 
    Be aware that a given prerequisite will only be built once per
 invocation of make, at most.  If the same file is a prerequisite of
 multiple targets, and each of those targets has a different value for
 the same target-specific variable, then the first target to be built
 will cause that prerequisite to be built and the prerequisite will
 inherit the target-specific value from the first target.  It will
 ignore the target-specific values from any other targets.
 
Info Catalog (make.info.gz) Environment (make.info.gz) Using Variables (make.info.gz) Pattern-specific
automatically generated byinfo2html