make: Suppressing Inheritance

1 
1 6.13 Suppressing Inheritance
1 ============================
1 
1 As described in previous sections, 'make' variables are inherited by
1 prerequisites.  This capability allows you to modify the behavior of a
1 prerequisite based on which targets caused it to be rebuilt.  For
1 example, you might set a target-specific variable on a 'debug' target,
1 then running 'make debug' will cause that variable to be inherited by
1 all prerequisites of 'debug', while just running 'make all' (for
1 example) would not have that assignment.
1 
1    Sometimes, however, you may not want a variable to be inherited.  For
1 these situations, 'make' provides the 'private' modifier.  Although this
1 modifier can be used with any variable assignment, it makes the most
1 sense with target- and pattern-specific variables.  Any variable marked
1 'private' will be visible to its local target but will not be inherited
1 by prerequisites of that target.  A global variable marked 'private'
1 will be visible in the global scope but will not be inherited by any
1 target, and hence will not be visible in any recipe.
1 
1    As an example, consider this makefile:
1      EXTRA_CFLAGS =
1 
1      prog: private EXTRA_CFLAGS = -L/usr/local/lib
1      prog: a.o b.o
1 
1    Due to the 'private' modifier, 'a.o' and 'b.o' will not inherit the
1 'EXTRA_CFLAGS' variable assignment from the 'prog' target.
1