]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Keep `AC_CHECK_TYPE' backward compatibility and provide a proper
authorAkim Demaille <akim@epita.fr>
Thu, 10 Feb 2000 10:24:10 +0000 (10:24 +0000)
committerAkim Demaille <akim@epita.fr>
Thu, 10 Feb 2000 10:24:10 +0000 (10:24 +0000)
`AC_CHECK_TYPE',
Based on ideas from Paul Eggert and Alexandre Oliva.

* acgeneral.m4 (AC_CHECK_TYPE_INTERNAL): Renamed as
(_AC_CHECK_TYPE_NEW): this.
(AC_CHECK_TYPES): Adjusted.
(AC_CHECK_TYPE): Renamed as
(_AC_CHECK_TYPE_OLD): This.  Adjusted to _AC_CHECK_TYPE_NEW.
No longer support extra includes, stick to 2.13's interface.
(_AC_CHECK_TYPE_BUILTIN_P): New macro.
(AC_CHECK_TYPE): New macro.
* autoheader.m4 (autoheader::AC_CHECK_TYPE): Renamed as...
(autoheader::_AC_CHECK_TYPE_OLD): this.
* tests/atspecific.m4 (TEST_MACRO): Skip /^_AC_/ macros.
* tests/semantics.m4: Test the choices of AC_CHECK_TYPE (wrt _NEW
or _OLD implemenation).
* doc/autoconf.texi (Generic Types): Reorganized.  Explain
everything about AC_CHECK_TYPE and Co.

ChangeLog
acgeneral.m4
autoheader.m4
lib/autoconf/general.m4
tests/semantics.m4

index 5805f146030c5799432d219b4f1ed9e23d7edc6c..e88b3b928a2e393278735be50117ad3c57c0a159 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2000-02-10  Akim Demaille  <akim@epita.fr>
+
+       Keep `AC_CHECK_TYPE' backward compatibility and provide a proper
+       `AC_CHECK_TYPE',
+       Based on ideas from Paul Eggert and Alexandre Oliva.
+
+       * acgeneral.m4 (AC_CHECK_TYPE_INTERNAL): Renamed as
+       (_AC_CHECK_TYPE_NEW): this.
+       (AC_CHECK_TYPES): Adjusted.
+       (AC_CHECK_TYPE): Renamed as
+       (_AC_CHECK_TYPE_OLD): This.  Adjusted to _AC_CHECK_TYPE_NEW.
+       No longer support extra includes, stick to 2.13's interface.
+       (_AC_CHECK_TYPE_BUILTIN_P): New macro.
+       (AC_CHECK_TYPE): New macro.
+       * autoheader.m4 (autoheader::AC_CHECK_TYPE): Renamed as...
+       (autoheader::_AC_CHECK_TYPE_OLD): this.
+       * tests/atspecific.m4 (TEST_MACRO): Skip /^_AC_/ macros.
+       * tests/semantics.m4: Test the choices of AC_CHECK_TYPE (wrt _NEW
+       or _OLD implemenation).
+       * doc/autoconf.texi (Generic Types): Reorganized.  Explain
+       everything about AC_CHECK_TYPE and Co.
+
 2000-02-10  Akim Demaille  <akim@epita.fr>
 
        * libm4.m4 (near m4_split): Remove the buggy additional
index bbe3f24227f9da01388ca540c06cc7e8c1db49e9..7e66223d9cb6135214e586efd1357551eb7583f8 100644 (file)
@@ -2795,15 +2795,33 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 ])
 
 
+
 ## -------------------- ##
 ## Checking for types.  ##
 ## -------------------- ##
 
+# Up to 2.13 included, Autoconf used to provide the macro
+#
+#    AC_CHECK_TYPE(TYPE, DEFAULT)
+#
+# Since, it provides another version which fits better with the other
+# AC_CHECK_ families:
+#
+#    AC_CHECK_TYPE(TYPE,
+#                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                 [INCLUDES])
+#
+# In order to provide backward compatibility, the new scheme is
+# implemented as _AC_CHECK_TYPE_NEW, the old scheme as _AC_CHECK_TYPE_OLD,
+# and AC_CHECK_TYPE branches to one or the other, depending upon its
+# arguments.
 
-# AC_CHECK_TYPE_INTERNAL(TYPE,
-#                       [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-#                       [INCLUDES])
-# ----------------------------------------------------------------
+
+
+# _AC_CHECK_TYPE_NEW(TYPE,
+#                   [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                   [INCLUDES])
+# ------------------------------------------------------------
 # Check whether the type TYPE is supported by the system, maybe via the
 # the provided includes.  This macro implements the former task of
 # AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
@@ -2864,9 +2882,7 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 # (not necessarily size_t etc.).  Equally, instead of defining an unused
 # variable, we just use a cast to avoid warnings from the compiler.
 # Suggested by Paul Eggert.
-#
-# FIXME: This is *the* macro which ought to be named AC_CHECK_TYPE.
-AC_DEFUN(AC_CHECK_TYPE_INTERNAL,
+AC_DEFUN([_AC_CHECK_TYPE_NEW],
 [AC_REQUIRE([AC_HEADER_STDC])dnl
 AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Type,
@@ -2880,35 +2896,66 @@ if (sizeof ($1))
 AC_SHELL_IFELSE([test AC_VAR_GET(ac_Type) = yes],
                 [$2], [$3])dnl
 AC_VAR_POPDEF([ac_Type])dnl
-])# AC_CHECK_TYPE_INTERNAL
+])# _AC_CHECK_TYPE_NEW
 
 
 # AC_CHECK_TYPES((TYPE, ...),
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                [INCLUDES])
 # --------------------------------------------------------
-# TYPEs is an m4 list.
-AC_DEFUN(AC_CHECK_TYPES,
+# TYPEs is an m4 list.  There are no ambiguities here, we mean the newer
+# AC_CHECK_TYPE.
+AC_DEFUN([AC_CHECK_TYPES],
 [m4_foreach([AC_Type], [$1],
-  [AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,
+  [AC_SPECIALIZE([_AC_CHECK_TYPE_NEW], AC_Type,
                  [AC_DEFINE_UNQUOTED(AC_TR_CPP(HAVE_[]AC_Type))
 $2],
                  [$3],
                  [$4])])])
 
 
-# AC_CHECK_TYPE(TYPE, DEFAULT, [INCLUDES])
-# ----------------------------------------
+# _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
+# ---------------------------------
 # FIXME: This is an extremely badly chosen name, since this
 # macro actually performs an AC_REPLACE_TYPE.  Some day we
-# have to clean this up.  The macro AC_TYPE_PTRDIFF_T shows the
-# need for a checking only macro.
-AC_DEFUN(AC_CHECK_TYPE,
-[AC_CHECK_TYPE_INTERNAL([$1],,
-                        [AC_DEFINE_UNQUOTED($1, $2)],
-                        [$3])dnl
-])# AC_CHECK_TYPE
+# have to clean this up.
+AC_DEFUN([_AC_CHECK_TYPE_OLD],
+[_AC_CHECK_TYPE_NEW([$1],,
+                    [AC_DEFINE_UNQUOTED([$1], [$2])])dnl
+])# _AC_CHECK_TYPE_OLD
+
 
+# _AC_CHECK_TYPE_BUILTIN_P(STRING)
+# --------------------------------
+# Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
+# starts with `_Bool', `bool', `char', `double', `float', `int',
+# `long', `short', `signed', or `unsigned' followed by characters
+# that are defining types.
+define([_AC_CHECK_TYPE_BUILTIN_P],
+[ifelse(regexp([$1], [^\(_Bool\|bool|\char\|double\|float\|int\|long\|short\|\(un\)?signed\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
+       0, 1, 0)dnl
+])# _AC_CHECK_TYPE_BUILTIN_P
+
+
+# AC_CHECK_TYPE(TYPE, DEFAULT)
+#  or
+# AC_CHECK_TYPE(TYPE,
+#              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#              [INCLUDES])
+# -------------------------------------------------------
+#
+# Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
+# 1. More than two arguments     => NEW
+# 2. $2 seems to be builtin type => OLD
+# 3. $2 seems to be a type       => NEW plus a warning
+# 4. default                     => NEW
+AC_DEFUN([AC_CHECK_TYPE],
+[ifelse($#, 3, [_AC_CHECK_TYPE_NEW($@)],
+        $#, 4, [_AC_CHECK_TYPE_NEW($@)],
+        _AC_CHECK_TYPE_BUILTIN_P([$2]), 1, [_AC_CHECK_TYPE_OLD($@)],
+        regexp([$2], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
+        [_AC_CHECK_TYPE_NEW($@)])[]dnl
+])# AC_CHECK_TYPE
 
 
 
index 29b4ad6c534cdeedb17d2795ad119bfa008e1758..5da30d8d4ca6a6af2c6fc00b3cdf50049eec6198 100644 (file)
@@ -215,9 +215,9 @@ AH_DEFUN([AC_CHECK_MEMBERS],
 ])
 
 
-# AC_CHECK_TYPE(TYPE, SUBTITUTE)
-# ------------------------------
-AH_DEFUN([AC_CHECK_TYPE],
+# _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
+# ---------------------------------
+AH_DEFUN([_AC_CHECK_TYPE_OLD],
 [AH_TEMPLATE([$1], [Define to `$2' if <sys/types.h> does not define.])])
 
 
index bbe3f24227f9da01388ca540c06cc7e8c1db49e9..7e66223d9cb6135214e586efd1357551eb7583f8 100644 (file)
@@ -2795,15 +2795,33 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 ])
 
 
+
 ## -------------------- ##
 ## Checking for types.  ##
 ## -------------------- ##
 
+# Up to 2.13 included, Autoconf used to provide the macro
+#
+#    AC_CHECK_TYPE(TYPE, DEFAULT)
+#
+# Since, it provides another version which fits better with the other
+# AC_CHECK_ families:
+#
+#    AC_CHECK_TYPE(TYPE,
+#                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                 [INCLUDES])
+#
+# In order to provide backward compatibility, the new scheme is
+# implemented as _AC_CHECK_TYPE_NEW, the old scheme as _AC_CHECK_TYPE_OLD,
+# and AC_CHECK_TYPE branches to one or the other, depending upon its
+# arguments.
 
-# AC_CHECK_TYPE_INTERNAL(TYPE,
-#                       [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
-#                       [INCLUDES])
-# ----------------------------------------------------------------
+
+
+# _AC_CHECK_TYPE_NEW(TYPE,
+#                   [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#                   [INCLUDES])
+# ------------------------------------------------------------
 # Check whether the type TYPE is supported by the system, maybe via the
 # the provided includes.  This macro implements the former task of
 # AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
@@ -2864,9 +2882,7 @@ AC_VAR_POPDEF([ac_Sizeof])dnl
 # (not necessarily size_t etc.).  Equally, instead of defining an unused
 # variable, we just use a cast to avoid warnings from the compiler.
 # Suggested by Paul Eggert.
-#
-# FIXME: This is *the* macro which ought to be named AC_CHECK_TYPE.
-AC_DEFUN(AC_CHECK_TYPE_INTERNAL,
+AC_DEFUN([_AC_CHECK_TYPE_NEW],
 [AC_REQUIRE([AC_HEADER_STDC])dnl
 AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
 AC_CACHE_CHECK([for $1], ac_Type,
@@ -2880,35 +2896,66 @@ if (sizeof ($1))
 AC_SHELL_IFELSE([test AC_VAR_GET(ac_Type) = yes],
                 [$2], [$3])dnl
 AC_VAR_POPDEF([ac_Type])dnl
-])# AC_CHECK_TYPE_INTERNAL
+])# _AC_CHECK_TYPE_NEW
 
 
 # AC_CHECK_TYPES((TYPE, ...),
 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
 #                [INCLUDES])
 # --------------------------------------------------------
-# TYPEs is an m4 list.
-AC_DEFUN(AC_CHECK_TYPES,
+# TYPEs is an m4 list.  There are no ambiguities here, we mean the newer
+# AC_CHECK_TYPE.
+AC_DEFUN([AC_CHECK_TYPES],
 [m4_foreach([AC_Type], [$1],
-  [AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,
+  [AC_SPECIALIZE([_AC_CHECK_TYPE_NEW], AC_Type,
                  [AC_DEFINE_UNQUOTED(AC_TR_CPP(HAVE_[]AC_Type))
 $2],
                  [$3],
                  [$4])])])
 
 
-# AC_CHECK_TYPE(TYPE, DEFAULT, [INCLUDES])
-# ----------------------------------------
+# _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
+# ---------------------------------
 # FIXME: This is an extremely badly chosen name, since this
 # macro actually performs an AC_REPLACE_TYPE.  Some day we
-# have to clean this up.  The macro AC_TYPE_PTRDIFF_T shows the
-# need for a checking only macro.
-AC_DEFUN(AC_CHECK_TYPE,
-[AC_CHECK_TYPE_INTERNAL([$1],,
-                        [AC_DEFINE_UNQUOTED($1, $2)],
-                        [$3])dnl
-])# AC_CHECK_TYPE
+# have to clean this up.
+AC_DEFUN([_AC_CHECK_TYPE_OLD],
+[_AC_CHECK_TYPE_NEW([$1],,
+                    [AC_DEFINE_UNQUOTED([$1], [$2])])dnl
+])# _AC_CHECK_TYPE_OLD
+
 
+# _AC_CHECK_TYPE_BUILTIN_P(STRING)
+# --------------------------------
+# Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
+# starts with `_Bool', `bool', `char', `double', `float', `int',
+# `long', `short', `signed', or `unsigned' followed by characters
+# that are defining types.
+define([_AC_CHECK_TYPE_BUILTIN_P],
+[ifelse(regexp([$1], [^\(_Bool\|bool|\char\|double\|float\|int\|long\|short\|\(un\)?signed\)\([_a-zA-Z0-9() *]\|\[\|\]\)*$]),
+       0, 1, 0)dnl
+])# _AC_CHECK_TYPE_BUILTIN_P
+
+
+# AC_CHECK_TYPE(TYPE, DEFAULT)
+#  or
+# AC_CHECK_TYPE(TYPE,
+#              [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
+#              [INCLUDES])
+# -------------------------------------------------------
+#
+# Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
+# 1. More than two arguments     => NEW
+# 2. $2 seems to be builtin type => OLD
+# 3. $2 seems to be a type       => NEW plus a warning
+# 4. default                     => NEW
+AC_DEFUN([AC_CHECK_TYPE],
+[ifelse($#, 3, [_AC_CHECK_TYPE_NEW($@)],
+        $#, 4, [_AC_CHECK_TYPE_NEW($@)],
+        _AC_CHECK_TYPE_BUILTIN_P([$2]), 1, [_AC_CHECK_TYPE_OLD($@)],
+        regexp([$2], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$]), 0, [m4_warn([$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
+        [_AC_CHECK_TYPE_NEW($@)])[]dnl
+])# AC_CHECK_TYPE
 
 
 
index bbe1d539fe3161c81766ba21078e3a66f5c8cb2f..47c12467cf3d512fa480634c20ae7bb4c3d7d49f 100644 (file)
@@ -7,6 +7,7 @@ Semantics.
 EOF
 
 
+
 dnl AC_CHECK_DECLS
 dnl --------------
 dnl Check that it performs the correct actions:
@@ -66,7 +67,7 @@ dnl Check that it performs the correct actions.
 dnl Must define HAVE_STRUCT_YES, HAVE_INT, but not HAVE_STRUCT_NO.
 dnl `int' and `struct yes' are both checked to test both the compiler
 dnl builtin types, and defined types.
-AT_TEST_MACRO(AC_CHECK_TYPES,
+AT_TEST_MACRO(AC_CHECK_SIZEOF,
 [AC_CHECK_SIZEOF(char)
 AC_CHECK_SIZEOF(charchar,,
 [#include <stdio.h>
@@ -98,6 +99,44 @@ AT_TEST_MACRO(AC_CHECK_TYPES,
 ])])
 
 
+dnl AC_CHECK_TYPES
+dnl --------------
+dnl Check that we properly dispatch properly to the old implementation
+dnl or to the new one.
+AT_SETUP([AC_CHECK_TYPES])
+
+AT_DATA(configure.in,
+[[AC_INIT
+m4_define([_AC_CHECK_TYPE_NEW], [NEW])
+m4_define([_AC_CHECK_TYPE_OLD], [OLD])
+#(cut-from-here
+AC_CHECK_TYPE(ptrdiff_t)
+AC_CHECK_TYPE(ptrdiff_t, int)
+AC_CHECK_TYPE(quad, long long)
+AC_CHECK_TYPE(table_42, [int[42]])
+dnl Nice machine!
+AC_CHECK_TYPE(uint8_t, uint65536_t)
+AC_CHECK_TYPE(a,b,c,d)
+#to-here)
+AC_OUTPUT
+]])
+
+AT_CHECK([../autoconf -m .. -l $at_srcdir], 0,,
+[configure.in:10: warning: AC_CHECK_TYPE: assuming `uint65536_t' is not a type
+])
+AT_CHECK([[sed -e '/^#(cut-from-here/, /^#to-here)/!d' -e '/^#/d' configure]],
+         0,
+         [NEW
+OLD
+OLD
+OLD
+NEW
+NEW
+])
+
+AT_CLEANUP(autoconf.err)
+
+
 
 dnl AC_CHECK_FILES
 dnl --------------