annotate m4/getgroups.m4 @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 57d3bf2ca96d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39934
57d3bf2ca96d fsusage, mountlist, getloadavg, getgroups: Remove support for Ultrix.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
1 # serial 21
820
7d99d39333e1 broken out of ../acinclude.m4
Jim Meyering <jim@meyering.net>
parents:
diff changeset
2
7d99d39333e1 broken out of ../acinclude.m4
Jim Meyering <jim@meyering.net>
parents:
diff changeset
3 dnl From Jim Meyering.
4565
57ddc0368e92 (jm_FUNC_GETGROUPS): Rewrite to use AC_FUNC_GETGROUPS
Paul Eggert <eggert@cs.ucla.edu>
parents: 4108
diff changeset
4 dnl A wrapper around AC_FUNC_GETGROUPS.
820
7d99d39333e1 broken out of ../acinclude.m4
Jim Meyering <jim@meyering.net>
parents:
diff changeset
5
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 39934
diff changeset
6 # Copyright (C) 1996-1997, 1999-2004, 2008-2019 Free Software Foundation, Inc.
5611
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5016
diff changeset
7 #
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5016
diff changeset
8 # This file is free software; the Free Software Foundation
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5016
diff changeset
9 # gives unlimited permission to copy and/or distribute it,
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5016
diff changeset
10 # with or without modifications, as long as this notice is preserved.
87c42e194f4a Use an all-permissive copyright notice, recommended by RMS.
Paul Eggert <eggert@cs.ucla.edu>
parents: 5016
diff changeset
11
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
12 m4_version_prereq([2.70], [] ,[
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
13
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
14 # This is taken from the following Autoconf patch:
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 # https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
16 AC_DEFUN([AC_FUNC_GETGROUPS],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
17 [
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
18 AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
19 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
20 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
21 AC_CHECK_FUNC([getgroups])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
22
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
23 # If we don't yet have getgroups, see if it's in -lbsd.
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
24 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
25 ac_save_LIBS=$LIBS
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
26 if test $ac_cv_func_getgroups = no; then
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
27 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
28 fi
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
29
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
30 # Run the program to test the functionality of the system-supplied
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
31 # getgroups function only if there is such a function.
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
32 if test $ac_cv_func_getgroups = yes; then
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
33 AC_CACHE_CHECK([for working getgroups], [ac_cv_func_getgroups_works],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
34 [AC_RUN_IFELSE(
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
35 [AC_LANG_PROGRAM(
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
36 [AC_INCLUDES_DEFAULT],
39934
57d3bf2ca96d fsusage, mountlist, getloadavg, getgroups: Remove support for Ultrix.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
37 [[/* On NeXTstep 3.2, getgroups (0, 0) always fails. */
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
38 return getgroups (0, 0) == -1;]])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
39 ],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
40 [ac_cv_func_getgroups_works=yes],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
41 [ac_cv_func_getgroups_works=no],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
42 [case "$host_os" in # ((
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
43 # Guess yes on glibc systems.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
44 *-gnu* | gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
45 # If we don't know, assume the worst.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
46 *) ac_cv_func_getgroups_works="guessing no" ;;
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
47 esac
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
48 ])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
49 ])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
50 else
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
51 ac_cv_func_getgroups_works=no
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
52 fi
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
53 case "$ac_cv_func_getgroups_works" in
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
54 *yes)
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
55 AC_DEFINE([HAVE_GETGROUPS], [1],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
56 [Define to 1 if your system has a working `getgroups' function.])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
57 ;;
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
58 esac
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
59 LIBS=$ac_save_LIBS
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
60 ])# AC_FUNC_GETGROUPS
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
61
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
62 ])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
63
5016
7141ea4946af Change jm_ to gl_ in AC_DEFINE'd names. Update all uses.
Jim Meyering <jim@meyering.net>
parents: 4565
diff changeset
64 AC_DEFUN([gl_FUNC_GETGROUPS],
4108
c1d472db5c30 An independent .m4 file for each module.
Bruno Haible <bruno@clisp.org>
parents: 3486
diff changeset
65 [
12279
6a41b8f5f874 getgroups, getugroups: provide stubs for mingw
Eric Blake <ebb9@byu.net>
parents: 11007
diff changeset
66 AC_REQUIRE([AC_TYPE_GETGROUPS])
6a41b8f5f874 getgroups, getugroups: provide stubs for mingw
Eric Blake <ebb9@byu.net>
parents: 11007
diff changeset
67 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
16811
b187fc49964b Avoid "guessing no" guesses when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
68 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
69
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
70 AC_FUNC_GETGROUPS
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
71 if test $ac_cv_func_getgroups != yes; then
12279
6a41b8f5f874 getgroups, getugroups: provide stubs for mingw
Eric Blake <ebb9@byu.net>
parents: 11007
diff changeset
72 HAVE_GETGROUPS=0
12284
fcf83d7e45e4 getgroups: work around FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12280
diff changeset
73 else
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
74 if test "$ac_cv_type_getgroups" != gid_t \
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
75 || { case "$ac_cv_func_getgroups_works" in
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
76 *yes) false;;
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
77 *) true;;
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
78 esac
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
79 }; then
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
80 REPLACE_GETGROUPS=1
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
81 AC_DEFINE([GETGROUPS_ZERO_BUG], [1], [Define this to 1 if
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
82 getgroups(0,NULL) does not return the number of groups.])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
83 else
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
84 dnl Detect FreeBSD bug; POSIX requires getgroups(-1,ptr) to fail.
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
85 AC_CACHE_CHECK([whether getgroups handles negative values],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
86 [gl_cv_func_getgroups_works],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
87 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
88 [[int size = getgroups (0, 0);
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
89 gid_t *list = malloc (size * sizeof *list);
18240
8f47f3e77c8e misc: port better to gcc -fsanitize=address
Paul Eggert <eggert@cs.ucla.edu>
parents: 18189
diff changeset
90 int result = getgroups (-1, list) != -1;
8f47f3e77c8e misc: port better to gcc -fsanitize=address
Paul Eggert <eggert@cs.ucla.edu>
parents: 18189
diff changeset
91 free (list);
8f47f3e77c8e misc: port better to gcc -fsanitize=address
Paul Eggert <eggert@cs.ucla.edu>
parents: 18189
diff changeset
92 return result;]])],
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
93 [gl_cv_func_getgroups_works=yes],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
94 [gl_cv_func_getgroups_works=no],
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
95 [case "$host_os" in
19479
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
96 # Guess yes on glibc systems.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
97 *-gnu* | gnu*) gl_cv_func_getgroups_works="guessing yes" ;;
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
98 # If we don't know, assume the worst.
4bc5b8cefed7 Add cross-compilation results for GNU/Hurd.
Samuel Thibault <samuel.thibault@gnu.org>
parents: 19190
diff changeset
99 *) gl_cv_func_getgroups_works="guessing no" ;;
16814
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
100 esac
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
101 ])])
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
102 case "$gl_cv_func_getgroups_works" in
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
103 *yes) ;;
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
104 *) REPLACE_GETGROUPS=1 ;;
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
105 esac
8fa37454b38b getgroups: Avoid "guessing no" when cross-compiling to glibc systems.
Bruno Haible <bruno@clisp.org>
parents: 16811
diff changeset
106 fi
820
7d99d39333e1 broken out of ../acinclude.m4
Jim Meyering <jim@meyering.net>
parents:
diff changeset
107 fi
4565
57ddc0368e92 (jm_FUNC_GETGROUPS): Rewrite to use AC_FUNC_GETGROUPS
Paul Eggert <eggert@cs.ucla.edu>
parents: 4108
diff changeset
108 test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS"
820
7d99d39333e1 broken out of ../acinclude.m4
Jim Meyering <jim@meyering.net>
parents:
diff changeset
109 ])