From: Akim Demaille Date: Mon, 20 Dec 1999 13:40:18 +0000 (+0000) Subject: 1999-10-31 Akim Demaille X-Git-Tag: autoconf-2.50~1308 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed0f9a6d4e4ee82a7e19e4bb6cbc3726dabada62;p=thirdparty%2Fautoconf.git 1999-10-31 Akim Demaille 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_. --- diff --git a/ChangeLog b/ChangeLog index b64cfcf99..bcce91e6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +1999-10-31 Akim Demaille + + 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 Revamp the handling of the arguments of config.status: instead of diff --git a/TODO b/TODO index b5ef67e87..9bcf7cbee 100644 --- a/TODO +++ b/TODO @@ -288,7 +288,6 @@ in a dnl comment. (Seems to be hard.) ------------------------------------------------------------------------------ * Look at user contributed macros: - prototypes IEEE double precision math more diff --git a/acgeneral.m4 b/acgeneral.m4 index 2294e3506..5dec803ed 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -2731,15 +2731,13 @@ dnl ]) 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 #ifdef HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H @@ -2767,23 +2765,23 @@ AC_CACHE_CHECK([whether $1 needs to be declared], ac_Symbol, 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 diff --git a/acspecific.m4 b/acspecific.m4 index 06e0ee4fe..e3f2c5748 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -2438,7 +2438,7 @@ char *s = x(teststring); ], 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 diff --git a/autoconf.texi b/autoconf.texi index 905be4367..b51eb9302 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -2607,11 +2607,11 @@ 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_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. @@ -2621,15 +2621,31 @@ r-value, not if it is really declared, because it is much safer to avoid 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 diff --git a/autoheader.m4 b/autoheader.m4 index 652a5b71c..e005d6d24 100644 --- a/autoheader.m4 +++ b/autoheader.m4 @@ -90,9 +90,9 @@ $2 # 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 @@ -205,7 +205,7 @@ $4]) 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]) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 905be4367..b51eb9302 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2607,11 +2607,11 @@ 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_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. @@ -2621,15 +2621,31 @@ r-value, not if it is really declared, because it is much safer to avoid 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 diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 2294e3506..5dec803ed 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -2731,15 +2731,13 @@ dnl ]) 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 #ifdef HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H @@ -2767,23 +2765,23 @@ AC_CACHE_CHECK([whether $1 needs to be declared], ac_Symbol, 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 diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 06e0ee4fe..e3f2c5748 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -2438,7 +2438,7 @@ char *s = x(teststring); ], 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