+1999-10-31 Akim Demaille <akim@epita.fr>
+
+ Rename the family AC_NEED_DECL as AC_CHECK: it is more uniform,
+ but keep defining NEED_FOO_DECL when `foo' is not declared. Files
+ not using Autoconf behave better when declarations lacks than when
+ they are wrong. So the unset position should off, hence #if NEEDS
+ instead of #if !HAVE (which is triggered when HAVE is not set).
+
+ * acgeneral.m4 (AC_NEED_DECL): Renamed as...
+ (AC_CHECK_DECL): This. Make sure the arguments are the usual
+ IF-FOUND, IF-NOT-FOUND.
+ (AC_NEED_DECLS, AC_CHECK_DECLS): Likewise.
+ * autoconf.texi (Generic Declarations): Document the changes
+ aforementioned.
+ * autoheader.m4 (AH_NEED_DECLS): Renamed as
+ (AH_CHECK_DECLS): This.
+ (AH_HOOKS): Hook AH_CHECK_DECLS on AC_CHECK_DECLS instead of
+ _NEED_.
+
1999-10-31 Akim Demaille <akim@epita.fr>
Revamp the handling of the arguments of config.status: instead of
------------------------------------------------------------------------------
* Look at user contributed macros:
- prototypes
IEEE double precision math
more
dnl ### Checking for declared symbols
-dnl AC_NEED_DECL(SYMBOL, [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED
+dnl AC_CHECK_DECL(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
dnl [, INCLUDES,]]])
-dnl --------------------------------------------------------------
+dnl -------------------------------------------------------------
dnl Check if SYMBOL (a variable or a function) is declared.
-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_need_decl_$1])dnl
-AC_CACHE_CHECK([whether $1 needs to be declared], ac_Symbol,
+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_TRY_COMPILE(m4_default([$4], [#include <stdio.h>
#ifdef HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
char *p = (char *) $1;
#endif
],
-AC_VAR_SET(ac_Symbol, no), AC_VAR_SET(ac_Symbol, yes))])
+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_CHECK_DECL
-dnl AC_NEED_DECLS(SYMBOL, [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED
+dnl AC_CHECK_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
dnl [, INCLUDES]]])
-dnl ---------------------------------------------------------------
-AC_DEFUN([AC_NEED_DECLS],
+dnl --------------------------------------------------------------
+AC_DEFUN([AC_CHECK_DECLS],
[AC_FOREACH([AC_Symbol], [$1],
- [AC_SPECIALIZE([AC_NEED_DECL], AC_Symbol,
- [AC_DEFINE_UNQUOTED(AC_TR_CPP(NEED_DECL_[]AC_Symbol))
-$2],
- [$3],
+ [AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol,
+ [$2],
+ [AC_DEFINE_UNQUOTED(AC_TR_CPP([NEED_]AC_Symbol[_DECL]))
+$3],
[$4])])
-])dnl AC_NEED_DECLS
+])dnl AC_CHECK_DECLS
dnl ### Checking for library functions
], ac_cv_c_stringize=no, ac_cv_c_stringize=yes))
if test "${ac_cv_c_stringize}" = yes; then
AC_DEFINE(HAVE_STRINGIZE, 1,
- [Define if you have the ANSI # stringizing operator in cpp.])
+ [Define if cpp supports the ANSI # stringizing operator.])
fi
AC_MSG_RESULT([${ac_cv_c_stringize}])
])dnl AC_C_STRINGIZE
These macros are used to find declarations not covered by the particular
test macros.
-@defmac AC_NEED_DECL (@var{symbol} @r{[}, @var{action-if-needed}@r{[}, @var{action-if-not-needed} @r{[},@var{includes} @r{]]]})
-@maindex NEED_DECL
+@defmac AC_CHECK_DECL (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex CHECK_DECL
If the declaration of @var{symbol} (a function or a variable) is needed
because it is not declared in @var{includes}, run the shell commands
-@var{action-if-needed}, otherwise @var{action-if-not-needed}. If no
+@var{action-if-not-found}, otherwise @var{action-if-found}. If no
@var{includes} are given at all, by default @file{stdio.h},
@file{stdlib.h}, @file{stddef.h}, @file{memory.h}, @file{string.h},
@file{strings.h}, and @file{unistd.h} will be included.
introducing extra declarations when not needed.
@end defmac
-@defmac AC_NEED_DECLS (@var{symbol} @r{[}, @var{action-if-needed}@r{[}, @var{action-if-not-needed} @r{[},@var{includes} @r{]]]})
-@maindex NEED_DECLS
-@cvindex NEED_DECL_@var{symbol}
+@defmac AC_CHECK_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex CHECK_DECLS
+@cvindex NEED_@var{symbol}_DECL
For each given @var{symbol} (whitespace-separated), define
-@code{NEED_DECL_@var{symbol}} (in all capitals) if @var{symbol} has to
-be declared to be used as an r-value. If @var{action-if-needed} is
+@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-not-found} is
given, it is additional shell code to execute when one of the function
-declarations is needed, otherwise @var{action-if-not-needed} is
-executed.
+declarations is needed, otherwise @var{action-if-found} is executed.
+
+This macro does not define @code{HAVE_@var{symbol}_DECL} on purpose.
+The following code
+@example
+#if NEED_FOO_DECL
+/* Declare foo. */
+#endif
+@end example
+is safer than
+@example
+#if !HAVE_FOO_DECL
+/* Declare foo. */
+#endif
+@end example
+since in this last case, if @code{configure} was not run, then the test
+succeeds, thus @code{foo} is declared, with risks to clash with previous
+declarations. It is safer not to declare in case of doubts.
@end defmac
# Failure
$3])])
-define([AH_NEED_DECLS],
+define([AH_CHECK_DECLS],
[AC_FOREACH([AC_Symbol], [$1],
- [AH_TEMPLATE(AC_TR_CPP(NEED_DECL_[]AC_Symbol),
+ [AH_TEMPLATE(AC_TR_CPP([NEED_]AC_Symbol[_DECL]),
[Define if you need the declaration of `]AC_Symbol['.])
# Success
$2
AH_HOOK([AC_DEFINE], [AH_DEFINE])
AH_HOOK([AC_DEFINE_UNQUOTED], [AH_DEFINE])
-AH_HOOK([AC_NEED_DECLS], [AH_NEED_DECLS])
+AH_HOOK([AC_CHECK_DECLS], [AH_CHECK_DECLS])
AH_HOOK([AC_CHECK_SIZEOF], [AH_CHECK_SIZEOF])
AH_HOOK([AC_CHECK_FUNCS], [AH_CHECK_FUNCS])
AH_HOOK([AC_CHECK_HEADERS], [AH_CHECK_HEADERS])
These macros are used to find declarations not covered by the particular
test macros.
-@defmac AC_NEED_DECL (@var{symbol} @r{[}, @var{action-if-needed}@r{[}, @var{action-if-not-needed} @r{[},@var{includes} @r{]]]})
-@maindex NEED_DECL
+@defmac AC_CHECK_DECL (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex CHECK_DECL
If the declaration of @var{symbol} (a function or a variable) is needed
because it is not declared in @var{includes}, run the shell commands
-@var{action-if-needed}, otherwise @var{action-if-not-needed}. If no
+@var{action-if-not-found}, otherwise @var{action-if-found}. If no
@var{includes} are given at all, by default @file{stdio.h},
@file{stdlib.h}, @file{stddef.h}, @file{memory.h}, @file{string.h},
@file{strings.h}, and @file{unistd.h} will be included.
introducing extra declarations when not needed.
@end defmac
-@defmac AC_NEED_DECLS (@var{symbol} @r{[}, @var{action-if-needed}@r{[}, @var{action-if-not-needed} @r{[},@var{includes} @r{]]]})
-@maindex NEED_DECLS
-@cvindex NEED_DECL_@var{symbol}
+@defmac AC_CHECK_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]})
+@maindex CHECK_DECLS
+@cvindex NEED_@var{symbol}_DECL
For each given @var{symbol} (whitespace-separated), define
-@code{NEED_DECL_@var{symbol}} (in all capitals) if @var{symbol} has to
-be declared to be used as an r-value. If @var{action-if-needed} is
+@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-not-found} is
given, it is additional shell code to execute when one of the function
-declarations is needed, otherwise @var{action-if-not-needed} is
-executed.
+declarations is needed, otherwise @var{action-if-found} is executed.
+
+This macro does not define @code{HAVE_@var{symbol}_DECL} on purpose.
+The following code
+@example
+#if NEED_FOO_DECL
+/* Declare foo. */
+#endif
+@end example
+is safer than
+@example
+#if !HAVE_FOO_DECL
+/* Declare foo. */
+#endif
+@end example
+since in this last case, if @code{configure} was not run, then the test
+succeeds, thus @code{foo} is declared, with risks to clash with previous
+declarations. It is safer not to declare in case of doubts.
@end defmac
dnl ### Checking for declared symbols
-dnl AC_NEED_DECL(SYMBOL, [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED
+dnl AC_CHECK_DECL(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
dnl [, INCLUDES,]]])
-dnl --------------------------------------------------------------
+dnl -------------------------------------------------------------
dnl Check if SYMBOL (a variable or a function) is declared.
-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_need_decl_$1])dnl
-AC_CACHE_CHECK([whether $1 needs to be declared], ac_Symbol,
+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_TRY_COMPILE(m4_default([$4], [#include <stdio.h>
#ifdef HAVE_STRING_H
# if !STDC_HEADERS && HAVE_MEMORY_H
char *p = (char *) $1;
#endif
],
-AC_VAR_SET(ac_Symbol, no), AC_VAR_SET(ac_Symbol, yes))])
+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_CHECK_DECL
-dnl AC_NEED_DECLS(SYMBOL, [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED
+dnl AC_CHECK_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
dnl [, INCLUDES]]])
-dnl ---------------------------------------------------------------
-AC_DEFUN([AC_NEED_DECLS],
+dnl --------------------------------------------------------------
+AC_DEFUN([AC_CHECK_DECLS],
[AC_FOREACH([AC_Symbol], [$1],
- [AC_SPECIALIZE([AC_NEED_DECL], AC_Symbol,
- [AC_DEFINE_UNQUOTED(AC_TR_CPP(NEED_DECL_[]AC_Symbol))
-$2],
- [$3],
+ [AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol,
+ [$2],
+ [AC_DEFINE_UNQUOTED(AC_TR_CPP([NEED_]AC_Symbol[_DECL]))
+$3],
[$4])])
-])dnl AC_NEED_DECLS
+])dnl AC_CHECK_DECLS
dnl ### Checking for library functions
], ac_cv_c_stringize=no, ac_cv_c_stringize=yes))
if test "${ac_cv_c_stringize}" = yes; then
AC_DEFINE(HAVE_STRINGIZE, 1,
- [Define if you have the ANSI # stringizing operator in cpp.])
+ [Define if cpp supports the ANSI # stringizing operator.])
fi
AC_MSG_RESULT([${ac_cv_c_stringize}])
])dnl AC_C_STRINGIZE