summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@epita.fr>1999-09-27 12:04:40 +0000
committerAkim Demaille <akim@epita.fr>1999-09-27 12:04:40 +0000
commit5d1058e34544f140611ddc77b22e37a70f05bde1 (patch)
treef102093c3a2d4ba22f7da1d72c4d7a4b5782802c
parent811a0a183aa7cbaaf79af8500ef2c33093a55bd3 (diff)
downloadautoconf-5d1058e34544f140611ddc77b22e37a70f05bde1.tar.gz
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.
-rw-r--r--ChangeLog11
-rw-r--r--acgeneral.m488
-rw-r--r--autoconf.texi31
-rw-r--r--autoheader.m48
-rw-r--r--autoheader.sh4
-rw-r--r--doc/autoconf.texi31
-rw-r--r--lib/autoconf/general.m488
7 files changed, 179 insertions, 82 deletions
diff --git a/ChangeLog b/ChangeLog
index f297f8d3..9038ebd8 100644
--- 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.
diff --git a/acgeneral.m4 b/acgeneral.m4
index 0a01b997..79866c7d 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -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))])
diff --git a/autoconf.texi b/autoconf.texi
index 8db54d3f..8f58198a 100644
--- a/autoconf.texi
+++ b/autoconf.texi
@@ -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
diff --git a/autoheader.m4 b/autoheader.m4
index 55c9c232..d26c9932 100644
--- a/autoheader.m4
+++ b/autoheader.m4
@@ -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
])
])
diff --git a/autoheader.sh b/autoheader.sh
index 426fd4dc..da644b62 100644
--- a/autoheader.sh
+++ b/autoheader.sh
@@ -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
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 8db54d3f..8f58198a 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -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
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 0a01b997..79866c7d 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -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))])