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