For each program or library that the build system can build,
there is a collection of variables that affects how this happens.
The names of these variables are derived from the values of variables
described in the previous section. For example, if ‘foo’ is listed
bin_PROGRAMS, the variable for listing the source files of the
foo program would be called ‘foo_SOURCES’. For a list of
these variables, see Program and Library Variables.
The name of the program (or library) is used as a base for naming these variables. The text of these names is canonicalized, so that program names and the like do not have to follow Makefile variable naming rules. This entails all characters in the name except for letters, numbers, the at sign (‘@’) and the underscore (‘_’) being turned into underscores.
The at sign is an addition, to make the use of Autoconf substitutions in variable names less obfuscating.
For example, a program named sniff-glue, would be canonicalized as ‘sniff_glue’. An example of a derived variable name is ‘sniff_glue_SOURCES’ (not ‘sniff-glue_SOURCES’.) Similarly, the sources for a library named libmumble++.a would be listed in the ‘libmumble___a_SOURCES’ variable.
As well as the variables that the writer of Makefile.am uses to give information about how to build particular programs, there are variables of that take effect more generally. For example, there are variables specifying how programs and libraries are to be built (see Program Variables).
Some of these general variables correspond
to Makefile variables reserved by the GNU Coding
for the use of the “user”—the
person building the package.
CFLAGS is one such variable
(known as a user variable).
A package maintainer should never set a user variable
(by placing a definition for it in Makefile.am),
so that the person building the package
is always able to override
any of these variables at build time.
If the package maintainer needs to specify any options, they should place them in a so-called shadow variable in Makefile.in. The shadow variable is named by prefixing the user variable’s name. with ‘AM_’: for example, ‘CFLAGS’ becomes ‘AM_CFLAGS’. Shadow variables are only available where they would make sense.
See Flag Variables Ordering for more discussion about these variables and how they interact with per-target variables.