[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
8.7 Variables used when building a program
Occasionally it is useful to know which ‘Makefile’ variables Automake uses for compilations, and in which order (see section Flag Variables Ordering); for instance, you might need to do your own compilation in some special cases.
Some variables are inherited from Autoconf; these are CC
,
CFLAGS
, CPPFLAGS
, DEFS
, LDFLAGS
, and
LIBS
.
There are some additional variables that Automake defines on its own:
AM_CPPFLAGS
The contents of this variable are passed to every compilation that invokes the C preprocessor; it is a list of arguments to the preprocessor. For instance, ‘-I’ and ‘-D’ options should be listed here.
Automake already provides some ‘-I’ options automatically, in a separate variable that is also passed to every compilation that invokes the C preprocessor. In particular it generates ‘-I.’, ‘-I$(srcdir)’, and a ‘-I’ pointing to the directory holding ‘config.h’ (if you’ve used
AC_CONFIG_HEADERS
). You can disable the default ‘-I’ options using the ‘nostdinc’ option.When a file to be included is generated during the build and not part of a distribution tarball, its location is under
$(builddir)
, not under$(srcdir)
. This matters especially for packages that use header files placed in sub-directories and want to allow builds outside the source tree (see section Parallel Build Trees (a.k.a. VPATH Builds)). In that case we recommend to use a pair of ‘-I’ options, such as, e.g., ‘-Isome/subdir -I$(srcdir)/some/subdir’ or ‘-I$(top_builddir)/some/subdir -I$(top_srcdir)/some/subdir’. Note that the reference to the build tree should come before the reference to the source tree, so that accidentally leftover generated files in the source directory are ignored.AM_CPPFLAGS
is ignored in preference to a per-executable (or per-library)_CPPFLAGS
variable if it is defined.INCLUDES
This does the same job as
AM_CPPFLAGS
(or any per-target_CPPFLAGS
variable if it is used). It is an older name for the same functionality. This variable is deprecated; we suggest usingAM_CPPFLAGS
and per-target_CPPFLAGS
instead.AM_CFLAGS
This is the variable the ‘Makefile.am’ author can use to pass in additional C compiler flags. In some situations, this is not used, in preference to the per-executable (or per-library)
_CFLAGS
.COMPILE
This is the command used to actually compile a C source file. The file name is appended to form the complete command line.
AM_LDFLAGS
This is the variable the ‘Makefile.am’ author can use to pass in additional linker flags. In some situations, this is not used, in preference to the per-executable (or per-library)
_LDFLAGS
.LINK
This is the command used to actually link a C program. It already includes ‘-o $@’ and the usual variable references (for instance,
CFLAGS
); it takes as “arguments” the names of the object files and libraries to link in. This variable is not used when the linker is overridden with a per-target_LINK
variable or per-target flags cause Automake to define such a_LINK
variable.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on January 25, 2014 using texi2html 5.0.