From: Akim Demaille Date: Fri, 28 Jan 2000 15:23:37 +0000 (+0000) Subject: 1999-11-01 Akim Demaille X-Git-Tag: autoconf-2.50~1270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=097b84fd1cfd0a4cd924bc3f5c12e723bbff4e1c;p=thirdparty%2Fautoconf.git 1999-11-01 Akim Demaille Install a uniform set of default includes. * acgeneral.m4 (AC_INCLUDES_DEFAULT): New macro. Expands in its argument if non empty, otherwise a default list of includes. (AC_CHECK_DECL, AC_CHECK_TYPE_INTERNAL): Use AC_INCLUDES_DEFAULT. * autoconf.texi: Adjusted. --- diff --git a/ChangeLog b/ChangeLog index 0a4ef9f4c..c36cbcbdc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +1999-11-01 Akim Demaille + + Install a uniform set of default includes. + + * acgeneral.m4 (AC_INCLUDES_DEFAULT): New macro. Expands in its + argument if non empty, otherwise a default list of includes. + (AC_CHECK_DECL, AC_CHECK_TYPE_INTERNAL): Use AC_INCLUDES_DEFAULT. + * autoconf.texi: Adjusted. + 1999-11-01 Akim Demaille * autoheader.m4 (AH_FUNC_ALLOCA, AH_C_CHAR_UNSIGNED, AH_AIX): diff --git a/acgeneral.m4 b/acgeneral.m4 index 1fffefed6..7bef706e6 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -1229,12 +1229,16 @@ AC_INIT_PREPARE($1)dnl AC_DIVERT_POP()dnl to NORMAL ]) -dnl AC_INCLUDE +dnl AC_INCLUDE(FILES...) +dnl -------------------- +dnl Note that there is shell expansion, hence AC_INCLUDE(m4/*.m4) is +dnl legal. AC_DEFUN(AC_INCLUDE, [ifelse($1, [], [], [dnl esyscmd([for file in $1; do echo "m4_include($file)dnl"; done])dnl ])]) + dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR) dnl ------------------------------------------ dnl Called by AC_INIT to build the preamble of the `configure' scripts. @@ -2154,6 +2158,41 @@ AC_DEFUN(AC_C_STRUCT_MEMBER, $1="$ac_cv_c_struct_member_$1"]) +dnl ### Default headers. + +dnl Always use the same set of default headers for all the generic macros. +dnl It is easier to document, to extend, and to understand than having +dnl specific defaults for each macro. + +dnl AC_INCLUDES_DEFAULT([INCLUDES]) +dnl ------------------------------- +dnl If INCLUDES is empty, expand in default includes, otherwise in +dnl INCLUDES. +define(AC_INCLUDES_DEFAULT, +[m4_default([$1], +[#include +#ifdef HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#else +# ifdef HAVE_STRINGS_H +# include +# endif +#endif +#if STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_UNISTD_H +# include +#endif +])]) dnl ### Checking for programs @@ -2509,6 +2548,7 @@ dnl ### Examining declarations dnl AC_TRY_CPP(INCLUDES, [ACTION-IF-TRUE [, ACTION-IF-FALSE]]) dnl ---------------------------------------------------------- +dnl INCLUDES are not defaulted. AC_DEFUN(AC_TRY_CPP, [AC_REQUIRE_CPP()dnl cat >conftest.$ac_ext <conftest.$ac_ext <conftest.$ac_ext < -#ifdef HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#if STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -]), +[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]), [#ifndef $1 char *p = (char *) $1; #endif @@ -2822,9 +2843,11 @@ AC_SHELL_IFELSE(test AC_VAR_GET(ac_Symbol) = yes, AC_VAR_POPDEF([ac_Symbol])dnl ])dnl AC_CHECK_DECL -dnl AC_CHECK_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND -dnl [, INCLUDES]]]) -dnl -------------------------------------------------------------- + +dnl AC_CHECK_DECLS(SYMBOL, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [INCLUDES]) +dnl -------------------------------------------------------- AC_DEFUN([AC_CHECK_DECLS], [AC_FOREACH([AC_Symbol], [$1], [AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol, @@ -2898,7 +2921,8 @@ dnl ### Checking compiler characteristics dnl AC_CHECK_SIZEOF(TYPE [, CROSS-SIZE, [INCLUDES]]) dnl ------------------------------------------------ dnl This macro will probably be obsoleted by the macros of Kaveh. In -dnl addition `CHECK' is not a proper name (is not boolean). +dnl addition `CHECK' is not a proper name (is not boolean). And finally: +dnl shouldn't we use the default INCLUDES? AC_DEFUN(AC_CHECK_SIZEOF, [AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl AC_CACHE_CHECK([size of $1], ac_Sizeof, @@ -2923,9 +2947,10 @@ AC_VAR_POPDEF([ac_Sizeof])dnl dnl ### Checking for typedefs -dnl AC_CHECK_TYPE_INTERNAL(TYPE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl AC_CHECK_TYPE_INTERNAL(TYPE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], dnl [INCLUDES]) -dnl ---------------------------------------------------------------------- +dnl ---------------------------------------------------------------- dnl Check whether the type TYPE is supported by the system, maybe via the dnl the provided includes. This macro implements the former task of dnl AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was @@ -2940,25 +2965,21 @@ AC_DEFUN(AC_CHECK_TYPE_INTERNAL, [AC_REQUIRE([AC_HEADER_STDC])dnl AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl AC_CACHE_CHECK([for $1], ac_Type, -[AC_TRY_COMPILE(m4_default([$4 -], [#include -#include -#if STDC_HEADERS -# include -# include -#endif -]), - [$1 foo;], - AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))]) +[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]), + [$1 foo;], + AC_VAR_SET(ac_Type, yes), + AC_VAR_SET(ac_Type, no))]) AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes, [$2], [$3])dnl AC_VAR_POPDEF([ac_Type])dnl ])dnl AC_CHECK_TYPE_INTERNAL -dnl AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES]) -dnl --------------------------------------------------------------------------- -dnl TYPES is an m4 list. +dnl AC_CHECK_TYPES((TYPE, ...), +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [INCLUDES]) +dnl -------------------------------------------------------- +dnl TYPEs is an m4 list. AC_DEFUN(AC_CHECK_TYPES, [m4_foreach([AC_Type], [$1], [AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type, diff --git a/autoconf.texi b/autoconf.texi index 0363d2bf0..d27f5e46d 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -2612,21 +2612,20 @@ 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{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]}) +@defmac AC_CHECK_DECL (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, o@var{includes}) @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-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. +@var{includes} are given at all, FIXME: point to a node defining the +standard include. 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. @end defmac -@defmac AC_CHECK_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]}) +@defmac AC_CHECK_DECLS (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes}) @maindex CHECK_DECLS @cvindex NEED_@var{symbol}_DECL For each given @var{symbol} (whitespace-separated), define @@ -2820,8 +2819,7 @@ particular test macros. @defmac AC_CHECK_TYPES ((@var{type}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes}) @maindex CHECK_TYPES -For each given @var{type} that is defined by the @var{includes} (by -default, @file{sys/types.h}, @file{stdlib.h}, and @file{stddef.h}), +For each given @var{type} that is defined by the FIXME: @var{includes}, define @code{HAVE_@var{type}} (in all capitals). If @var{action-if-found} is given, it is additional shell code to execute when one of the header files is found. You can give it a value of @@ -2845,11 +2843,9 @@ to incompatible code in the case of pointer types. @defmac AC_CHECK_TYPE (@var{type}, @var{default}, @ovar{includes}) @maindex CHECK_TYPE -If the type @var{type} is not defined in @file{sys/types.h}, or -@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the C -(or C++) builtin type @var{default}; e.g., @samp{short} or -@samp{unsigned}. The default header files to search can be replaced by -supplying the optional argument @var{includes}. +If the type @var{type} is not defined in FIXME: @ovar{includes}, define +it to be the C (or C++) builtin type @var{default}; e.g., @samp{short} +or @samp{unsigned}. This macro has a broken design. First, although it is a member of the @code{CHECK} clan, singular subfamily, it does more than just checking. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 0363d2bf0..d27f5e46d 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2612,21 +2612,20 @@ 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{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]}) +@defmac AC_CHECK_DECL (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, o@var{includes}) @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-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. +@var{includes} are given at all, FIXME: point to a node defining the +standard include. 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. @end defmac -@defmac AC_CHECK_DECLS (@var{symbol} @r{[}, @var{action-if-found}@r{[}, @var{action-if-not-found} @r{[},@var{includes} @r{]]]}) +@defmac AC_CHECK_DECLS (@var{symbol}, @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes}) @maindex CHECK_DECLS @cvindex NEED_@var{symbol}_DECL For each given @var{symbol} (whitespace-separated), define @@ -2820,8 +2819,7 @@ particular test macros. @defmac AC_CHECK_TYPES ((@var{type}, @dots{}), @ovar{action-if-found}, @ovar{action-if-not-found}, @ovar{includes}) @maindex CHECK_TYPES -For each given @var{type} that is defined by the @var{includes} (by -default, @file{sys/types.h}, @file{stdlib.h}, and @file{stddef.h}), +For each given @var{type} that is defined by the FIXME: @var{includes}, define @code{HAVE_@var{type}} (in all capitals). If @var{action-if-found} is given, it is additional shell code to execute when one of the header files is found. You can give it a value of @@ -2845,11 +2843,9 @@ to incompatible code in the case of pointer types. @defmac AC_CHECK_TYPE (@var{type}, @var{default}, @ovar{includes}) @maindex CHECK_TYPE -If the type @var{type} is not defined in @file{sys/types.h}, or -@file{stdlib.h} or @file{stddef.h} if they exist, define it to be the C -(or C++) builtin type @var{default}; e.g., @samp{short} or -@samp{unsigned}. The default header files to search can be replaced by -supplying the optional argument @var{includes}. +If the type @var{type} is not defined in FIXME: @ovar{includes}, define +it to be the C (or C++) builtin type @var{default}; e.g., @samp{short} +or @samp{unsigned}. This macro has a broken design. First, although it is a member of the @code{CHECK} clan, singular subfamily, it does more than just checking. diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 1fffefed6..7bef706e6 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1229,12 +1229,16 @@ AC_INIT_PREPARE($1)dnl AC_DIVERT_POP()dnl to NORMAL ]) -dnl AC_INCLUDE +dnl AC_INCLUDE(FILES...) +dnl -------------------- +dnl Note that there is shell expansion, hence AC_INCLUDE(m4/*.m4) is +dnl legal. AC_DEFUN(AC_INCLUDE, [ifelse($1, [], [], [dnl esyscmd([for file in $1; do echo "m4_include($file)dnl"; done])dnl ])]) + dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR) dnl ------------------------------------------ dnl Called by AC_INIT to build the preamble of the `configure' scripts. @@ -2154,6 +2158,41 @@ AC_DEFUN(AC_C_STRUCT_MEMBER, $1="$ac_cv_c_struct_member_$1"]) +dnl ### Default headers. + +dnl Always use the same set of default headers for all the generic macros. +dnl It is easier to document, to extend, and to understand than having +dnl specific defaults for each macro. + +dnl AC_INCLUDES_DEFAULT([INCLUDES]) +dnl ------------------------------- +dnl If INCLUDES is empty, expand in default includes, otherwise in +dnl INCLUDES. +define(AC_INCLUDES_DEFAULT, +[m4_default([$1], +[#include +#ifdef HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#else +# ifdef HAVE_STRINGS_H +# include +# endif +#endif +#if STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_UNISTD_H +# include +#endif +])]) dnl ### Checking for programs @@ -2509,6 +2548,7 @@ dnl ### Examining declarations dnl AC_TRY_CPP(INCLUDES, [ACTION-IF-TRUE [, ACTION-IF-FALSE]]) dnl ---------------------------------------------------------- +dnl INCLUDES are not defaulted. AC_DEFUN(AC_TRY_CPP, [AC_REQUIRE_CPP()dnl cat >conftest.$ac_ext <conftest.$ac_ext <conftest.$ac_ext < -#ifdef HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H -# include -# endif -# include -#else -# ifdef HAVE_STRINGS_H -# include -# endif -#endif -#if STDC_HEADERS -# include -# include -#else -# ifdef HAVE_STDLIB_H -# include -# endif -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -]), +[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]), [#ifndef $1 char *p = (char *) $1; #endif @@ -2822,9 +2843,11 @@ AC_SHELL_IFELSE(test AC_VAR_GET(ac_Symbol) = yes, AC_VAR_POPDEF([ac_Symbol])dnl ])dnl AC_CHECK_DECL -dnl AC_CHECK_DECLS(SYMBOL, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND -dnl [, INCLUDES]]]) -dnl -------------------------------------------------------------- + +dnl AC_CHECK_DECLS(SYMBOL, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [INCLUDES]) +dnl -------------------------------------------------------- AC_DEFUN([AC_CHECK_DECLS], [AC_FOREACH([AC_Symbol], [$1], [AC_SPECIALIZE([AC_CHECK_DECL], AC_Symbol, @@ -2898,7 +2921,8 @@ dnl ### Checking compiler characteristics dnl AC_CHECK_SIZEOF(TYPE [, CROSS-SIZE, [INCLUDES]]) dnl ------------------------------------------------ dnl This macro will probably be obsoleted by the macros of Kaveh. In -dnl addition `CHECK' is not a proper name (is not boolean). +dnl addition `CHECK' is not a proper name (is not boolean). And finally: +dnl shouldn't we use the default INCLUDES? AC_DEFUN(AC_CHECK_SIZEOF, [AC_VAR_PUSHDEF([ac_Sizeof], [ac_cv_sizeof_$1])dnl AC_CACHE_CHECK([size of $1], ac_Sizeof, @@ -2923,9 +2947,10 @@ AC_VAR_POPDEF([ac_Sizeof])dnl dnl ### Checking for typedefs -dnl AC_CHECK_TYPE_INTERNAL(TYPE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl AC_CHECK_TYPE_INTERNAL(TYPE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], dnl [INCLUDES]) -dnl ---------------------------------------------------------------------- +dnl ---------------------------------------------------------------- dnl Check whether the type TYPE is supported by the system, maybe via the dnl the provided includes. This macro implements the former task of dnl AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was @@ -2940,25 +2965,21 @@ AC_DEFUN(AC_CHECK_TYPE_INTERNAL, [AC_REQUIRE([AC_HEADER_STDC])dnl AC_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl AC_CACHE_CHECK([for $1], ac_Type, -[AC_TRY_COMPILE(m4_default([$4 -], [#include -#include -#if STDC_HEADERS -# include -# include -#endif -]), - [$1 foo;], - AC_VAR_SET(ac_Type, yes), AC_VAR_SET(ac_Type, no))]) +[AC_TRY_COMPILE(AC_INCLUDES_DEFAULT([$4]), + [$1 foo;], + AC_VAR_SET(ac_Type, yes), + AC_VAR_SET(ac_Type, no))]) AC_SHELL_IFELSE(test AC_VAR_GET(ac_Type) = yes, [$2], [$3])dnl AC_VAR_POPDEF([ac_Type])dnl ])dnl AC_CHECK_TYPE_INTERNAL -dnl AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [INCLUDES]) -dnl --------------------------------------------------------------------------- -dnl TYPES is an m4 list. +dnl AC_CHECK_TYPES((TYPE, ...), +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +dnl [INCLUDES]) +dnl -------------------------------------------------------- +dnl TYPEs is an m4 list. AC_DEFUN(AC_CHECK_TYPES, [m4_foreach([AC_Type], [$1], [AC_SPECIALIZE([AC_CHECK_TYPE_INTERNAL], AC_Type,