]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
1999-11-01 Akim Demaille <akim@epita.fr>
authorAkim Demaille <akim@epita.fr>
Fri, 28 Jan 2000 10:41:47 +0000 (10:41 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 28 Jan 2000 10:41:47 +0000 (10:41 +0000)
Fix a bit of the brokenness of AC_CHECK_TYPE.

* acgeneral.m4 (AC_CHECK_TYPE_INTERNAL): New macro, inspired from
  the former AC_CHECK_TYPE.  This macro is exactly the one that
  ought to be named AC_CHECK_TYPE: it just checks, and executes user
  actions.  In the future, this macro ought to be renamed
  AC_CHECK_TYPE.
There is a big difference with the former AC_CHECK_TYPE: instead
  of grepping in the headers, it tries to compile a variable
  declaration.  This is both safer, slower, and better, since now we
  can check for compiler types (e.g., unsigned long long).
(AC_CHECK_TYPES): The looping and AC_DEFINEing version of the
  previous macro.  Uses m4 loops.
(AC_CHECK_TYPE): Reimplemented on top of AC_CHECK_TYPE_INTERNAL.
   * autoheader.m4 (AH_CHECK_TYPE, AH_CHECK_TYPES): New macros,
  hooked.
* autoconf.texi (@ovar): New macro, for optional variables.
(Generic Typedefs): Document AC_CHECK_TYPES.
* autoheader.texi: (AH_CHECK_TYPE, AH_CHECK_TYPES): New macros.
(Epilogue): Hooks them.

ChangeLog
TODO
acgeneral.m4
autoconf.texi
autoheader.m4
doc/autoconf.texi
lib/autoconf/general.m4

index 4988eece5d10b374650deba7a8ab57c510b73907..2807af917d8ea230e77819f011a2fbe018949a61 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+1999-11-01  Akim Demaille  <akim@epita.fr>
+
+       Fix a bit of the brokenness of AC_CHECK_TYPE.
+
+       * acgeneral.m4 (AC_CHECK_TYPE_INTERNAL): New macro, inspired from
+       the former AC_CHECK_TYPE.  This macro is exactly the one that
+       ought to be named AC_CHECK_TYPE: it just checks, and executes user
+       actions.  In the future, this macro ought to be renamed
+       AC_CHECK_TYPE.
+       There is a big difference with the former AC_CHECK_TYPE: instead
+       of grepping in the headers, it tries to compile a variable
+       declaration.  This is both safer, slower, and better, since now we
+       can check for compiler types (e.g., unsigned long long).
+       (AC_CHECK_TYPES): The looping and AC_DEFINEing version of the
+       previous macro.  Uses m4 loops.
+       (AC_CHECK_TYPE): Reimplemented on top of AC_CHECK_TYPE_INTERNAL.
+       * autoheader.m4 (AH_CHECK_TYPE, AH_CHECK_TYPES): New macros,
+       hooked.
+       * autoconf.texi (@ovar): New macro, for optional variables.
+       (Generic Typedefs): Document AC_CHECK_TYPES.
+       * autoheader.texi: (AH_CHECK_TYPE, AH_CHECK_TYPES): New macros.
+       (Epilogue): Hooks them.
+
 1999-11-01  Akim Demaille  <akim@epita.fr>
 
        Update autoupdate.
diff --git a/TODO b/TODO
index 026e74f90fbdd8d7cde88db07202e7472985630d..b4776b11ee1ce2f4addd9c3add79bbb06857c0ba 100644 (file)
--- a/TODO
+++ b/TODO
@@ -13,6 +13,12 @@ These are things mandatory to fulfill before releasing 2.15.  There
 are also suggestions we should either satisfy right now (they're
 easy), or remove (obsoleted since then).
 
+** automake
+The section for old macros is not completely up to date.  For
+instance, there is still AM_PROG_LIBTOOL.  Anyawy, since autoupdate
+takes care of them, it is no longer the role of Automake to handle
+this.  Most should be removed.
+
 ** tests/
 Write the sketch of a new series of tests, written in Autotest,
 cf. recode 3.5 by François Pinard.  It has to be shell scripts so that
index a5cb8931f831125f992cb46edda887d51d8ff876..1fffefed6d7da4447b218ce5a309768ba5db76c2 100644 (file)
@@ -389,6 +389,7 @@ undivert(AC_DIVERSION_NORMAL_1)dnl
 ])dnl
 ])
 
+
 dnl AC_DEFUN(NAME, [REPLACED-FUNCTION, ARGUMENT, ]EXPANSION)
 dnl --------------------------------------------------------
 dnl Define a macro which automatically provides itself.  Add machinery
@@ -2094,9 +2095,9 @@ define(AC_HASBEEN,
 
 dnl ### Generic structure checks
 
-dnl AC_CHECK_MEMBER(AGGREGATE.MEMBER
-dnl                 [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl                 [, INCLUDES ]]])
+dnl AC_CHECK_MEMBER(AGGREGATE.MEMBER,
+dnl                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl                 [INCLUDES])
 dnl ---------------------------------------------------------
 dnl AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
 dnl variables are not a valid argument.
@@ -2128,10 +2129,13 @@ AC_VAR_POPDEF([ac_Member])dnl
 ])dnl AC_CHECK_MEMBER
 
 
-dnl AC_CHECK_MEMBER(AGGREGATE.MEMBER...
-dnl                 [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl                 [, INCLUDES ]]])
-dnl ---------------------------------------------------------
+dnl AC_CHECK_MEMBER((AGGREGATE.MEMBER, ...),
+dnl                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
+dnl                 [INCLUDES])
+dnl --------------------------------------------------------
+dnl The first argument is an m4 list.  First because we want to
+dnl promote m4 list, and second because anyway there can be spaces
+dnl in some types (struct etc.).
 AC_DEFUN(AC_CHECK_MEMBERS,
 [m4_foreach([AC_Member], [$1],
   [AC_SPECIALIZE([AC_CHECK_MEMBER], AC_Member,
@@ -2155,10 +2159,10 @@ $1="$ac_cv_c_struct_member_$1"])
 dnl ### Checking for programs
 
 
-dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR
-dnl               [, VALUE-IF-FOUND [, VALUE-IF-NOT-FOUND]
-dnl               [, PATH [, REJECT]]])
-dnl ------------------------------------------------------
+dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
+dnl               [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
+dnl               [PATH], [REJECT])
+dnl -----------------------------------------------------
 AC_DEFUN(AC_CHECK_PROG,
 [# Extract the first word of "$2", so it can be a program name with args.
 set dummy $2; ac_word=[$]2
@@ -2721,6 +2725,7 @@ AC_SHELL_IFELSE(test AC_VAR_GET(ac_Header) = yes,
 AC_VAR_POPDEF([ac_Header])dnl
 ])dnl AC_CHECK_HEADER
 
+
 dnl AC_CHECK_HEADERS(HEADER-FILE...
 dnl                  [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl -------------------------------------------------------------
@@ -2783,7 +2788,7 @@ dnl -------------------------------------------------------------
 dnl Check if SYMBOL (a variable or a function) is declared.
 AC_DEFUN([AC_CHECK_DECL],
 [AC_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
-AC_CACHE_CHECK([whether `$1' is declared], ac_Symbol,
+AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
 [AC_TRY_COMPILE(m4_default([$4], [#include <stdio.h>
 #ifdef HAVE_STRING_H
 # if !STDC_HEADERS && HAVE_MEMORY_H
@@ -2918,31 +2923,61 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 dnl ### Checking for typedefs
 
 
-dnl AC_CHECK_TYPE(TYPE, DEFAULT[, INCLUDES])
-dnl ----------------------------------------
-dnl FIXME: This is an extremely badly chosen name, since this
-dnl macro actually performs an AC_REPLACE_TYPE.  Some day we
-dnl have to clean this up.
-AC_DEFUN(AC_CHECK_TYPE,
+dnl AC_CHECK_TYPE_INTERNAL(TYPE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl                        [INCLUDES])
+dnl ----------------------------------------------------------------------
+dnl Check whether the type TYPE is supported by the system, maybe via the
+dnl the provided includes.  This macro implements the former task of
+dnl AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
+dnl grepping in the headers, what led to many problems, BTW, until
+dnl the egrep expression was correct and did not given false positives.
+dnl Now, we try to compile a variable declaration.  It is probably slower,
+dnl but it is *much* safer, and in addition, allows to check for types
+dnl defined by the compiler (e.g., unsigned long long), not only for
+dnl typedefs.
+dnl FIXME: This is *the* macro which ought to be named AC_CHECK_TYPE.
+AC_DEFUN(AC_CHECK_TYPE_INTERNAL,
 [AC_REQUIRE([AC_HEADER_STDC])dnl
 AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Type,
-[AC_EGREP_CPP(
-changequote(<<,>>)dnl
-<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]),
-m4_default([$3], [#include <stdio.h>
+[AC_TRY_COMPILE(m4_default([$4
+], [#include <stdio.h>
 #include <sys/types.h>
 #if STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
 #endif
-]), AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
-AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes,,
-                [AC_DEFINE_UNQUOTED($1, $2,
-                                    [Define to `$2' if <sys/types.h>
-                                     does not define.])])dnl
+]),
+ [$1 foo;],
+ AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
+AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes,
+                [$2], [$3])dnl
 AC_VAR_POPDEF([ac_Type])dnl
+])dnl AC_CHECK_TYPE_INTERNAL
+
+
+dnl AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
+dnl ---------------------------------------------------------------------------
+dnl TYPES is an m4 list.
+AC_DEFUN(AC_CHECK_TYPES,
+[m4_foreach([AC_Type], [$1],
+  [AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP(HAVE_[]AC_Type))
+$2]
+                 [$3],
+                 [$4])])])
+
+
+dnl AC_CHECK_TYPE(TYPE, DEFAULT, [INCLUDES])
+dnl ----------------------------------------
+dnl FIXME: This is an extremely badly chosen name, since this
+dnl macro actually performs an AC_REPLACE_TYPE.  Some day we
+dnl have to clean this up.  The macro AC_TYPE_PTRDIFF_T shows the
+dnl need for a checking only macro.
+AC_DEFUN(AC_CHECK_TYPE,
+[AC_CHECK_TYPE_INTERNAL([$1],,
+                        [AC_DEFINE_UNQUOTED($1, $2)],
+                        [$3])dnl
 ])dnl AC_CHECK_TYPE
 
 
index b51eb9302e9293d5991b7f3e482a5b5c0b3ac583..0363d2bf0bd4b699ee6437713834697facf0c143 100644 (file)
 @finalout
 @end iftex
 
+@c A simple macro for optional variables.
+@macro ovar{varname}
+@r{[}@var{\varname\}@r{]}
+@end macro
+
 @dircategory GNU admin
 @direntry
 * Autoconf: (autoconf).         Create source code configuration scripts
@@ -2810,23 +2815,52 @@ If @code{uid_t} is not defined, define @code{uid_t} to be @code{int} and
 @node Generic Typedefs,  , Particular Typedefs, Typedefs
 @subsection Generic Typedef Checks
 
-This macro is used to check for typedefs not covered by the particular
-test macros.  This macro does not fit well with the rest of Autoconf,
-and its design will probably change in the future.
+These macros are used to check for typedefs not covered by the
+particular test macros.
+
+@defmac AC_CHECK_TYPES ((@var{type}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
+@maindex CHECK_TYPES
+For each given @var{type} that is defined by the @var{includes} (by
+default, @file{sys/types.h}, @file{stdlib.h}, and @file{stddef.h}),
+define @code{HAVE_@var{type}} (in all capitals).  If
+@var{action-if-found} is given, it is additional shell code to execute
+when one of the header files is found.  You can give it a value of
+@samp{break} to break out of the loop on the first match.  If
+@var{action-if-not-found} is given, it is executed when one of the
+header files is not found.
+
+This macro uses m4 lists:
+@example
+AC_CHECK_TYPES((ptrdiff_t))
+AC_CHECK_TYPES((unsigned long long, uintmax_t))
+@end example
+
+@end defmac
 
-One of its main flaws is that missing types are not typedef'd, they are
-defined, which can lead to incompatible code in the case of pointer types.
 
-@defmac AC_CHECK_TYPE (@var{type}, @var{default} @r{[}, @var{includes}@r{]})
+The following macro does not fit well with the rest of Autoconf, and its
+design will probably change in the future.  One of its main flaws is
+that missing types are not typedef'd, they are defined, which can lead
+to incompatible code in the case of pointer types.
+
+@defmac AC_CHECK_TYPE (@var{type}, @var{default}, @ovar{includes})
 @maindex CHECK_TYPE
 If the type @var{type} is not defined in @file{sys/types.h}, or
-@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the
-C (or C++) builtin type @var{default}; e.g., @samp{short} or
-@samp{unsigned}.  The default header files to search can be replaced
-by supplying the optional argument @var{includes}.
+@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the C
+(or C++) builtin type @var{default}; e.g., @samp{short} or
+@samp{unsigned}.  The default header files to search can be replaced by
+supplying the optional argument @var{includes}.
+
+This macro has a broken design.  First, although it is a member of the
+@code{CHECK} clan, singular subfamily, it does more than just checking.
+Second, the replacement it performs is done via @samp{#define @var{type}
+@var{default}}, although a @samp{typedef} is expected.  Therefore, in
+the future, this macro shall be removed or replaced.  User are adviced
+to use @code{AC_CHECK_TYPES} preferably.
 @end defmac
 
 
+
 @node C Compiler Characteristics, Fortran 77 Compiler Characteristics, Typedefs, Existing Tests
 @section C Compiler Characteristics
 
@@ -2937,7 +2971,7 @@ size_t my_strlen PARAMS ((const char *));
 
 @c FIXME: What the heck is this macro doing here?  Move it out of
 @c the way, in its proper section!!!
-@defmac AC_CHECK_SIZEOF (@var{type} @r{[}, @var{cross-size}@r{[}, @var{includes}@r{]]})
+@defmac AC_CHECK_SIZEOF (@var{type}, @ovar{cross-size}, @ovar{includes})
 @maindex CHECK_SIZEOF
 Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or
 C++) builtin type @var{type}, e.g. @samp{int} or @samp{char *}.  If
index e81b645aab2180a53f4138efc18707e4ef393e36..b611c10e34f3b40367825e92e985a53c381aa000 100644 (file)
@@ -132,6 +132,23 @@ define([AH_CHECK_MEMBERS],
    $3])
 ])
 
+dnl AH_CHECK_TYPES((TYPES, ...))
+dnl ----------------------------
+define([AH_CHECK_TYPES],
+[m4_foreach([AC_Type], [$1],
+  [AH_TEMPLATE(AC_TR_CPP(HAVE_[]AC_Type),
+               [Define if the system has the type `]AC_Type['.])
+   # Success
+   $2
+   # Failure
+   $3])
+])
+
+
+dnl AC_CHECK_TYPE(TYPE, SUBTITUTE)
+dnl ------------------------------
+define([AH_CHECK_TYPE],
+[AH_TEMPLATE([$1], [Define to `$2' if <sys/types.h> does not define.])])
 
 define([AH_FUNC_ALLOCA],
 [AH_VERBATIM([STACK_DIRECTION],
@@ -161,7 +178,8 @@ define([AH_AIX],
    We just want to avoid a redefinition error message.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
-#endif])])
+#endif[]dnl
+])])
 
 
 define([AH_F77_WRAPPERS],
@@ -239,6 +257,8 @@ AH_HOOK([AC_CHECK_FUNCS], [AH_CHECK_FUNCS])
 AH_HOOK([AC_CHECK_HEADERS], [AH_CHECK_HEADERS])
 AH_HOOK([AC_CHECK_HEADERS_DIRENT], [AH_CHECK_HEADERS])
 AH_HOOK([AC_CHECK_MEMBERS], [AH_CHECK_MEMBERS])
+AH_HOOK([AC_CHECK_TYPE], [AH_CHECK_TYPE])
+AH_HOOK([AC_CHECK_TYPES], [AH_CHECK_TYPES])
 AH_HOOK([AC_CHECK_LIB], [AH_CHECK_LIB])
 AH_HOOK([AC_PROG_LEX], [AH_PROG_LEX])
 AH_HOOK([AC_FUNC_ALLOCA], [AH_FUNC_ALLOCA])
index b51eb9302e9293d5991b7f3e482a5b5c0b3ac583..0363d2bf0bd4b699ee6437713834697facf0c143 100644 (file)
 @finalout
 @end iftex
 
+@c A simple macro for optional variables.
+@macro ovar{varname}
+@r{[}@var{\varname\}@r{]}
+@end macro
+
 @dircategory GNU admin
 @direntry
 * Autoconf: (autoconf).         Create source code configuration scripts
@@ -2810,23 +2815,52 @@ If @code{uid_t} is not defined, define @code{uid_t} to be @code{int} and
 @node Generic Typedefs,  , Particular Typedefs, Typedefs
 @subsection Generic Typedef Checks
 
-This macro is used to check for typedefs not covered by the particular
-test macros.  This macro does not fit well with the rest of Autoconf,
-and its design will probably change in the future.
+These macros are used to check for typedefs not covered by the
+particular test macros.
+
+@defmac AC_CHECK_TYPES ((@var{type}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes})
+@maindex CHECK_TYPES
+For each given @var{type} that is defined by the @var{includes} (by
+default, @file{sys/types.h}, @file{stdlib.h}, and @file{stddef.h}),
+define @code{HAVE_@var{type}} (in all capitals).  If
+@var{action-if-found} is given, it is additional shell code to execute
+when one of the header files is found.  You can give it a value of
+@samp{break} to break out of the loop on the first match.  If
+@var{action-if-not-found} is given, it is executed when one of the
+header files is not found.
+
+This macro uses m4 lists:
+@example
+AC_CHECK_TYPES((ptrdiff_t))
+AC_CHECK_TYPES((unsigned long long, uintmax_t))
+@end example
+
+@end defmac
 
-One of its main flaws is that missing types are not typedef'd, they are
-defined, which can lead to incompatible code in the case of pointer types.
 
-@defmac AC_CHECK_TYPE (@var{type}, @var{default} @r{[}, @var{includes}@r{]})
+The following macro does not fit well with the rest of Autoconf, and its
+design will probably change in the future.  One of its main flaws is
+that missing types are not typedef'd, they are defined, which can lead
+to incompatible code in the case of pointer types.
+
+@defmac AC_CHECK_TYPE (@var{type}, @var{default}, @ovar{includes})
 @maindex CHECK_TYPE
 If the type @var{type} is not defined in @file{sys/types.h}, or
-@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the
-C (or C++) builtin type @var{default}; e.g., @samp{short} or
-@samp{unsigned}.  The default header files to search can be replaced
-by supplying the optional argument @var{includes}.
+@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the C
+(or C++) builtin type @var{default}; e.g., @samp{short} or
+@samp{unsigned}.  The default header files to search can be replaced by
+supplying the optional argument @var{includes}.
+
+This macro has a broken design.  First, although it is a member of the
+@code{CHECK} clan, singular subfamily, it does more than just checking.
+Second, the replacement it performs is done via @samp{#define @var{type}
+@var{default}}, although a @samp{typedef} is expected.  Therefore, in
+the future, this macro shall be removed or replaced.  User are adviced
+to use @code{AC_CHECK_TYPES} preferably.
 @end defmac
 
 
+
 @node C Compiler Characteristics, Fortran 77 Compiler Characteristics, Typedefs, Existing Tests
 @section C Compiler Characteristics
 
@@ -2937,7 +2971,7 @@ size_t my_strlen PARAMS ((const char *));
 
 @c FIXME: What the heck is this macro doing here?  Move it out of
 @c the way, in its proper section!!!
-@defmac AC_CHECK_SIZEOF (@var{type} @r{[}, @var{cross-size}@r{[}, @var{includes}@r{]]})
+@defmac AC_CHECK_SIZEOF (@var{type}, @ovar{cross-size}, @ovar{includes})
 @maindex CHECK_SIZEOF
 Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or
 C++) builtin type @var{type}, e.g. @samp{int} or @samp{char *}.  If
index a5cb8931f831125f992cb46edda887d51d8ff876..1fffefed6d7da4447b218ce5a309768ba5db76c2 100644 (file)
@@ -389,6 +389,7 @@ undivert(AC_DIVERSION_NORMAL_1)dnl
 ])dnl
 ])
 
+
 dnl AC_DEFUN(NAME, [REPLACED-FUNCTION, ARGUMENT, ]EXPANSION)
 dnl --------------------------------------------------------
 dnl Define a macro which automatically provides itself.  Add machinery
@@ -2094,9 +2095,9 @@ define(AC_HASBEEN,
 
 dnl ### Generic structure checks
 
-dnl AC_CHECK_MEMBER(AGGREGATE.MEMBER
-dnl                 [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl                 [, INCLUDES ]]])
+dnl AC_CHECK_MEMBER(AGGREGATE.MEMBER,
+dnl                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl                 [INCLUDES])
 dnl ---------------------------------------------------------
 dnl AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
 dnl variables are not a valid argument.
@@ -2128,10 +2129,13 @@ AC_VAR_POPDEF([ac_Member])dnl
 ])dnl AC_CHECK_MEMBER
 
 
-dnl AC_CHECK_MEMBER(AGGREGATE.MEMBER...
-dnl                 [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
-dnl                 [, INCLUDES ]]])
-dnl ---------------------------------------------------------
+dnl AC_CHECK_MEMBER((AGGREGATE.MEMBER, ...),
+dnl                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
+dnl                 [INCLUDES])
+dnl --------------------------------------------------------
+dnl The first argument is an m4 list.  First because we want to
+dnl promote m4 list, and second because anyway there can be spaces
+dnl in some types (struct etc.).
 AC_DEFUN(AC_CHECK_MEMBERS,
 [m4_foreach([AC_Member], [$1],
   [AC_SPECIALIZE([AC_CHECK_MEMBER], AC_Member,
@@ -2155,10 +2159,10 @@ $1="$ac_cv_c_struct_member_$1"])
 dnl ### Checking for programs
 
 
-dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR
-dnl               [, VALUE-IF-FOUND [, VALUE-IF-NOT-FOUND]
-dnl               [, PATH [, REJECT]]])
-dnl ------------------------------------------------------
+dnl AC_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
+dnl               [VALUE-IF-FOUND], [VALUE-IF-NOT-FOUND],
+dnl               [PATH], [REJECT])
+dnl -----------------------------------------------------
 AC_DEFUN(AC_CHECK_PROG,
 [# Extract the first word of "$2", so it can be a program name with args.
 set dummy $2; ac_word=[$]2
@@ -2721,6 +2725,7 @@ AC_SHELL_IFELSE(test AC_VAR_GET(ac_Header) = yes,
 AC_VAR_POPDEF([ac_Header])dnl
 ])dnl AC_CHECK_HEADER
 
+
 dnl AC_CHECK_HEADERS(HEADER-FILE...
 dnl                  [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl -------------------------------------------------------------
@@ -2783,7 +2788,7 @@ dnl -------------------------------------------------------------
 dnl Check if SYMBOL (a variable or a function) is declared.
 AC_DEFUN([AC_CHECK_DECL],
 [AC_VAR_PUSHDEF([ac_Symbol], [ac_cv_have_decl_$1])dnl
-AC_CACHE_CHECK([whether `$1' is declared], ac_Symbol,
+AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
 [AC_TRY_COMPILE(m4_default([$4], [#include <stdio.h>
 #ifdef HAVE_STRING_H
 # if !STDC_HEADERS && HAVE_MEMORY_H
@@ -2918,31 +2923,61 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 dnl ### Checking for typedefs
 
 
-dnl AC_CHECK_TYPE(TYPE, DEFAULT[, INCLUDES])
-dnl ----------------------------------------
-dnl FIXME: This is an extremely badly chosen name, since this
-dnl macro actually performs an AC_REPLACE_TYPE.  Some day we
-dnl have to clean this up.
-AC_DEFUN(AC_CHECK_TYPE,
+dnl AC_CHECK_TYPE_INTERNAL(TYPE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+dnl                        [INCLUDES])
+dnl ----------------------------------------------------------------------
+dnl Check whether the type TYPE is supported by the system, maybe via the
+dnl the provided includes.  This macro implements the former task of
+dnl AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
+dnl grepping in the headers, what led to many problems, BTW, until
+dnl the egrep expression was correct and did not given false positives.
+dnl Now, we try to compile a variable declaration.  It is probably slower,
+dnl but it is *much* safer, and in addition, allows to check for types
+dnl defined by the compiler (e.g., unsigned long long), not only for
+dnl typedefs.
+dnl FIXME: This is *the* macro which ought to be named AC_CHECK_TYPE.
+AC_DEFUN(AC_CHECK_TYPE_INTERNAL,
 [AC_REQUIRE([AC_HEADER_STDC])dnl
 AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Type,
-[AC_EGREP_CPP(
-changequote(<<,>>)dnl
-<<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]),
-m4_default([$3], [#include <stdio.h>
+[AC_TRY_COMPILE(m4_default([$4
+], [#include <stdio.h>
 #include <sys/types.h>
 #if STDC_HEADERS
 # include <stdlib.h>
 # include <stddef.h>
 #endif
-]), AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
-AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes,,
-                [AC_DEFINE_UNQUOTED($1, $2,
-                                    [Define to `$2' if <sys/types.h>
-                                     does not define.])])dnl
+]),
+ [$1 foo;],
+ AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
+AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes,
+                [$2], [$3])dnl
 AC_VAR_POPDEF([ac_Type])dnl
+])dnl AC_CHECK_TYPE_INTERNAL
+
+
+dnl AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES])
+dnl ---------------------------------------------------------------------------
+dnl TYPES is an m4 list.
+AC_DEFUN(AC_CHECK_TYPES,
+[m4_foreach([AC_Type], [$1],
+  [AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP(HAVE_[]AC_Type))
+$2]
+                 [$3],
+                 [$4])])])
+
+
+dnl AC_CHECK_TYPE(TYPE, DEFAULT, [INCLUDES])
+dnl ----------------------------------------
+dnl FIXME: This is an extremely badly chosen name, since this
+dnl macro actually performs an AC_REPLACE_TYPE.  Some day we
+dnl have to clean this up.  The macro AC_TYPE_PTRDIFF_T shows the
+dnl need for a checking only macro.
+AC_DEFUN(AC_CHECK_TYPE,
+[AC_CHECK_TYPE_INTERNAL([$1],,
+                        [AC_DEFINE_UNQUOTED($1, $2)],
+                        [$3])dnl
 ])dnl AC_CHECK_TYPE