make: Using Variables

1 
1 6 How to Use Variables
1 **********************
1 
1 A "variable" is a name defined in a makefile to represent a string of
1 text, called the variable's "value".  These values are substituted by
1 explicit request into targets, prerequisites, recipes, and other parts
1 of the makefile.  (In some other versions of 'make', variables are
1 called "macros".)
1 
1    Variables and functions in all parts of a makefile are expanded when
1 read, except for in recipes, the right-hand sides of variable
1 definitions using '=', and the bodies of variable definitions using the
1 'define' directive.
1 
1    Variables can represent lists of file names, options to pass to
1 compilers, programs to run, directories to look in for source files,
1 directories to write output in, or anything else you can imagine.
1 
1    A variable name may be any sequence of characters not containing ':',
1 '#', '=', or whitespace.  However, variable names containing characters
1 other than letters, numbers, and underscores should be considered
1 carefully, as in some shells they cannot be passed through the
11 environment to a sub-'make' (⇒Communicating Variables to a
 Sub-'make' Variables/Recursion.).  Variable names beginning with '.'
1 and an uppercase letter may be given special meaning in future versions
1 of 'make'.
1 
1    Variable names are case-sensitive.  The names 'foo', 'FOO', and 'Foo'
1 all refer to different variables.
1 
1    It is traditional to use upper case letters in variable names, but we
1 recommend using lower case letters for variable names that serve
1 internal purposes in the makefile, and reserving upper case for
1 parameters that control implicit rules or for parameters that the user
11 should override with command options (⇒Overriding Variables
 Overriding.).
1 
1    A few variables have names that are a single punctuation character or
1 just a few characters.  These are the "automatic variables", and they
1 have particular specialized uses.  ⇒Automatic Variables.
1 

Menu