]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
1999-09-27 Akim Demaille <akim@epita.fr>
authorAkim Demaille <akim@epita.fr>
Mon, 27 Sep 1999 12:04:40 +0000 (12:04 +0000)
committerAkim Demaille <akim@epita.fr>
Mon, 27 Sep 1999 12:04:40 +0000 (12:04 +0000)
* acgeneral.m4 (AC_CHECK_DECL): Renamed as...
(AC_NEED_DECL): This.
(AC_CHECK_DECLS): Renamed as...
(AC_NEED_DECLS): This.
(AC_NEED_DECL): Include <stdio.h>, <memory.h>, <string.h>,
  <strings.h>, <stdlib.h>, <stddef.h>, and <unistd.h>.

* autoconf.texi (Generic Declarations): Updated.

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

index f297f8d3808d11d3db037f601cd039124ba907fe..9038ebd88dde3800bc32547f460cf50b59c78e99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+1999-09-27  Akim Demaille  <akim@epita.fr>
+
+       * acgeneral.m4 (AC_CHECK_DECL): Renamed as...
+       (AC_NEED_DECL): This.
+       (AC_CHECK_DECLS): Renamed as...
+       (AC_NEED_DECLS): This.
+       (AC_NEED_DECL): Include <stdio.h>, <memory.h>, <string.h>,
+       <strings.h>, <stdlib.h>, <stddef.h>, and <unistd.h>.
+
+       * autoconf.texi (Generic Declarations): Updated.
+
 1999-09-26  Akim Demaille  <akim@epita.fr>
 
        * acgeneral.m4 (AC_WRAP): Rewritten.
index 0a01b997a109497108ab9a55444d03020ae7f8e8..79866c7d97db5587d308b81bf495b200dad6d680 100644 (file)
@@ -2491,35 +2491,68 @@ dnl ])
 dnl ### Checking for declared symbols
 
 
-dnl AC_CHECK_DECL(SYMBOL, [, INCLUDES,
-dnl              [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl --------------------------------------------------------
+dnl AC_NEED_DECL(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl              [, INCLUDES,]]])
+dnl ------------------------------------------------------------
 dnl Check if SYMBOL (a variable or a function) is declared.
-AC_DEFUN([AC_CHECK_DECL],
-[AC_VAR_PUSHDEF([ac_var], [ac_cv_decl_$1])dnl
-AC_CACHE_CHECK([whether $1 is declared], ac_var,
-[AC_TRY_COMPILE($2,
+dnl This macro is not a _CHECK_, because it is better not to declare
+dnl a symbol if you don't really need it.
+AC_DEFUN([AC_NEED_DECL],
+[AC_VAR_PUSHDEF([ac_Symbol], [ac_cv_decl_$1])dnl
+AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
+[AC_TRY_COMPILE([#include <stdio.h>
+#ifdef HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#else
+# ifdef HAVE_STRINGS_H
+#  include <strings.h>
+# endif
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+$4],
 [#ifndef $1
 char *p = (char *) $1;
 #endif
 ],
-AC_VAR_SET(ac_var, yes), AC_VAR_SET(ac_var, no))])
-AC_SHELL_IFELSE(test AC_VAR_GET(ac_var) = yes,
-               [$3], [$4])dnl
-AC_VAR_POPDEF([ac_var])dnl
-])dnl AC_CHECK_DECL
-
-dnl AC_CHECK_DECLS(SYMBOL... , [, INCLUDES,
-dnl                [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-AC_DEFUN(AC_CHECK_DECLS,
-[for ac_sym in $1
-do
-AC_CHECK_DECL($ac_sym,
-              [$2],
-              [AC_DEFINE_UNQUOTED(AC_TR_CPP(${ac_sym}_DECLARED)) $3],
-              [$4])dnl
-done
-])
+AC_VAR_SET(ac_Symbol, yes), AC_VAR_SET(ac_Symbol, no))])
+AC_SHELL_IFELSE(test AC_VAR_GET(ac_Symbol) = yes,
+               [$2], [$3])dnl
+AC_VAR_POPDEF([ac_Symbol])dnl
+])dnl AC_NEED_DECL
+
+dnl AC_NEED_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl               [, INCLUDES,]]])
+dnl -------------------------------------------------------------
+AC_DEFUN([AC_NEED_DECLS],
+[AC_FOREACH([ac_Symbol], [$1],
+  [AC_SPECIALIZE([AC_NEED_DECL], ac_Symbol,
+                 [$2],
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP(NEED_[]ac_Symbol[]_DECL))
+$3],
+                 [$4])])])
+])dnl AC_NEED_DECLS
+
+dnl This is the pure sh versions of the macro above.
+dnl [for ac_sym in [$1]
+dnl do
+dnl AC_NEED_DECL($ac_sym,
+dnl             [$4],
+dnl             [AC_DEFINE_UNQUOTED(AC_TR_CPP(${ac_sym}_DECLARED)) $2],
+dnl             [$3])dnl
+dnl done
 
 dnl ### Checking for library functions
 
@@ -2619,10 +2652,11 @@ AC_CACHE_CHECK([for $1], ac_Type,
 [AC_EGREP_CPP(dnl
 changequote(<<,>>)dnl
 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]), [#include <sys/types.h>
+changequote([,]), [#include <stdio.h>
+#include <sys/types.h>
 #if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
+# include <stdlib.h>
+# include <stddef.h>
 #endif
 [$3]
 ], AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])
index 8db54d3f6442872c685406428e816c79aaec15af..8f58198a4d57b125070b516a4e95669903268297 100644 (file)
@@ -2633,21 +2633,30 @@ is declared in a system header file, either @file{signal.h} or
 These macros are used to find declarations not covered by the particular
 test macros.
 
-@defmac AC_CHECK_DECL (@var{symbol}, @r{[}@var{includes}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]]})
-@maindex CHECK_DECL
+@defmac AC_NEED_DECL (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex NEED_DECL
 If @var{symbol} (a function or a variable) is declared in
-@var{includes}, run shell commands @var{action-if-found}, otherwise
-@var{action-if-not-found}.
+@file{stdio.h}, @file{stdlib.h}, @file{stddef.h}, @file{memory.h},
+@file{string.h}, @file{strings.h}, and @file{unistd.h}.  (plus
+@var{includes} if given), run the shell commands @var{action-if-found},
+otherwise @var{action-if-not-found}.
+
+This macro actually tests whether it is valid to use @var{symbol} as an
+r-value, not if it is really declared, because it is much safer to avoid
+introducing extra declarations when not needed.
+
+Please, note that @var{action-if-found} when the symbol is declared, not
+when it is needed.
 @end defmac
 
-@defmac AC_CHECK_DECLS (@var{symbol}@dots{}, @r{[}@var{includes} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]]})
-@maindex CHECK_DECLS
-@cvindex @var{symbol}_DECLARED
+@defmac AC_NEED_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex NEED_DECLS
+@cvindex NEED_@var{symbol}_DECL
 For each given @var{symbol} (whitespace-separated), define
-@code{@var{symbol}_DECLARED} (in all capitals) if @var{symbol} is
-declared.  If @var{action-if-found} is given, it is additional shell
-code to execute when one of the function declarations is found,
-otherwise @var{action-if-not-found} is executed.
+@code{NEED_@var{symbol}_DECL} (in all capitals) if @var{symbol} has to
+be declared to be used as an r-value.  If @var{action-if-found} is
+given, it is additional shell code to execute when one of the function
+declarations is found, otherwise @var{action-if-not-found} is executed.
 @end defmac
 
 
index 55c9c23237347ebf51c8181724ec2d220de2d9f9..d26c9932d7bacea9a425a1cf80eb76cd1ef50812 100644 (file)
@@ -65,14 +65,14 @@ $4
 ])
 ])
 
-define([AC_CHECK_DECLS], [#
-  ifelse([$3], , [
+define([AC_NEED_DECLS], [#
+  ifelse([$2], , [
 @@@decls="$decls $1"@@@
 ], [
 # If it was found, we do:
-$3
+$2
 # If it was not found, we do:
-$4
+$3
 ])
 ])
 
index 426fd4dc57b0b8306ec9233e30eaf6de5085d232..da644b6287667081d7bb24f084dbf95031a034e5 100644 (file)
@@ -264,8 +264,8 @@ if test -n "$decls"; then
   for decl in `for x in $decls; do echo $x; done | sort | uniq`; do
    sym="`echo ${decl} | sed 's/[^a-zA-Z0-9_]/_/g' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
     echo "
-/* Define if you have the \`${decl}' declaration.  */
-#undef ${sym}_DECLARED"
+/* Define if you need the \`${decl}' declaration.  */
+#undef NEED_${sym}_DECL"
   done
 fi
 
index 8db54d3f6442872c685406428e816c79aaec15af..8f58198a4d57b125070b516a4e95669903268297 100644 (file)
@@ -2633,21 +2633,30 @@ is declared in a system header file, either @file{signal.h} or
 These macros are used to find declarations not covered by the particular
 test macros.
 
-@defmac AC_CHECK_DECL (@var{symbol}, @r{[}@var{includes}, @r{[}@var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]]})
-@maindex CHECK_DECL
+@defmac AC_NEED_DECL (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex NEED_DECL
 If @var{symbol} (a function or a variable) is declared in
-@var{includes}, run shell commands @var{action-if-found}, otherwise
-@var{action-if-not-found}.
+@file{stdio.h}, @file{stdlib.h}, @file{stddef.h}, @file{memory.h},
+@file{string.h}, @file{strings.h}, and @file{unistd.h}.  (plus
+@var{includes} if given), run the shell commands @var{action-if-found},
+otherwise @var{action-if-not-found}.
+
+This macro actually tests whether it is valid to use @var{symbol} as an
+r-value, not if it is really declared, because it is much safer to avoid
+introducing extra declarations when not needed.
+
+Please, note that @var{action-if-found} when the symbol is declared, not
+when it is needed.
 @end defmac
 
-@defmac AC_CHECK_DECLS (@var{symbol}@dots{}, @r{[}@var{includes} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]]})
-@maindex CHECK_DECLS
-@cvindex @var{symbol}_DECLARED
+@defmac AC_NEED_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex NEED_DECLS
+@cvindex NEED_@var{symbol}_DECL
 For each given @var{symbol} (whitespace-separated), define
-@code{@var{symbol}_DECLARED} (in all capitals) if @var{symbol} is
-declared.  If @var{action-if-found} is given, it is additional shell
-code to execute when one of the function declarations is found,
-otherwise @var{action-if-not-found} is executed.
+@code{NEED_@var{symbol}_DECL} (in all capitals) if @var{symbol} has to
+be declared to be used as an r-value.  If @var{action-if-found} is
+given, it is additional shell code to execute when one of the function
+declarations is found, otherwise @var{action-if-not-found} is executed.
 @end defmac
 
 
index 0a01b997a109497108ab9a55444d03020ae7f8e8..79866c7d97db5587d308b81bf495b200dad6d680 100644 (file)
@@ -2491,35 +2491,68 @@ dnl ])
 dnl ### Checking for declared symbols
 
 
-dnl AC_CHECK_DECL(SYMBOL, [, INCLUDES,
-dnl              [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-dnl --------------------------------------------------------
+dnl AC_NEED_DECL(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl              [, INCLUDES,]]])
+dnl ------------------------------------------------------------
 dnl Check if SYMBOL (a variable or a function) is declared.
-AC_DEFUN([AC_CHECK_DECL],
-[AC_VAR_PUSHDEF([ac_var], [ac_cv_decl_$1])dnl
-AC_CACHE_CHECK([whether $1 is declared], ac_var,
-[AC_TRY_COMPILE($2,
+dnl This macro is not a _CHECK_, because it is better not to declare
+dnl a symbol if you don't really need it.
+AC_DEFUN([AC_NEED_DECL],
+[AC_VAR_PUSHDEF([ac_Symbol], [ac_cv_decl_$1])dnl
+AC_CACHE_CHECK([whether $1 is declared], ac_Symbol,
+[AC_TRY_COMPILE([#include <stdio.h>
+#ifdef HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#else
+# ifdef HAVE_STRINGS_H
+#  include <strings.h>
+# endif
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+$4],
 [#ifndef $1
 char *p = (char *) $1;
 #endif
 ],
-AC_VAR_SET(ac_var, yes), AC_VAR_SET(ac_var, no))])
-AC_SHELL_IFELSE(test AC_VAR_GET(ac_var) = yes,
-               [$3], [$4])dnl
-AC_VAR_POPDEF([ac_var])dnl
-])dnl AC_CHECK_DECL
-
-dnl AC_CHECK_DECLS(SYMBOL... , [, INCLUDES,
-dnl                [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
-AC_DEFUN(AC_CHECK_DECLS,
-[for ac_sym in $1
-do
-AC_CHECK_DECL($ac_sym,
-              [$2],
-              [AC_DEFINE_UNQUOTED(AC_TR_CPP(${ac_sym}_DECLARED)) $3],
-              [$4])dnl
-done
-])
+AC_VAR_SET(ac_Symbol, yes), AC_VAR_SET(ac_Symbol, no))])
+AC_SHELL_IFELSE(test AC_VAR_GET(ac_Symbol) = yes,
+               [$2], [$3])dnl
+AC_VAR_POPDEF([ac_Symbol])dnl
+])dnl AC_NEED_DECL
+
+dnl AC_NEED_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
+dnl               [, INCLUDES,]]])
+dnl -------------------------------------------------------------
+AC_DEFUN([AC_NEED_DECLS],
+[AC_FOREACH([ac_Symbol], [$1],
+  [AC_SPECIALIZE([AC_NEED_DECL], ac_Symbol,
+                 [$2],
+                 [AC_DEFINE_UNQUOTED(AC_TR_CPP(NEED_[]ac_Symbol[]_DECL))
+$3],
+                 [$4])])])
+])dnl AC_NEED_DECLS
+
+dnl This is the pure sh versions of the macro above.
+dnl [for ac_sym in [$1]
+dnl do
+dnl AC_NEED_DECL($ac_sym,
+dnl             [$4],
+dnl             [AC_DEFINE_UNQUOTED(AC_TR_CPP(${ac_sym}_DECLARED)) $2],
+dnl             [$3])dnl
+dnl done
 
 dnl ### Checking for library functions
 
@@ -2619,10 +2652,11 @@ AC_CACHE_CHECK([for $1], ac_Type,
 [AC_EGREP_CPP(dnl
 changequote(<<,>>)dnl
 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
-changequote([,]), [#include <sys/types.h>
+changequote([,]), [#include <stdio.h>
+#include <sys/types.h>
 #if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
+# include <stdlib.h>
+# include <stddef.h>
 #endif
 [$3]
 ], AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))])