autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03-ac-cpp-and-cc.patch


From: Akim Demaille
Subject: 03-ac-cpp-and-cc.patch
Date: Sun, 27 Oct 2002 19:14:58 +0100

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * lib/autoconf/headers.m4 (AC_HEADER_STDC): Don't use AC_TRY_CPP.
        
        More `check config.log' messages.
        
        * lib/autoconf/general.m4 (AC_MSG_FAILURE): New.
        * doc/autoconf.texi (Printing Messages): Document it.
        * lib/autoconf/types.m4 (AC_CHECK_SIZEOF): Use it when
        appropriate.
        * lib/autoconf/lang.m4 (_AC_COMPILER_EXEEXT_DEFAULT)
        (_AC_COMPILER_EXEEXT_WORKS, _AC_COMPILER_EXEEXT_O)
        (_AC_COMPILER_OBJEXT): Likewise.
        * lib/autoconf/general.m4 (AC_RUN_IFELSE): Likewise.
        * lib/autoconf/fortran.m4 (_AC_LANG_PROGRAM_C_F77_HOOKS):
        Likewise.
        * lib/autoconf/c.m4 (AC_PROG_CPP, AC_PROG_CC, AC_PROG_CXXCPP):
        Likewise.
        
        Deprecate macros with unsual interface.
        
        * lib/autoconf/general.m4 (AC_TRY_CPP, AC_TRY_LINK)
        (AC_TRY_COMPILE, AC_TRY_RUN): AU_DEFUN'ed.
        
        Document the new ones, and proper style.
        
        * doc/autoconf.texi (Generating Sources): New.
        Document AC_LANG_CONFTEST, AC_LANG_SOURCE, AC_LANG_PROGRAM.
        (Examining Declarations): Rename as...
        (Running the Preprocessor): this.
        Document AC_PREPROC_IFELSE.
        (Examining Syntax): Rename as...
        (Running the Compiler): this.
        (AC_FOO_IFELSE vs AC_TRY_FOO): New section.
        (Obsolete Macros): Move the definition of AC_TRY_CPP and
        AC_TRY_COMPILE here.
        
        
Index: NEWS
--- NEWS Sun, 27 Oct 2002 13:51:58 +0100 akim
+++ NEWS Sun, 27 Oct 2002 15:43:25 +0100 akim
@@ -11,6 +11,11 @@
 - AC_CHECK_HEADER, AC_CHECK_HEADERS
   More information on proper use.
 
+- Writing Test Programs
+
+  This sections explains how to write good test sources to use with
+  AC_COMPILE_IFELSE etc.  It documents AC_LANG_PROGRAMS and so forth.
+
 ** autoreconf
 
 - Is more robust to different Gettext installations.
@@ -19,6 +24,7 @@
   compile mode.
 
 ** Obsolete options
+
   Support for the obsoleted options -m, --macrodir, -l, --localdir is
   dropped in favor of the safer --include/--prepend-include scheme.
 
@@ -30,7 +36,9 @@
 ** Macros
 
 - New macros
-  AC_FUNC_MBRTOWC, AC_HEADER_STDBOOL.
+  AC_COMPILER_IFELSE, AC_FUNC_MBRTOWC, AC_HEADER_STDBOOL,
+  AC_LANG_CONFTEST, AC_LANG_SOURCE, AC_LANG_PROGRAM, AC_MSG_FAILURE,
+  AC_PREPROC_IFELSE.
 
 - Obsoleted
   Obsoleted macros are kept for Autoconf backward compatibility, but
Index: doc/autoconf.texi
--- doc/autoconf.texi Sun, 27 Oct 2002 14:07:33 +0100 akim
+++ doc/autoconf.texi Sun, 27 Oct 2002 17:12:56 +0100 akim
@@ -283,8 +283,8 @@ @node Top
 
 * Language Choice::             Selecting which language to use for testing
 * Writing Test Programs::       Forging source files for compilers
-* Examining Declarations::      Detecting header files and declarations
-* Examining Syntax::            Detecting language syntax features
+* Running the Preprocessor::    Detecting preprocessor symbols
+* Running the Compiler::        Detecting language or header features
 * Examining Libraries::         Detecting functions and global variables
 * Run Time::                    Testing for run-time features
 * Systemology::                 A zoology of operating systems
@@ -294,6 +294,7 @@ @node Top
 
 * Guidelines::                  General rules for writing test programs
 * Test Functions::              Avoiding pitfalls in test programs
+* Generating Sources::          Source Program Boilerplates
 
 Results of Tests
 
@@ -418,6 +419,7 @@ @node Top
 * New Macros::                  Interaction with foreign macros
 * Hosts and Cross-Compilation::  Bugward compatibility kludges
 * AC_LIBOBJ vs LIBOBJS::        LIBOBJS is a forbidden token
+* AC_FOO_IFELSE vs AC_TRY_FOO::  A more generic scheme for testing sources
 
 Generating Test Suites with Autotest
 
@@ -4522,8 +4524,8 @@ @node Generic Headers
 inappropriate for typical uses.  Headers are typically used to compile,
 not merely to preprocess, and the old behavior sometimes accepted
 headers that clashed at compile-time.  If you need to check whether a
-header is preprocessable, you can use @code{AC_TRY_CPP} or one of its
-variants (@pxref{Examining Declarations}).
+header is preprocessable, you can use @code{AC_PREPROC_IFELSE}
+(@pxref{Running the Preprocessor}).
 
 This scheme, which improves the robustness of the test, also requires
 that you make sure that headers that must be included before the
@@ -4549,7 +4551,7 @@ @node Declarations
 functions.  If there is no macro specifically defined to check for a
 symbol you need, then you can use the general macros (@pxref{Generic
 Declarations}) or, for more complex tests, you may use
address@hidden (@pxref{Examining Syntax}).
address@hidden (@pxref{Running the Compiler}).
 
 @menu
 * Particular Declarations::     Macros to check for certain declarations
@@ -4635,7 +4637,7 @@ @node Structures
 structures.  If there is no macro specifically defined to check for a
 member you need, then you can use the general structure-member macros
 (@pxref{Generic Structures}) or, for more complex tests, you may use
address@hidden (@pxref{Examining Syntax}).
address@hidden (@pxref{Running the Compiler}).
 
 @menu
 * Particular Structures::       Macros to check for certain structure members
@@ -5018,11 +5020,6 @@ this:
 It is only portable to run @code{CPP} on files with a @file{.c}
 extension.
 
-If the current language is C (@pxref{Language Choice}), many of the
-specific test macros use the value of @code{CPP} indirectly by calling
address@hidden, @code{AC_CHECK_HEADER}, @code{AC_EGREP_HEADER}, or
address@hidden
-
 Some preprocessors don't indicate missing include files by the error
 status.  For such preprocessors an internal variable is set that causes
 other macros to check the standard error from the preprocessor and
@@ -5032,8 +5029,8 @@ this:
 
 The following macros check for C compiler or machine architecture
 features.  To check for characteristics not listed here, use
address@hidden (@pxref{Examining Syntax}) or @code{AC_TRY_RUN}
-(@pxref{Run Time})
address@hidden (@pxref{Running the Compiler}) or
address@hidden (@pxref{Run Time})
 
 @defmac AC_C_BACKSLASH_A
 @acindex HAVE_C_BACKSLASH_A
@@ -5236,11 +5233,6 @@ @node C++ Compiler
 It is only portable to run @code{CXXCPP} on files with a @file{.c},
 @file{.C}, or @file{.cc} extension.
 
-If the current language is C++ (@pxref{Language Choice}), many of the
-specific test macros use the value of @code{CXXCPP} indirectly by
-calling @code{AC_TRY_CPP}, @code{AC_CHECK_HEADER},
address@hidden, or @code{AC_EGREP_CPP}.
-
 Some preprocessors don't indicate missing include files by the error
 status.  For such preprocessors an internal variable is set that causes
 other macros to check the standard error from the preprocessor and
@@ -5291,8 +5283,8 @@ @node Fortran 77 Compiler
 
 
 The following macros check for Fortran 77 compiler characteristics.  To
-check for characteristics not listed here, use @code{AC_TRY_COMPILE}
-(@pxref{Examining Syntax}) or @code{AC_TRY_RUN} (@pxref{Run Time}),
+check for characteristics not listed here, use @code{AC_COMPILE_IFELSE}
+(@pxref{Running the Compiler}) or @code{AC_TRY_RUN} (@pxref{Run Time}),
 making sure to first set the current language to Fortran 77
 @code{AC_LANG(Fortran 77)} (@pxref{Language Choice}).
 
@@ -5636,8 +5628,8 @@ @node Writing Tests
 @menu
 * Language Choice::             Selecting which language to use for testing
 * Writing Test Programs::       Forging source files for compilers
-* Examining Declarations::      Detecting header files and declarations
-* Examining Syntax::            Detecting language syntax features
+* Running the Preprocessor::    Detecting preprocessor symbols
+* Running the Compiler::        Detecting language or header features
 * Examining Libraries::         Detecting functions and global variables
 * Run Time::                    Testing for run-time features
 * Systemology::                 A zoology of operating systems
@@ -5719,11 +5711,30 @@ @node Writing Test Programs
 @menu
 * Guidelines::                  General rules for writing test programs
 * Test Functions::              Avoiding pitfalls in test programs
+* Generating Sources::          Source Program Boilerplates
 @end menu
 
 @node Guidelines
 @subsection Guidelines for Test Programs
 
+The most important rule to follow when writing testing samples is:
+
address@hidden @emph{Look for realism.}
+
+This motto means that testing samples must be written with the same
+strictness as real programs are written.  In particular, you should
+avoid ``shortcuts'' and simplifications.
+
+Don't just play with the preprocessor if you want to prepare a
+compilation.  For instance, using @command{cpp} to check if a header is
+functional might let your @command{configure} accept a header which will
+cause some @emph{compiler} error.  Do not hesitate checking header with
+other headers included before, especially required headers.
+
+Make sure the symbols you use are properly defined, i.e., refrain for
+simply declaring a function yourself instead of including the proper
+header.
+
 Test programs should not write anything to the standard output.  They
 should return 0 if the test succeeds, nonzero otherwise, so that success
 can be distinguished easily from a core dump or other failure;
@@ -5794,34 +5805,173 @@ @node Test Functions
 with a different return type (such as @code{char}).
 
 
address@hidden Generating Sources
address@hidden Generating Sources
 
+Autoconf provides a set of macros that can be used to generate test
+source files.  They are written to be language generic, i.e., they
+actually depend on the current language (@pxref{Language Choice}) to
+``format'' the output properly.
 
address@hidden Examining Declarations
address@hidden Examining Declarations
 
-The macro @code{AC_TRY_CPP} is used to check whether particular header
-files exist.  You can check for one at a time, or more than one if you
-need several header files to all exist for some purpose.
address@hidden AC_LANG_CONFTEST (@var{source})
address@hidden LANG_CONFTEST
+Save the @var{source} text in the current test source file:
address@hidden@var{extension}} where the @var{extension} depends on the
+current language.
 
address@hidden AC_TRY_CPP (@var{input}, @ovar{action-if-true}, 
@ovar{action-if-false})
address@hidden TRY_CPP
-If the preprocessor produces no error messages while processing the
address@hidden (typically includes), run shell commands
address@hidden  Otherwise run shell commands
address@hidden  Beware that @var{input} is double quoted.  Shell
-variable, back quote, and backslash substitutions are performed on
address@hidden
+Note that the @var{source} is evaluated exactly once, like regular
+Autoconf macro arguments, and therefore (i) you may pass a macro
+invocation, (ii) if not, be sure to double quote if needed.
address@hidden defmac
+
address@hidden AC_LANG_SOURCE (@var{source})
address@hidden LANG_SOURCE
+Expands into the @var{source}, with proper definition of the current
+location (e.g., @samp{#line 1234 "configure"} in C), and definition of
+all the @code{AC_DEFINE} performed so far.
address@hidden defmac
+
+For instance executing (observe the double quotation!):
+
address@hidden
+AC_INIT(Autoconf Documentation, @value{VERSION}, bug-autoconf@@gnu.org)
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"])
+AC_LANG_CONFTEST(
+   [AC_LANG_SOURCE([[const char hw[] = "Hello, World\n";]])])
+gcc -E -dD conftest.c -o -
address@hidden example
+
address@hidden
+results in:
+
address@hidden
+# 1 "conftest.c"
+# 1169 "configure"
+
+# 1 "confdefs.h" 1
+
+#define PACKAGE_NAME "Autoconf Documentation"
+#define PACKAGE_TARNAME "autoconf-documentation"
+#define PACKAGE_VERSION "@value{VERSION}"
+#define PACKAGE_STRING "Autoconf Documentation @value{VERSION}"
+#define PACKAGE_BUGREPORT "bug-autoconf@@gnu.org"
+#define HELLO_WORLD "Hello, World\n"
+# 1170 "configure" 2
+
+const char hw[] = "Hello, World\n";
address@hidden example
+
address@hidden AC_LANG_PROGRAM (@var{prologue}, @var{body})
address@hidden LANG_PROGRAM
+Expands into a source file which consists of the @var{prologue}, and
+then @var{body} as body of the main function (e.g., @code{main} in
+C).  Since it uses @code{AC_LANG_SOURCE}, the feature of the latter are
+available.
address@hidden defmac
+
+For instance:
+
address@hidden
+AC_INIT(Autoconf Documentation, @value{VERSION}, bug-autoconf@@gnu.org)
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"])
+AC_LANG_CONFTEST(
+[AC_LANG_PROGRAM([[const char hw[] = "Hello, World\n";]],
+                 [[fputs (hw, stdout);]])])
+gcc -E -dD conftest.c -o -
address@hidden example
+
address@hidden
+results in:
+
address@hidden
+# 1 "conftest.c"
+# 1169 "configure"
+
+# 1 "confdefs.h" 1
+
+#define PACKAGE_NAME "Autoconf Documentation"
+#define PACKAGE_TARNAME "autoconf-documentation"
+#define PACKAGE_VERSION "@value{VERSION}"
+#define PACKAGE_STRING "Autoconf Documentation @value{VERSION}"
+#define PACKAGE_BUGREPORT "bug-autoconf@@gnu.org"
+#define HELLO_WORLD "Hello, World\n"
+# 1170 "configure" 2
+
+const char hw[] = "Hello, World\n";
+int
+main ()
address@hidden
+fputs (hw, stdout);
+  ;
+  return 0;
address@hidden
address@hidden example
+
address@hidden Running the Preprocessor
address@hidden Running the Preprocessor
+
+Sometimes one might need to run the preprocessor on some source file.
address@hidden it is a bad idea}, as you typically need to @emph{compile}
+your project, not merely run the preprocessor on it; therefore you
+certainly want to run the compiler, not the preprocessor.  Resist to the
+temptation of following the easiest path.
+
+Nevertheless, if you need to run the preprocessor, then use
address@hidden
+
address@hidden AC_PREPROC_IFELSE (@var{input}, @ovar{action-if-true}, 
@ovar{action-if-false})
address@hidden PREPROC_IFELSE
+Run the preprocessor of the current language (@pxref{Language Choice})
+on the @var{input}, run the shell commands @var{action-if-true} on
+success, @var{action-if-false} otherwise.  The @var{input} can be made
+by @code{AC_LANG_PROGRAM} and friends.
 
 This macro uses @code{CPPFLAGS}, but not @code{CFLAGS}, because
 @option{-g}, @option{-O}, etc.@: are not valid options to many C
 preprocessors.
+
+It is customary to report unexpected failures with
address@hidden
 @end defmac
 
-Here is how to find out whether a header file contains a particular
-declaration, such as a typedef, a structure, a structure member, or a
-function.  Use @code{AC_EGREP_HEADER} instead of running @code{grep}
-directly on the header file; on some systems the symbol might be defined
-in another header file that the file you are checking @samp{#include}s.
+For instance:
+
address@hidden
+AC_INIT(Autoconf Documentation, @value{VERSION}, bug-autoconf@@gnu.org)
+AC_DEFINE([HELLO_WORLD], ["Hello, World\n"])
+AC_PREPROC_IFELSE(
+   [AC_LANG_PROGRAM([[const char hw[] = "Hello, World\n";]],
+                    [[fputs (hw, stdout);]])],
+   [AC_MSG_RESULT([OK])],
+   [AC_MSG_FAILURE([unexpected preprocessor failure])])
address@hidden example
+
address@hidden
+results in:
+
address@hidden
+checking for gcc... gcc
+checking for C compiler default output... a.out
+checking whether the C compiler works... yes
+checking whether we are cross compiling... no
+checking for suffix of executables...
+checking for suffix of object files... o
+checking whether we are using the GNU C compiler... yes
+checking whether gcc accepts -g... yes
+checking for gcc option to accept ANSI C... none needed
+checking how to run the C preprocessor... gcc -E
+OK
address@hidden example
+
address@hidden 1
+
+The macro @code{AC_TRY_CPP} (@pxref{Obsolete Macros}) used to play the
+role of @code{AC_PREPROC_IFELSE}, but double quotes its argument, making
+it impossible to use it to ellaborate sources.  You are encouraged to
+get rid of your old use of the macro @code{AC_TRY_CPP} in favor of
address@hidden, but, in the first place, are you sure you need
+to run the @emph{preprocessor} and not the compiler?
 
 @defmac AC_EGREP_HEADER (@var{pattern}, @var{header-file}, 
@var{action-if-found}, @ovar{action-if-not-found})
 @acindex EGREP_HEADER
@@ -5831,18 +5981,6 @@ @node Examining Declarations
 execute @var{action-if-not-found}.
 @end defmac
 
-To check for C preprocessor symbols, either defined by header files or
-predefined by the C preprocessor, use @code{AC_EGREP_CPP}.  Here is an
-example of the latter:
-
address@hidden
-AC_EGREP_CPP(yes,
-[#ifdef _AIX
-  yes
-#endif
-], is_aix=yes, is_aix=no)
address@hidden example
-
 @defmac AC_EGREP_CPP (@var{pattern}, @var{program}, @ovar{action-if-found}, 
@ovar{action-if-not-found})
 @acindex EGREP_CPP
 @var{program} is the text of a C or C++ program, on which shell
@@ -5850,40 +5988,33 @@ @node Examining Declarations
 output of running the preprocessor on @var{program} matches the
 extended regular expression @var{pattern}, execute shell commands
 @var{action-if-found}, otherwise execute @var{action-if-not-found}.
-
-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.
 @end defmac
 
address@hidden Examining Syntax
address@hidden Examining Syntax
-
-To check for a syntax feature of the C, C++, or Fortran 77 compiler, such
-as whether it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to
-try to compile a small program that uses that feature.  You can also use
-it to check for structures and structure members that are not present on
-all systems.
 
address@hidden AC_TRY_COMPILE (@var{includes}, @var{function-body}, 
@ovar{action-if-found}, @ovar{action-if-not-found})
address@hidden TRY_COMPILE
-Create a test program in the current language (@pxref{Language Choice})
-to see whether a function whose body consists of @var{function-body} can
-be compiled.  If the file compiles successfully, run shell commands
address@hidden, otherwise run @var{action-if-not-found}.
 
-This macro double quotes both @var{includes} and @var{function-body}.
address@hidden Running the Compiler
address@hidden Running the Compiler
 
-For C and C++, @var{includes} is any @code{#include} statements needed
-by the code in @var{function-body} (@var{includes} will be ignored if
-the currently selected language is Fortran 77).  This macro also uses
address@hidden or @code{CXXFLAGS} if either C or C++ is the currently
-selected language, as well as @code{CPPFLAGS}, when compiling.  If
-Fortran 77 is the currently selected language then @code{FFLAGS} will be
-used when compiling.
+To check for a syntax feature of the (C, C++, or Fortran 77) compiler,
+such as whether it recognizes a certain keyword, or simply to try some
+library feature, use @code{AC_COMPILE_IFELSE} to try to compile a small
+program that uses that feature.
+
+
address@hidden AC_COMPILE_IFELSE (@var{input}, @ovar{action-if-found}, 
@ovar{action-if-not-found})
address@hidden COMPILE_IFELSE
+Run the compiler of the current language (@pxref{Language Choice}) on
+the @var{input}, run the shell commands @var{action-if-true} on success,
address@hidden otherwise. The @var{input} can be made by
address@hidden and friends.
+
+This macro uses @code{CFLAGS} or @code{CXXFLAGS} if either C or C++ is
+the currently selected language, as well as @code{CPPFLAGS}, when
+compiling.  If Fortran 77 is the currently selected language then
address@hidden will be used when compiling.
 
-This macro does not try to link; use @code{AC_TRY_LINK} if you need to
-do that (@pxref{Examining Libraries}).
+This macro does not try to link; use @code{AC_LINK_IFELSE} if you need
+to do that (@pxref{Examining Libraries}).
 @end defmac
 
 @node Examining Libraries
@@ -6639,6 +6770,14 @@ substitution on them.
 ``cannot'' is preferred to ``can't''.
 @end defmac
 
address@hidden AC_MSG_FAILURE (@var{error-description}, @ovar{exit-status})
address@hidden MSG_FAILURE
+This @code{AC_MSG_ERROR} wrapper notifies the user of an error that
+prevents @command{configure} from completing @emph{and} that additional
+details are provided in @file{config.log}.  This is typically used when
+abnormal results are found during a compilation.
address@hidden defmac
+
 @defmac AC_MSG_WARN (@var{problem-description})
 @acindex MSG_WARN
 Notify the @command{configure} user of a possible problem.  This macro
@@ -12842,6 +12981,32 @@ is:
 @code{AC_HEADER_TIME}
 @end defmac
 
address@hidden AC_TRY_COMPILE (@var{includes}, @var{function-body}, 
@ovar{action-if-found}, @ovar{action-if-not-found})
address@hidden TRY_COMPILE
+Same as @samp{AC_COMPILE_IFELSE([AC_LANG_SOURCE(address@hidden,
address@hidden)], address@hidden,
address@hidden)} (@pxref{Running the Compiler}).
+
+This macro double quotes both @var{includes} and @var{function-body}.
+
+For C and C++, @var{includes} is any @code{#include} statements needed
+by the code in @var{function-body} (@var{includes} will be ignored if
+the currently selected language is Fortran 77).  This macro also uses
address@hidden or @code{CXXFLAGS} if either C or C++ is the currently
+selected language, as well as @code{CPPFLAGS}, when compiling.  If
+Fortran 77 is the currently selected language then @code{FFLAGS} will be
+used when compiling.
address@hidden defmac
+
address@hidden AC_TRY_CPP (@var{input}, @ovar{action-if-true}, 
@ovar{action-if-false})
address@hidden TRY_CPP
+Same as @samp{AC_PREPROC_IFELSE([AC_LANG_SOURCE(address@hidden)],
address@hidden, address@hidden)} (@pxref{Running the
+Preprocessor}).
+
+This macro double quotes the @var{input}.
address@hidden defmac
+
 @defmac AC_UID_T
 @acindex UID_T
 @code{AC_TYPE_UID_T}
@@ -13132,6 +13297,7 @@ @node Autoconf 2.13
 * New Macros::                  Interaction with foreign macros
 * Hosts and Cross-Compilation::  Bugward compatibility kludges
 * AC_LIBOBJ vs LIBOBJS::        LIBOBJS is a forbidden token
+* AC_FOO_IFELSE vs AC_TRY_FOO::  A more generic scheme for testing sources
 @end menu
 
 @node Changed Quotation
@@ -13455,6 +13621,71 @@ @node AC_LIBOBJ vs LIBOBJS
 cannot handle this task, since this is not a macro).
 
 Note that @code{U} must not be used in your Makefiles.
+
+
address@hidden AC_FOO_IFELSE vs AC_TRY_FOO
address@hidden @code{AC_FOO_IFELSE} vs.@: @code{AC_TRY_FOO}
+
+Since Autoconf 2.50, internal codes uses @code{AC_PREPROC_IFELSE},
address@hidden, @code{AC_LINK_IFELSE}, and
address@hidden on the other one hand and @code{AC_LANG_SOURCES},
+and @code{AC_LANG_PROGRAM} on the other hand instead of the deprecated
address@hidden, @code{AC_TRY_COMPILE}, @code{AC_TRY_LINK}, and
address@hidden  The motivations where:
address@hidden @minus
address@hidden
+a more consistent interface: @code{AC_TRY_COMPILE} etc. were double
+quoting their arguments;
+
address@hidden
+the combinatoric explosion is solved by decomposing on the one hand the
+generation of sources, and on the other hand executing the program;
+
address@hidden
+this scheme helps supporting more languages than plain C and C++.
address@hidden itemize
+
+In addition to the change of syntax, the philosphy has changed too:
+while emphasis was put on speed at the expense of accuracy, today's
+Autoconf promotes accuracy of the testing framework at, ahem..., the
+expense of speed.
+
+
+As a perfect example of what is @emph{not} to be done, here is how to
+find out whether a header file contains a particular declaration, such
+as a typedef, a structure, a structure member, or a function.  Use
address@hidden instead of running @code{grep} directly on the
+header file; on some systems the symbol might be defined in another
+header file that the file you are checking @samp{#include}s.
+
+As a (bad) example, here is how you should not check for C preprocessor
+symbols, either defined by header files or predefined by the C
+preprocessor: using @code{AC_EGREP_CPP}:
+
address@hidden
address@hidden
+AC_EGREP_CPP(yes,
+[#ifdef _AIX
+  yes
+#endif
+], is_aix=yes, is_aix=no)
address@hidden group
address@hidden example
+
+The above example, properly written would (i) use
address@hidden, and (ii) run the compiler:
+
address@hidden
address@hidden
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[#if !defined _AIX
+# error _AIX not defined
+#endif
+]])],
+                   [is_aix=yes],
+                   [is_aix=no])
address@hidden group
address@hidden example
 
 
 @c ============================= Generating Test Suites with Autotest
Index: lib/autoconf/c.m4
--- lib/autoconf/c.m4 Sat, 28 Sep 2002 17:01:27 +0200 akim
+++ lib/autoconf/c.m4 Sun, 27 Oct 2002 15:35:53 +0100 akim
@@ -368,7 +368,7 @@ AC_DEFUN([AC_PROG_CPP],
 fi
 AC_MSG_RESULT([$CPP])
 _AC_PROG_PREPROC_WORKS_IFELSE([],
-                    [AC_MSG_ERROR([C preprocessor "$CPP" fails sanity check])])
+                [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
 AC_SUBST(CPP)dnl
 AC_LANG_POP(C)dnl
 ])# AC_PROG_CPP
@@ -416,7 +416,7 @@ AC_DEFUN([AC_PROG_CC],
 fi
 ])
 
-test -z "$CC" && AC_MSG_ERROR([no acceptable C compiler found in \$PATH])
+test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
 
 # Provide some information about the compiler.
 echo "$as_me:$LINENO:" \
@@ -588,7 +588,7 @@ AC_DEFUN([AC_PROG_CXXCPP],
 fi
 AC_MSG_RESULT([$CXXCPP])
 _AC_PROG_PREPROC_WORKS_IFELSE([],
-              [AC_MSG_ERROR([C++ preprocessor "$CXXCPP" fails sanity check])])
+          [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
 AC_SUBST(CXXCPP)dnl
 AC_LANG_POP(C++)dnl
 ])# AC_PROG_CXXCPP
Index: lib/autoconf/fortran.m4
--- lib/autoconf/fortran.m4 Sat, 14 Sep 2002 14:56:56 +0200 akim
+++ lib/autoconf/fortran.m4 Sun, 27 Oct 2002 15:35:53 +0100 akim
@@ -615,7 +615,7 @@ m4_define([_AC_LANG_PROGRAM_C_F77_HOOKS]
                       link to the Fortran 77 libraries.])
 fi])],
       [m4_default([$2],
-                [AC_MSG_ERROR([linking to Fortran libraries from C fails])])])
+            [AC_MSG_FAILURE([linking to Fortran libraries from C fails])])])
 ])# AC_F77_DUMMY_MAIN
 
 
Index: lib/autoconf/general.m4
--- lib/autoconf/general.m4 Sun, 27 Oct 2002 13:35:48 +0100 akim
+++ lib/autoconf/general.m4 Sun, 27 Oct 2002 16:16:26 +0100 akim
@@ -1963,11 +1963,14 @@ m4_define([AC_MSG_RESULT_UNQUOTED],
 # AC_MSG_WARN(PROBLEM)
 # AC_MSG_NOTICE(STRING)
 # AC_MSG_ERROR(ERROR, [EXIT-STATUS = 1])
-# --------------------------------------
+# AC_MSG_FAILURE(ERROR, [EXIT-STATUS = 1])
+# ----------------------------------------
 m4_copy([AS_WARN],    [AC_MSG_WARN])
 m4_copy([AS_MESSAGE], [AC_MSG_NOTICE])
 m4_copy([AS_ERROR],   [AC_MSG_ERROR])
-
+m4_define([AC_MSG_FAILURE],
+[AC_MSG_ERROR([$1
+See `config.log' for more details.], [$2])])
 
 # AU::AC_CHECKING(FEATURE)
 # ------------------------
@@ -2111,7 +2114,7 @@ AC_DEFUN([AC_PREPROC_IFELSE],
 # (But it actually tests whether INCLUDES produces no CPP errors.)
 #
 # INCLUDES are not defaulted and are double quoted.
-AC_DEFUN([AC_TRY_CPP],
+AU_DEFUN([AC_TRY_CPP],
 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([[$1]])], [$2], [$3])])
 
 
@@ -2183,7 +2186,7 @@ AC_DEFUN([AC_COMPILE_IFELSE],
 # AC_TRY_COMPILE(INCLUDES, FUNCTION-BODY,
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # --------------------------------------------------------
-AC_DEFUN([AC_TRY_COMPILE],
+AU_DEFUN([AC_TRY_COMPILE],
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4])])
 
 
@@ -2230,7 +2233,7 @@ AC_DEFUN([AC_LINK_IFELSE],
 # equivalent as far as I can tell from the semantics and the docs.  In
 # the former, $[2] is used as is, in the latter, it is `call' ed.
 # Remove these FIXME: once truth established.
-AC_DEFUN([AC_TRY_LINK],
+AU_DEFUN([AC_TRY_LINK],
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4])])
 
 
@@ -2287,7 +2290,7 @@ AC_DEFUN([AC_RUN_IFELSE],
                      [$0 called without default to allow cross compiling])])dnl
 if test "$cross_compiling" = yes; then
   m4_default([$4],
-             [AC_MSG_ERROR([cannot run test program while cross compiling])])
+           [AC_MSG_FAILURE([cannot run test program while cross compiling])])
 else
   _AC_RUN_IFELSE($@)
 fi])
@@ -2297,7 +2300,7 @@ AC_DEFUN([AC_RUN_IFELSE],
 #            [ACTION-IF-TRUE], [ACTION-IF-FALSE],
 #            [ACTION-IF-CROSS-COMPILING = RUNTIME-ERROR])
 # --------------------------------------------------------
-AC_DEFUN([AC_TRY_RUN],
+AU_DEFUN([AC_TRY_RUN],
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[$1]])], [$2], [$3], [$4])])
 
 
Index: lib/autoconf/headers.m4
--- lib/autoconf/headers.m4 Sun, 27 Oct 2002 13:35:48 +0100 akim
+++ lib/autoconf/headers.m4 Sun, 27 Oct 2002 17:15:56 +0100 akim
@@ -566,11 +566,13 @@ AC_DEFUN([AC_HEADER_STDBOOL],
 
 AC_DEFUN([AC_HEADER_STDC],
 [AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
-[AC_TRY_CPP([#include <stdlib.h>
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <float.h>
-], ac_cv_header_stdc=yes, ac_cv_header_stdc=no)
+]])],
+                    [ac_cv_header_stdc=yes],
+                    [ac_cv_header_stdc=no])
 
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
Index: lib/autoconf/lang.m4
--- lib/autoconf/lang.m4 Fri, 27 Sep 2002 20:14:45 +0200 akim
+++ lib/autoconf/lang.m4 Sun, 27 Oct 2002 15:35:52 +0100 akim
@@ -478,8 +478,7 @@ m4_define([_AC_COMPILER_EXEEXT_DEFAULT],
 done],
       [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
 cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
-AC_MSG_ERROR([_AC_LANG compiler cannot create executables
-check `config.log' for details.], 77)])
+AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)])
 ac_exeext=$ac_cv_exeext
 AC_MSG_RESULT([$ac_file])
 ])# _AC_COMPILER_EXEEXT_DEFAULT
@@ -500,7 +499,7 @@ m4_define([_AC_COMPILER_EXEEXT_WORKS],
     if test "$cross_compiling" = maybe; then
        cross_compiling=yes
     else
-       AC_MSG_ERROR([cannot run _AC_LANG compiled programs.
+       AC_MSG_FAILURE([cannot run _AC_LANG compiled programs.
 If you meant to cross compile, use `--host'.])
     fi
   fi
@@ -540,7 +539,7 @@ m4_define([_AC_COMPILER_EXEEXT_O],
     * ) break;;
   esac
 done],
-              [AC_MSG_ERROR([cannot compute suffix of executables: cannot 
compile and link])])
+              [AC_MSG_FAILURE([cannot compute suffix of executables: cannot 
compile and link])])
 rm -f conftest$ac_cv_exeext
 AC_MSG_RESULT([$ac_cv_exeext])
 ])# _AC_COMPILER_EXEEXT_O
@@ -598,7 +597,7 @@ m4_define([_AC_COMPILER_OBJEXT],
 done],
       [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD
 cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD
-AC_MSG_ERROR([cannot compute suffix of object files: cannot compile])])
+AC_MSG_FAILURE([cannot compute suffix of object files: cannot compile])])
 rm -f conftest.$ac_cv_objext conftest.$ac_ext])
 AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
 ac_objext=$OBJEXT
Index: lib/autoconf/types.m4
--- lib/autoconf/types.m4 Sat, 28 Sep 2002 17:01:27 +0200 akim
+++ lib/autoconf/types.m4 Sun, 27 Oct 2002 15:35:50 +0100 akim
@@ -396,7 +396,7 @@ AC_DEFUN([AC_CHECK_SIZEOF],
   _AC_COMPUTE_INT([(long) (sizeof ($1))],
                   [AS_TR_SH([ac_cv_sizeof_$1])],
                   [AC_INCLUDES_DEFAULT([$3])],
-                  [AC_MSG_ERROR([cannot compute sizeof ($1), 77])])
+                  [AC_MSG_FAILURE([cannot compute sizeof ($1), 77])])
 else
   AS_TR_SH([ac_cv_sizeof_$1])=0
 fi])dnl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]