Hi Paul, * Paul Eggert wrote on Wed, Mar 01, 2006 at 01:48:54AM CET: > Several macros in Gnulib really belong in Autoconf. I took a first > cut at migrating the code, and came up with the following proposed > patch to Autoconf. Not all the gnulib macros made the cut, and some > needed to be renamed to avoid backwards-compatibility issues and to > keep the naming conventions. Comments welcome.
First quick review below, snipping everything but interesting patch hunks including file headers. Great work BTW! Cheers, Ralf > Index: doc/autoconf.texi > =================================================================== > RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v > retrieving revision 1.954 > diff -p -u -r1.954 autoconf.texi > --- doc/autoconf.texi 22 Feb 2006 20:18:23 -0000 1.954 > +++ doc/autoconf.texi 1 Mar 2006 00:45:24 -0000 > @@ -749,6 +753,31 @@ The benefits of Automake increase for la > with subdirectories), but even for small programs the added convenience > and portability can be substantial. And that's not [EMAIL PROTECTED] > > [EMAIL PROTECTED] Gnulib > [EMAIL PROTECTED] Gnulib Please add a @cindex entry for Gnulib. > + > [EMAIL PROTECTED] software has a well-deserved reputation for running on > +many different types of systems. While our primary goal is to write > +software for the @acronym{GNU} system, many users and developers have > +been introduced to us through the systems that they were already using. > + > +Gnulib is a central location for common @acronym{GNU} code, intended to > +be shared among free-software packages. Its components are typically I'd write s|free-|free | as done elsewhere in the documentation. > +shared at the source level, rather than being a library that gets built, > +installed, and linked against. The idea is to copy files from Gnulib > +into your own source tree. There is no distribution tarball; developers > +should just grab source modules from the repository. The source files > +are available online, under various licences, mostly GNU GPL or GNU > +LGPL. > + > +Gnulib modules typically contain C source code along with Autoconf > +macros used to configure the source code. For example, the Gnulib > [EMAIL PROTECTED] module implements a @file{stdbool.h} header that nearly > +conforms to C99, even on old-fashioned hosts that lack @file{stdbool.h}. > +This module contains a source file for the replacement header, along > +with an Autoconf macro that arranges to use the replacement header on > +old-fashioned systems. > + > @node Libtool > @section Libtool > @@ -796,7 +825,8 @@ the @acronym{GNU} build tools. > > The home pages for > @uref{http://www.gnu.org/software/autoconf/, Autoconf}, > [EMAIL PROTECTED]://www.gnu.org/software/automake/, Automake}, and > [EMAIL PROTECTED]://www.gnu.org/software/automake/, Automake}, > [EMAIL PROTECTED]://www.gnu.org/software/automake/, Gnulib}, and > @uref{http://www.gnu.org/software/libtool/, Libtool}. > > @item Automake Manual s|automake/, Gnulib|gnulib/, Gnulib| > @@ -5573,6 +5911,22 @@ compatibility, a simple heuristics, quit > implemented. In case of doubt, read the documentation of the former > @code{AC_CHECK_TYPE}, see @ref{Obsolete Macros}. > > [EMAIL PROTECTED] Ranges of Integer Types > [EMAIL PROTECTED] Checks for Ranges of Integer Types > + > +This macro checks for ranges of integer types not covered by the > +``particular'' test macros. > + > [EMAIL PROTECTED] AC_C_TYPE_RANGE_INTEGER (@var{type}, @ovar{min-variable}, > @var{max-variable}, @dvar{includes, default-includes}) > [EMAIL PROTECTED] > +Compute the bounds of the integer @var{type} and define > [EMAIL PROTECTED] and @var{max-variable} to integer constant > +expressions that suitable for use even in the preprocessor. Do not > +define @var{min-variable} if it is absent. Do not define either > +variable if it is already defined by @var{includes}, or if @var{type} is > +not a valid type. > [EMAIL PROTECTED] defmac > + > > @node Compilers and Preprocessors > @section Compilers and Preprocessors s|that|& are| > Index: lib/autoconf/c.m4 > =================================================================== > RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v > retrieving revision 1.210 > diff -p -u -r1.210 c.m4 > --- lib/autoconf/c.m4 24 Jan 2006 00:20:15 -0000 1.210 > +++ lib/autoconf/c.m4 1 Mar 2006 00:45:24 -0000 > @@ -1121,39 +1121,18 @@ fi > > # AC_C_LONG_DOUBLE > # ---------------- > -AC_DEFUN([AC_C_LONG_DOUBLE], > -[AC_CACHE_CHECK( > - [for working long double with more range or precision than double], > - [ac_cv_c_long_double], > - [AC_COMPILE_IFELSE( > - [AC_LANG_BOOL_COMPILE_TRY( > - [[#include <float.h> > - long double const a[] = > - { > - 0.0L, DBL_MIN, DBL_MAX, DBL_EPSILON, > - LDBL_MIN, LDBL_MAX, LDBL_EPSILON > - }; > - long double > - f (long double x) > - { > - return ((x + (unsigned long int) 10) * (-1 / x) + a[0] > - + (x ? f (x) : 'c')); > - } > - ]], > - [[(0 < ((DBL_MAX_EXP < LDBL_MAX_EXP) > - + (DBL_MANT_DIG < LDBL_MANT_DIG) > - - (LDBL_MAX_EXP < DBL_MAX_EXP) > - - (LDBL_MANT_DIG < DBL_MANT_DIG))) > - && (int) LDBL_EPSILON == 0 > - ]])], > - ac_cv_c_long_double=yes, > - ac_cv_c_long_double=no)]) > -if test $ac_cv_c_long_double = yes; then > - AC_DEFINE(HAVE_LONG_DOUBLE, 1, > - [Define to 1 if long double works and has more range or precision > than double.]) > -fi > -])# AC_C_LONG_DOUBLE > - > +AU_DEFUN([AC_C_LONG_DOUBLE], > + [ > + AC_TYPE_LONG_DOUBLE_WIDER > + if test $ac_cv_type_long_double_wider = yes; then > + AC_DEFINE([HAVE_LONG_DOUBLE], 1, > + [Define to 1 if the type `long double' works and has more range or > + precision than `double'.]) > + fi > + ], > + [The macro `AC_C_LONG_DOUBLE' is obsolete. > +You should use `AC_TYPE_LONG_DOUBLE' or `AC_TYPE_LONG_DOUBLE_WIDER' instead.] > +) > > # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN]) > # ------------------------------------------------------------------------- The AU_DEFUN of AC_C_LONG_DOUBLE is repeated in lib/autoconf/types.m4. I fear a bit that external code may rely on $ac_cv_c_long_double. > @@ -1471,3 +1450,120 @@ AC_DEFUN([AC_C_TYPEOF], > fi > fi > ]) > + > + > +# AC_C_TYPE_RANGE_INTEGER(TYPE, [MIN-VARIABLE], MAX-VARIABLE, > +# [INCLUDES = DEFAULT-INCLUDES]) > +# ----------------------------------------------------------- > +# Compute the bounds of the integer TYPE and define MIN-VARIABLE and > +# MAX-VARIABLE to those bounds. The bounds are expressions that are > +# suitable for use in the preprocessor. If MIN-VARIABLE is absent, do > +# not define it. If either variable is already defined by INCLUDES, do > +# not define it. If TYPE does not work, do not define either variable. > +# Works OK if cross compiling. > +m4_define([AC_C_TYPE_RANGE_INTEGER], Why is this m4_define'd and not AC_DEFUN'd? > +[ > + AC_CACHE_CHECK([for $3], [ac_cv_value_$3], > + [ac_cv_value_$3=no > + ac_signbits= > + AC_COMPILE_IFELSE( > + [AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([$4])], [($1) -1 < > 0])], > + [ac_signbits=1; ac_suffix=; ac_unsigned=], *snip* > Index: lib/autoconf/functions.m4 > =================================================================== > RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v > retrieving revision 1.95 > diff -p -u -r1.95 functions.m4 > --- lib/autoconf/functions.m4 24 Jan 2006 00:20:15 -0000 1.95 > +++ lib/autoconf/functions.m4 1 Mar 2006 00:45:24 -0000 > @@ -1500,6 +1526,36 @@ fi > ]) > > > +# AC_FUNC_STRTOLD > +# --------------- > +AC_DEFUN([AC_FUNC_STRTOLD], > +[ > + AC_CACHE_CHECK([whether strtold conforms to C99], > + [ac_cv_func_strtold], > + [AC_COMPILE_IFELSE( > + [AC_LANG_PROGRAM( > + [[/* On HP-UX before 11.23, strtold returns a struct instead of > + long double. Reject implementations like that, by requiring > + compatibility with the C99 prototype. */ > + #include <stdlib.h> Doesn't Autoconf code still put the hash in the first column? > + static long double (*p) (char const *, char **) = strtold; > + static long double > + test (char const *nptr, char **endptr) > + { > + long double r; > + r = strtold (nptr, endptr); > + return r; > + }]], > + [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])], > + [ac_cv_func_strtold=yes], > + [ac_cv_func_strtold=no])]) > + if test $ac_cv_func_strtold = yes; then > + AC_DEFINE([HAVE_STRTOLD], 1, > + [Define to 1 if strtold exists and conforms to C99.]) > + fi > +]) > + > + > # AU::AM_FUNC_STRTOD > # ------------------ > AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD]) > Index: lib/autoconf/headers.m4 > =================================================================== > RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/headers.m4,v > retrieving revision 1.45 > diff -p -u -r1.45 headers.m4 > --- lib/autoconf/headers.m4 24 Jan 2006 00:20:15 -0000 1.45 > +++ lib/autoconf/headers.m4 1 Mar 2006 00:45:24 -0000 > @@ -65,8 +65,8 @@ > > > # AC_CHECK_HEADER(HEADER-FILE, > -# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], > -# [INCLUDES]) > +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], > +# [INCLUDES]) > # --------------------------------------------------------- > # We are slowly moving to checking headers with the compiler instead > # of the preproc, so that we actually learn about the usability of a Not sure if I like all those white space changes (several instances in several files) introducing TABs in comments, and making this patch much larger than necessary (and more difficult to review for lined-up underlines ;-) > @@ -207,6 +207,26 @@ done > ])# AC_CHECK_HEADERS > > > +# AC_CHECK_HEADERS_ONCE(HEADER-FILE...) > +# ------------------------------------- > +AC_DEFUN([AC_CHECK_HEADERS_ONCE], > +[ > + AH_CHECK_HEADERS([$1]) > + m4_foreach_w([AC_Header], [$1], > + [AC_DEFUN([_AC_Header_]m4_quote(translit(AC_Header, [./-], [___])), > + [m4_divert_text([INIT_PREPARE], > + [ac_header_list="$ac_header_list AC_Header"]) > + _AC_HEADERS_EXPANSION]) > + AC_REQUIRE([_AC_Header_]m4_quote(translit(AC_Header, [./-], [___])))]) Please s|translit|m4_&|, two instances. > +]) > +m4_define([_AC_HEADERS_EXPANSION], > +[ > + m4_divert_text([DEFAULTS], [ac_header_list=]) > + AC_CHECK_HEADERS([$ac_header_list]) > + m4_define([_AC_HEADERS_EXPANSION], []) > +]) > + > + > > > ## --------------------- ## > @@ -561,10 +594,39 @@ AC_DEFUN([AC_HEADER_STDBOOL], > enum { j = false, k = true, l = false * true, m = true * 256 }; > _Bool n[m]; > char o[sizeof n == m * sizeof n[0] ? 1 : -1]; > + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; > + #if defined __xlc__ || defined __GNUC__ See above (hash column). > + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 > + reported by James Lemley on 2005-10-05; see > + > http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html > + This test is not quite right, since xlc is allowed to > + reject this program, as the initializer for xlcbug is > + not one of the forms that C requires support for. > + However, doing the test right would require a run-time > + test, and that would make cross-compilation harder. > + Let us hope that IBM fixes the xlc bug, and also adds > + support for this kind of constant expression. In the > + meantime, this test will reject xlc, which is OK, since > + our stdbool.h substitute should suffice. We also test > + this with GCC, where it should work, to detect more > + quickly whether someone messes up the test in the > + future. */ > + char digs[] = "0123456789"; > + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); > + #endif See above (hash column). > + /* Catch a bug in an HP-UX C compiler. See > + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html > + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html > + */ > + _Bool q = true; > + _Bool *pq = &q; > ]], > [[ > - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !j + !k + !l > - + !m + !n + !o); > + *pq |= q; > + *pq |= ! q; > + /* Refer to every declared value, to avoid compiler optimizations. */ > + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l > + + !m + !n + !o + !p + !q + !pq); > ]])], > [ac_cv_header_stdbool_h=yes], > [ac_cv_header_stdbool_h=no])]) > Index: lib/autoconf/specific.m4 > =================================================================== > RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v > retrieving revision 1.363 > diff -p -u -r1.363 specific.m4 > --- lib/autoconf/specific.m4 24 Jan 2006 00:20:15 -0000 1.363 > +++ lib/autoconf/specific.m4 1 Mar 2006 00:45:24 -0000 > @@ -379,6 +379,41 @@ esac > matches *mingw32*])# AC_MINGW32 > > > +# AC_USE_SYSTEM_EXTENSIONS > +# ------------------------ > +# Enable extensions on systems that normally disable them, > +# typically due to standards-conformance issues. > +AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS], > +[ > + AC_BEFORE([$0], [AC_COMPILE_IFELSE]) > + AC_BEFORE([$0], [AC_RUN_IFELSE]) > + > + AC_REQUIRE([AC_GNU_SOURCE]) > + AC_REQUIRE([AC_AIX]) > + AC_REQUIRE([AC_MINIX]) It'd be nice to s|$|dnl| for all the AC_REQUIRE and AC_BEFORE. > + > + AH_VERBATIM([__EXTENSIONS__], > +[/* Enable extensions on Solaris. */ > +#ifndef __EXTENSIONS__ > +# undef __EXTENSIONS__ > +#endif > +#ifndef _POSIX_PTHREAD_SEMANTICS > +# undef _POSIX_PTHREAD_SEMANTICS > +#endif]) > + AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], > + [ac_cv_safe_to_define___extensions__], > + [AC_COMPILE_IFELSE( > + [AC_LANG_PROGRAM([ > + #define __EXTENSIONS__ 1 See above (hash column). > + AC_INCLUDES_DEFAULT])], > + [ac_cv_safe_to_define___extensions__=yes], > + [ac_cv_safe_to_define___extensions__=no])]) > + test $ac_cv_safe_to_define___extensions__ == yes && > + AC_DEFINE([__EXTENSIONS__]) > + AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) > +]) > + > + > > > ## -------------------------- ## _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib