From: Ben Elliston Date: Sat, 10 Apr 1999 19:54:57 +0000 (+0000) Subject: 1999-04-11 Ben Elliston X-Git-Tag: experimental-branchpoint~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0012aaa6ecdb847da8d337ba08bc62696a924f55;p=thirdparty%2Fautoconf.git 1999-04-11 Ben Elliston * acgeneral.m4 (AC_C_STRUCT_MEMBER): New macro. * acspecific.m4 (AC_STRUCT_TIMEZONE): Rewrite in terms of AC_C_STRUCT_MEMBER. (AC_STRUCT_ST_BLOCKS): Likewise. (AC_STRUCT_ST_BLKSIZE): Likewise. (AC_STRUCT_ST_RDEV): Likewise. * autoconf.texi (Structures): Update. Add menu for subnodes. (Particular Structures): New node. (Generic Structures): New node. (AC_C_STRUCT_MEMBER): Document. --- diff --git a/ChangeLog b/ChangeLog index 7a85eba0..8a124bb7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +1999-04-11 Ben Elliston + + * acgeneral.m4 (AC_C_STRUCT_MEMBER): New macro. + * acspecific.m4 (AC_STRUCT_TIMEZONE): Rewrite in terms of + AC_C_STRUCT_MEMBER. + (AC_STRUCT_ST_BLOCKS): Likewise. + (AC_STRUCT_ST_BLKSIZE): Likewise. + (AC_STRUCT_ST_RDEV): Likewise. + * autoconf.texi (Structures): Update. Add menu for subnodes. + (Particular Structures): New node. + (Generic Structures): New node. + (AC_C_STRUCT_MEMBER): Document. + 1999-04-10 Ben Elliston * mkinstalldirs: Add `-m' flag to specify the mode of a newly diff --git a/acgeneral.m4 b/acgeneral.m4 index 5bfaaacc..7eccd9a2 100644 --- a/acgeneral.m4 +++ b/acgeneral.m4 @@ -1277,6 +1277,17 @@ define(AC_OBSOLETE, )]) +dnl ### Generic structure checks + +dnl Check if a particular structure member exists. +dnl AC_C_STRUCT_MEMBER(VARIABLE, INCLUDES, TYPE, MEMBER) +AC_DEFUN(AC_C_STRUCT_MEMBER, +[AC_CACHE_CHECK([for member $4 in aggregate type $3],ac_cv_c_struct_member_$1, + [AC_TRY_COMPILE([$2], [$3 foo; foo.$4;], + ac_cv_c_struct_member_$1=yes,ac_cv_c_struct_member_$1=no)]) +$1="$ac_cv_c_struct_member_$1"]) + + dnl ### Checking for programs diff --git a/acspecific.m4 b/acspecific.m4 index 21b1fa5e..da9ba74e 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -1733,11 +1733,9 @@ fi AC_DEFUN(AC_STRUCT_TIMEZONE, [AC_REQUIRE([AC_STRUCT_TM])dnl -AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone, -[AC_TRY_COMPILE([#include -#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], - ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)]) -if test "$ac_cv_struct_tm_zone" = yes; then +AC_C_STRUCT_MEMBER(tm_zone, [#include +#include <$ac_cv_struct_tm>], [struct tm], tm_zone) +if test "$ac_cv_c_struct_member_tm_zone" = yes; then AC_DEFINE(HAVE_TM_ZONE) else AC_CACHE_CHECK(for tzname, ac_cv_var_tzname, @@ -1756,11 +1754,9 @@ fi ]) AC_DEFUN(AC_STRUCT_ST_BLOCKS, -[AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks, -[AC_TRY_COMPILE([#include -#include ], [struct stat s; s.st_blocks;], -ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)]) -if test $ac_cv_struct_st_blocks = yes; then +[AC_C_STRUCT_MEMBER(st_blocks, [#include +#include ], [struct stat], st_blocks) +if test $ac_cv_c_struct_member_st_blocks = yes; then AC_DEFINE(HAVE_ST_BLOCKS) else LIBOBJS="$LIBOBJS fileblocks.${ac_objext}" @@ -1769,21 +1765,17 @@ AC_SUBST(LIBOBJS)dnl ]) AC_DEFUN(AC_STRUCT_ST_BLKSIZE, -[AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize, -[AC_TRY_COMPILE([#include -#include ], [struct stat s; s.st_blksize;], -ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)]) -if test $ac_cv_struct_st_blksize = yes; then +[AC_C_STRUCT_MEMBER(st_blksize, [#include +#include ], [struct stat], st_blksize) +if test $ac_cv_c_struct_member_st_blksize = yes; then AC_DEFINE(HAVE_ST_BLKSIZE) fi ]) AC_DEFUN(AC_STRUCT_ST_RDEV, -[AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev, -[AC_TRY_COMPILE([#include -#include ], [struct stat s; s.st_rdev;], -ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)]) -if test $ac_cv_struct_st_rdev = yes; then +[AC_C_STRUCT_MEMBER(st_rdev, [#include +#include ], [struct stat], st_rdev) +if test $ac_cv_c_struct_member_st_rdev = yes; then AC_DEFINE(HAVE_ST_RDEV) fi ]) diff --git a/autoconf.texi b/autoconf.texi index 00476f52..d94e59e1 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -2479,10 +2479,21 @@ is executed when one of the header files is not found. @node Structures, Typedefs, Header Files, Existing Tests @section Structures +The following macros check for the presence of certain members in C +structures. If there is no macro specifically defined to check for a +member you need, then you can use the general structure member macro +(@pxref{Generic Structures}) or, for more complex tests, you may use +@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}). + +@menu +* Particular Structures:: Macros to check for certain stucture members. +* Generic Structures:: How to find other structure members. +@end menu + +@node Particular Structures, Generic Structures, Structures, Structures +@subsection Particular Structure Checks + The following macros check for certain structures or structure members. -To check structures not listed here, use @code{AC_EGREP_CPP} -(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE} -(@pxref{Examining Syntax}). @defmac AC_HEADER_STAT @maindex HEADER_STAT @@ -2562,6 +2573,26 @@ Figure out how to get the current timezone. If @code{struct tm} has a external array @code{tzname} is found, define @code{HAVE_TZNAME}. @end defmac +@node Generic Structures, , Particular Structures, Structures +@subsection Generic Structure Checks + +These macros are used to find structure members not covered by the +particular test macros. + +@defmac AC_C_STRUCT_MEMBER (@var{variable}, @var{includes}, @var{type}, @var{member}) +@maindex C_STRUCT_MEMBER +Check whether @var{member} is a member of the C aggregate @var{type}. +The value of @var{type} may be the name of any legitimate C data type +including the keywords @code{struct} and @code{union}. @var{includes} is +any @code{#include} statements needed to obtain the definition of the +aggregate type. If @var{member} is present, set @var{variable} to @samp{yes}, +otherwise @samp{no}. An example: +@example +AC_C_STRUCT_MEMBER(gecos, + [#include ], [struct passwd], gecos) +@end example +@end defmac + @node Typedefs, C Compiler Characteristics, Structures, Existing Tests @section Typedefs diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 00476f52..d94e59e1 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2479,10 +2479,21 @@ is executed when one of the header files is not found. @node Structures, Typedefs, Header Files, Existing Tests @section Structures +The following macros check for the presence of certain members in C +structures. If there is no macro specifically defined to check for a +member you need, then you can use the general structure member macro +(@pxref{Generic Structures}) or, for more complex tests, you may use +@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}). + +@menu +* Particular Structures:: Macros to check for certain stucture members. +* Generic Structures:: How to find other structure members. +@end menu + +@node Particular Structures, Generic Structures, Structures, Structures +@subsection Particular Structure Checks + The following macros check for certain structures or structure members. -To check structures not listed here, use @code{AC_EGREP_CPP} -(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE} -(@pxref{Examining Syntax}). @defmac AC_HEADER_STAT @maindex HEADER_STAT @@ -2562,6 +2573,26 @@ Figure out how to get the current timezone. If @code{struct tm} has a external array @code{tzname} is found, define @code{HAVE_TZNAME}. @end defmac +@node Generic Structures, , Particular Structures, Structures +@subsection Generic Structure Checks + +These macros are used to find structure members not covered by the +particular test macros. + +@defmac AC_C_STRUCT_MEMBER (@var{variable}, @var{includes}, @var{type}, @var{member}) +@maindex C_STRUCT_MEMBER +Check whether @var{member} is a member of the C aggregate @var{type}. +The value of @var{type} may be the name of any legitimate C data type +including the keywords @code{struct} and @code{union}. @var{includes} is +any @code{#include} statements needed to obtain the definition of the +aggregate type. If @var{member} is present, set @var{variable} to @samp{yes}, +otherwise @samp{no}. An example: +@example +AC_C_STRUCT_MEMBER(gecos, + [#include ], [struct passwd], gecos) +@end example +@end defmac + @node Typedefs, C Compiler Characteristics, Structures, Existing Tests @section Typedefs diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index 5bfaaacc..7eccd9a2 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1277,6 +1277,17 @@ define(AC_OBSOLETE, )]) +dnl ### Generic structure checks + +dnl Check if a particular structure member exists. +dnl AC_C_STRUCT_MEMBER(VARIABLE, INCLUDES, TYPE, MEMBER) +AC_DEFUN(AC_C_STRUCT_MEMBER, +[AC_CACHE_CHECK([for member $4 in aggregate type $3],ac_cv_c_struct_member_$1, + [AC_TRY_COMPILE([$2], [$3 foo; foo.$4;], + ac_cv_c_struct_member_$1=yes,ac_cv_c_struct_member_$1=no)]) +$1="$ac_cv_c_struct_member_$1"]) + + dnl ### Checking for programs diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 21b1fa5e..da9ba74e 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -1733,11 +1733,9 @@ fi AC_DEFUN(AC_STRUCT_TIMEZONE, [AC_REQUIRE([AC_STRUCT_TM])dnl -AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone, -[AC_TRY_COMPILE([#include -#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], - ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)]) -if test "$ac_cv_struct_tm_zone" = yes; then +AC_C_STRUCT_MEMBER(tm_zone, [#include +#include <$ac_cv_struct_tm>], [struct tm], tm_zone) +if test "$ac_cv_c_struct_member_tm_zone" = yes; then AC_DEFINE(HAVE_TM_ZONE) else AC_CACHE_CHECK(for tzname, ac_cv_var_tzname, @@ -1756,11 +1754,9 @@ fi ]) AC_DEFUN(AC_STRUCT_ST_BLOCKS, -[AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks, -[AC_TRY_COMPILE([#include -#include ], [struct stat s; s.st_blocks;], -ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)]) -if test $ac_cv_struct_st_blocks = yes; then +[AC_C_STRUCT_MEMBER(st_blocks, [#include +#include ], [struct stat], st_blocks) +if test $ac_cv_c_struct_member_st_blocks = yes; then AC_DEFINE(HAVE_ST_BLOCKS) else LIBOBJS="$LIBOBJS fileblocks.${ac_objext}" @@ -1769,21 +1765,17 @@ AC_SUBST(LIBOBJS)dnl ]) AC_DEFUN(AC_STRUCT_ST_BLKSIZE, -[AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize, -[AC_TRY_COMPILE([#include -#include ], [struct stat s; s.st_blksize;], -ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)]) -if test $ac_cv_struct_st_blksize = yes; then +[AC_C_STRUCT_MEMBER(st_blksize, [#include +#include ], [struct stat], st_blksize) +if test $ac_cv_c_struct_member_st_blksize = yes; then AC_DEFINE(HAVE_ST_BLKSIZE) fi ]) AC_DEFUN(AC_STRUCT_ST_RDEV, -[AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev, -[AC_TRY_COMPILE([#include -#include ], [struct stat s; s.st_rdev;], -ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)]) -if test $ac_cv_struct_st_rdev = yes; then +[AC_C_STRUCT_MEMBER(st_rdev, [#include +#include ], [struct stat], st_rdev) +if test $ac_cv_c_struct_member_st_rdev = yes; then AC_DEFINE(HAVE_ST_RDEV) fi ])