| 1 |
dnl |
| 2 |
dnl Copyright (C) 1996-2026 Free Software Foundation, Inc. |
| 3 |
dnl |
| 4 |
dnl This file is part of GNU Inetutils. |
| 5 |
dnl |
| 6 |
dnl GNU Inetutils is free software: you can redistribute it and/or modify |
| 7 |
dnl it under the terms of the GNU General Public License as published by |
| 8 |
dnl the Free Software Foundation, either version 3 of the License, or (at |
| 9 |
dnl your option) any later version. |
| 10 |
dnl |
| 11 |
dnl GNU Inetutils is distributed in the hope that it will be useful, but |
| 12 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
dnl General Public License for more details. |
| 15 |
dnl |
| 16 |
dnl You should have received a copy of the GNU General Public License |
| 17 |
dnl along with this program. If not, see `http://www.gnu.org/licenses/'. |
| 18 |
|
| 19 |
dnl Written by Miles Bader. |
| 20 |
|
| 21 |
dnl IU_CHECK_MEMBER(AGGREGATE.MEMBER, |
| 22 |
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], |
| 23 |
dnl [INCLUDES]) |
| 24 |
dnl AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos'. |
| 25 |
dnl The member itself can be of an aggregate type |
| 26 |
dnl Shell variables are not a valid argument. |
| 27 |
AC_DEFUN([IU_CHECK_MEMBER], |
| 28 |
[AS_LITERAL_IF([$1], [], |
| 29 |
[AC_FATAL([$0: requires literal arguments])])dnl |
| 30 |
m4_bmatch([$1], [\.], , |
| 31 |
[m4_fatal([$0: Did not see any dot in `$1'])])dnl |
| 32 |
AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl |
| 33 |
dnl Extract the aggregate name, and the member name |
| 34 |
AC_CACHE_CHECK([for $1], ac_Member, |
| 35 |
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT(IU_FLUSHLEFT([$4]))], |
| 36 |
[dnl AGGREGATE ac_aggr; |
| 37 |
static m4_bpatsubst([$1], [\..*]) ac_aggr; |
| 38 |
dnl ac_aggr.MEMBER; |
| 39 |
if (sizeof(ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))) |
| 40 |
return 0;])], |
| 41 |
[AS_VAR_SET(ac_Member, yes)], |
| 42 |
[AS_VAR_SET(ac_Member, no)])]) |
| 43 |
AS_IF([test AS_VAR_GET(ac_Member) = yes], [$2], [$3]) |
| 44 |
AS_VAR_POPDEF([ac_Member])dnl |
| 45 |
])dnl IU_CHECK_MEMBER |
| 46 |
|
| 47 |
|
| 48 |
dnl IU_CHECK_MEMBERS([AGGREGATE.MEMBER, ...], |
| 49 |
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND] |
| 50 |
dnl [INCLUDES]) |
| 51 |
AC_DEFUN([IU_CHECK_MEMBERS], |
| 52 |
[m4_foreach([AC_Member], [$1], |
| 53 |
[IU_CHECK_MEMBER(AC_Member, |
| 54 |
[AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1, |
| 55 |
[Define to 1 if `]m4_bpatsubst(AC_Member, |
| 56 |
[^[^.]*\.])[' is |
| 57 |
member of `]m4_bpatsubst(AC_Member, [\..*])['.]) |
| 58 |
$2], |
| 59 |
[$3], |
| 60 |
[$4])])]) |