* AC_OUTPUT allows the optional environment variable CONFIG_STATUS to
override the file name "config.status".
* AC_OUTPUT and AC_CONFIG_HEADER allow you to override the input-file names.
-* AC_OUTPUT automatically substitutes the values of CFLAGS, CXXFLAGS, and
- LDFLAGS from the environment, with default values.
+* AC_OUTPUT automatically substitutes the values of CFLAGS, CXXFLAGS,
+ CPPFLAGS, and LDFLAGS from the environment, with default values.
* AC_PROG_INSTALL looks for install.sh in the directory specified by
AC_CONFIG_AUXDIR, or srcdir or srcdir/.. or srcdir/../.. by default.
* AC_DEFINE, AC_DEFINE_UNQUOTED, and AC_SUBST are more robust and smaller.
------------------------------------------------------------------------------
* Try it on Emacs configure.in, and adapt that to use the new features.
-Add equivalents of CFLAGS and LDFLAGS for the system to set,
-and which CPP will also use?
------------------------------------------------------------------------------
AC_SUBST(DEFS)dnl
AC_SUBST_DEFAULT(CFLAGS, -g)dnl
AC_SUBST_DEFAULT(CXXFLAGS, -g)dnl
+AC_SUBST_DEFAULT(CPPFLAGS, )dnl
AC_SUBST_DEFAULT(LDFLAGS, )dnl
])dnl
dnl
[define([AC_LANG], [C])dnl
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='${CPP}'
-ac_compile='${CC-cc} $CFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
+ac_cpp='${CPP} $CPPFLAGS'
+ac_compile='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
])dnl
dnl
dnl AC_LANG_CPLUSPLUS()
[define([AC_LANG], [CPLUSPLUS])dnl
ac_ext=C
# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='${CXXCPP}'
-ac_compile='${CXX-gcc} $CXXFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
+ac_cpp='${CXXCPP} $CPPFLAGS'
+ac_compile='${CXX-gcc} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
])dnl
dnl
dnl Push the current language on a stack.
This macro calls @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP} (depending
on which language is current, @pxref{Language Choice}), if it hasn't
-been called already. It does not use @code{CFLAGS}, because -g, -O,
-etc. are not valid options to many C preprocessors.
+been called already. It uses @code{CPPFLAGS}, but not @code{CFLAGS},
+because -g, -O, etc. are not valid options to many C preprocessors.
@end defmac
@defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
@code{#include} statements needed by the code in @var{function-body}.
If the file compiles and links successfully, run shell commands
@var{action-if-found}, otherwise run @var{action-if-not-found}. This
-macro uses @code{CFLAGS} and @code{LDFLAGS} and @code{LIBS} when
-compiling.
+macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS},
+@code{LDFLAGS}, and @code{LIBS} when compiling.
@end defmac
@defmac AC_TRY_RUN (@var{program}, @var{action-if-true} @r{[}, @var{action-if-false} @r{[}, @var{action-if-cross-compiling}@r{]]})
backquote substitutions are performed. If it compiles and links
successfully and returns an exit status of 0 when executed, run shell
commands @var{action-if-true}. Otherwise run shell commands
-@var{action-if-false}. This macro uses @code{CFLAGS} and @code{LDFLAGS}
-and @code{LIBS} when compiling.
+@var{action-if-false}. This macro uses @code{CFLAGS} or
+@code{CXXFLAGS}, @code{CPPFLAGS}, @code{LDFLAGS}, and @code{LIBS} when
+compiling.
If the C compiler being used does not produce executables that run on
the system where @code{configure} is being run, then the test program is
@var{value} should not contain literal newlines, and if you are not
using @code{AC_CONFIG_HEADER} it should not contain any @samp{#}
characters, as @code{make} tends to eat them. To use a shell variable
-as the value, use @code{AC_DEFINE_UNQUOTED} instead.
+or a value containing the @code{m4} quote characters @samp{[} or
+@samp{]}, use @code{AC_DEFINE_UNQUOTED} instead.
@code{AC_OUTPUT} substitutes the values defined by this macro as the
variable @code{DEFS} in the file(s) that it generates (typically
@example
AC_SUBST_DEFAULT(CFLAGS, -g)dnl
AC_SUBST_DEFAULT(CXXFLAGS, -g)dnl
+AC_SUBST_DEFAULT(CPPFLAGS, )dnl
AC_SUBST_DEFAULT(LDFLAGS, )dnl
@end example
@end defmac
@end defvar
@defvar CFLAGS
-Debugging, optimization, header file search directory, and other
-miscellaneous options for the C compiler. The default value is
-@samp{-g} if it is not set in the environment when @code{configure} runs.
-@code{configure} uses this variable when compiling programs to test
-for C features.
+Debugging and optimization options for the C compiler. The default
+value is @samp{-g} if it is not set in the environment when
+@code{configure} runs. @code{configure} uses this variable when
+compiling programs to test for C features.
+@end defvar
+
+@defvar CPPFLAGS
+Header file search directory (@samp{-I@var{dir}}) and any other
+miscellaneous options for the C preprocessor and compiler. The default
+value is empty if it is not set in the environment when @code{configure}
+runs. @code{configure} uses this variable when compiling or
+preprocessing programs to test for C features.
@end defvar
@defvar CXXFLAGS
-Debugging, optimization, header file search directory, and other
-miscellaneous options for the C++ compiler. The default value is
-@samp{-g} if it is not set in the environment when @code{configure} runs.
-@code{configure} uses this variable when compiling programs to test
-for C++ features.
+Debugging and optimization options for the C++ compiler. The default
+value is @samp{-g} if it is not set in the environment when
+@code{configure} runs. @code{configure} uses this variable when
+compiling programs to test for C++ features.
@end defvar
@defvar DEFS
@end defvar
@defvar LDFLAGS
-Stripping, library search directories, and other miscellaneous options
-for the linker. The default value is empty if it is not set in the
-environment when @code{configure} runs.
-@code{configure} uses this variable when linking programs to test
-for C features.
+Stripping (@samp{-s}) and any other miscellaneous options for the
+linker. The default value is empty if it is not set in the environment
+when @code{configure} runs. @code{configure} uses this variable when
+linking programs to test for C features.
@end defvar
@defvar LIBS
This macro calls @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP} (depending
on which language is current, @pxref{Language Choice}), if it hasn't
-been called already. It does not use @code{CFLAGS}, because -g, -O,
-etc. are not valid options to many C preprocessors.
+been called already. It uses @code{CPPFLAGS}, but not @code{CFLAGS},
+because -g, -O, etc. are not valid options to many C preprocessors.
@end defmac
@defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]})
@code{#include} statements needed by the code in @var{function-body}.
If the file compiles and links successfully, run shell commands
@var{action-if-found}, otherwise run @var{action-if-not-found}. This
-macro uses @code{CFLAGS} and @code{LDFLAGS} and @code{LIBS} when
-compiling.
+macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS},
+@code{LDFLAGS}, and @code{LIBS} when compiling.
@end defmac
@defmac AC_TRY_RUN (@var{program}, @var{action-if-true} @r{[}, @var{action-if-false} @r{[}, @var{action-if-cross-compiling}@r{]]})
backquote substitutions are performed. If it compiles and links
successfully and returns an exit status of 0 when executed, run shell
commands @var{action-if-true}. Otherwise run shell commands
-@var{action-if-false}. This macro uses @code{CFLAGS} and @code{LDFLAGS}
-and @code{LIBS} when compiling.
+@var{action-if-false}. This macro uses @code{CFLAGS} or
+@code{CXXFLAGS}, @code{CPPFLAGS}, @code{LDFLAGS}, and @code{LIBS} when
+compiling.
If the C compiler being used does not produce executables that run on
the system where @code{configure} is being run, then the test program is
@var{value} should not contain literal newlines, and if you are not
using @code{AC_CONFIG_HEADER} it should not contain any @samp{#}
characters, as @code{make} tends to eat them. To use a shell variable
-as the value, use @code{AC_DEFINE_UNQUOTED} instead.
+or a value containing the @code{m4} quote characters @samp{[} or
+@samp{]}, use @code{AC_DEFINE_UNQUOTED} instead.
@code{AC_OUTPUT} substitutes the values defined by this macro as the
variable @code{DEFS} in the file(s) that it generates (typically
@example
AC_SUBST_DEFAULT(CFLAGS, -g)dnl
AC_SUBST_DEFAULT(CXXFLAGS, -g)dnl
+AC_SUBST_DEFAULT(CPPFLAGS, )dnl
AC_SUBST_DEFAULT(LDFLAGS, )dnl
@end example
@end defmac
@end defvar
@defvar CFLAGS
-Debugging, optimization, header file search directory, and other
-miscellaneous options for the C compiler. The default value is
-@samp{-g} if it is not set in the environment when @code{configure} runs.
-@code{configure} uses this variable when compiling programs to test
-for C features.
+Debugging and optimization options for the C compiler. The default
+value is @samp{-g} if it is not set in the environment when
+@code{configure} runs. @code{configure} uses this variable when
+compiling programs to test for C features.
+@end defvar
+
+@defvar CPPFLAGS
+Header file search directory (@samp{-I@var{dir}}) and any other
+miscellaneous options for the C preprocessor and compiler. The default
+value is empty if it is not set in the environment when @code{configure}
+runs. @code{configure} uses this variable when compiling or
+preprocessing programs to test for C features.
@end defvar
@defvar CXXFLAGS
-Debugging, optimization, header file search directory, and other
-miscellaneous options for the C++ compiler. The default value is
-@samp{-g} if it is not set in the environment when @code{configure} runs.
-@code{configure} uses this variable when compiling programs to test
-for C++ features.
+Debugging and optimization options for the C++ compiler. The default
+value is @samp{-g} if it is not set in the environment when
+@code{configure} runs. @code{configure} uses this variable when
+compiling programs to test for C++ features.
@end defvar
@defvar DEFS
@end defvar
@defvar LDFLAGS
-Stripping, library search directories, and other miscellaneous options
-for the linker. The default value is empty if it is not set in the
-environment when @code{configure} runs.
-@code{configure} uses this variable when linking programs to test
-for C features.
+Stripping (@samp{-s}) and any other miscellaneous options for the
+linker. The default value is empty if it is not set in the environment
+when @code{configure} runs. @code{configure} uses this variable when
+linking programs to test for C features.
@end defvar
@defvar LIBS
environment. Using a Bourne-compatible shell, you can do that on the
command line like this:
@example
-CC=c89 CFLAGS=-O2 LDFLAGS=-s LIBS=-lposix ./configure
+CC=c89 CFLAGS=-O2 CPPFLAGS=-I/usr/local/include LDFLAGS=-s LIBS=-lposix ./configure
@end example
@noindent
Or on systems that have the @code{env} program, you can do it like this:
@example
-env CC=c89 CFLAGS=-O2 LDFLAGS=-s LIBS=-lposix ./configure
+env CC=c89 CFLAGS=-O2 CPPFLAGS=-I/usr/local/include LDFLAGS=-s LIBS=-lposix ./configure
@end example
@node Build Directory
environment. Using a Bourne-compatible shell, you can do that on the
command line like this:
@example
-CC=c89 CFLAGS=-O2 LDFLAGS=-s LIBS=-lposix ./configure
+CC=c89 CFLAGS=-O2 CPPFLAGS=-I/usr/local/include LDFLAGS=-s LIBS=-lposix ./configure
@end example
@noindent
Or on systems that have the @code{env} program, you can do it like this:
@example
-env CC=c89 CFLAGS=-O2 LDFLAGS=-s LIBS=-lposix ./configure
+env CC=c89 CFLAGS=-O2 CPPFLAGS=-I/usr/local/include LDFLAGS=-s LIBS=-lposix ./configure
@end example
@node Build Directory
AC_SUBST(DEFS)dnl
AC_SUBST_DEFAULT(CFLAGS, -g)dnl
AC_SUBST_DEFAULT(CXXFLAGS, -g)dnl
+AC_SUBST_DEFAULT(CPPFLAGS, )dnl
AC_SUBST_DEFAULT(LDFLAGS, )dnl
])dnl
dnl
[define([AC_LANG], [C])dnl
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='${CPP}'
-ac_compile='${CC-cc} $CFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
+ac_cpp='${CPP} $CPPFLAGS'
+ac_compile='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
])dnl
dnl
dnl AC_LANG_CPLUSPLUS()
[define([AC_LANG], [CPLUSPLUS])dnl
ac_ext=C
# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='${CXXCPP}'
-ac_compile='${CXX-gcc} $CXXFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
+ac_cpp='${CXXCPP} $CPPFLAGS'
+ac_compile='${CXX-gcc} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.${ac_ext} -o conftest $LIBS 1>&AC_FD_CC 2>&AC_FD_CC'
])dnl
dnl
dnl Push the current language on a stack.