autoconf: Configuration Headers

1 
1 4.9 Configuration Header Files
1 ==============================
1 
1 When a package contains more than a few tests that define C preprocessor
1 symbols, the command lines to pass `-D' options to the compiler can get
1 quite long.  This causes two problems.  One is that the `make' output
1 is hard to visually scan for errors.  More seriously, the command lines
1 can exceed the length limits of some operating systems.  As an
1 alternative to passing `-D' options to the compiler, `configure'
1 scripts can create a C header file containing `#define' directives.
1 The `AC_CONFIG_HEADERS' macro selects this kind of output.  Though it
1 can be called anywhere between `AC_INIT' and `AC_OUTPUT', it is
1 customary to call it right after `AC_INIT'.
1 
1    The package should `#include' the configuration header file before
1 any other header files, to prevent inconsistencies in declarations (for
1 example, if it redefines `const').
1 
1    To provide for VPATH builds, remember to pass the C compiler a `-I.'
1 option (or `-I..'; whichever directory contains `config.h').  Even if
1 you use `#include "config.h"', the preprocessor searches only the
1 directory of the currently read file, i.e., the source directory, not
1 the build directory.
1 
1    With the appropriate `-I' option, you can use `#include <config.h>'.
1 Actually, it's a good habit to use it, because in the rare case when
1 the source directory contains another `config.h', the build directory
1 should be searched first.
1 
1  -- Macro: AC_CONFIG_HEADERS (HEADER ..., [CMDS], [INIT-CMDS])
11      This macro is one of the instantiating macros; see ⇒
      Configuration Actions.  Make `AC_OUTPUT' create the file(s) in
1      the blank-or-newline-separated list HEADER containing C
1      preprocessor `#define' statements, and replace `@DEFS@' in
1      generated files with `-DHAVE_CONFIG_H' instead of the value of
1      `DEFS'.  The usual name for HEADER is `config.h'.
1 
1      If HEADER already exists and its contents are identical to what
1      `AC_OUTPUT' would put in it, it is left alone.  Doing this allows
1      making some changes in the configuration without needlessly causing
1      object files that depend on the header file to be recompiled.
1 
1      Usually the input file is named `HEADER.in'; however, you can
1      override the input file name by appending to HEADER a
1      colon-separated list of input files.  For example, you might need
1      to make the input file name acceptable to DOS variants:
1 
1           AC_CONFIG_HEADERS([config.h:config.hin])
1 
1 
1  -- Macro: AH_HEADER
1      This macro is defined as the name of the first declared config
1      header and undefined if no config headers have been declared up to
1      this point.  A third-party macro may, for example, require use of
1      a config header without invoking AC_CONFIG_HEADERS twice, like
1      this:
1 
1           AC_CONFIG_COMMANDS_PRE(
1                   [m4_ifndef([AH_HEADER], [AC_CONFIG_HEADERS([config.h])])])
1 
1 
1    ⇒Configuration Actions, for more details on HEADER.
1 

Menu