fix typo in last change
[gnulib.git] / m4 / getgroups.m4
1 #serial 4
2
3 dnl From Jim Meyering.
4 dnl
5 dnl Invoking code should check $GETGROUPS_LIB something like this:
6 dnl  jm_FUNC_GETGROUPS
7 dnl  test -n "$GETGROUPS_LIB" && LIBS="$GETGROUPS_LIB $LIBS"
8 dnl
9
10 AC_DEFUN(jm_FUNC_GETGROUPS,
11 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
12  AC_REQUIRE([AC_TYPE_SIZE_T])dnl
13  AC_CHECK_FUNCS(getgroups)
14
15  # If we don't yet have getgroups, see if it's in -lbsd.
16  # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
17  if test $ac_cv_func_getgroups = no; then
18    jm_cv_sys_getgroups_saved_lib="$LIBS"
19    AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
20    LIBS="$jm_cv_sys_getgroups_saved_lib"
21  fi
22
23  # Run the program to test the functionality of the system-supplied
24  # getgroups function only if there is such a function.
25  if test $ac_cv_func_getgroups = yes; then
26    AC_CACHE_CHECK([for working getgroups], jm_cv_func_working_getgroups,
27     [AC_TRY_RUN([
28       int
29       main ()
30       {
31         /* On Ultrix 4.3, getgroups (0, 0) always fails.  */
32         exit (getgroups (0, 0) == -1 ? 1 : 0);
33       }
34                 ],
35                jm_cv_func_working_getgroups=yes,
36                jm_cv_func_working_getgroups=no,
37                dnl When crosscompiling, assume getgroups is broken.
38                jm_cv_func_working_getgroups=no)
39     ])
40     if test $jm_cv_func_working_getgroups = no; then
41       AC_LIBOBJ(getgroups)
42       AC_DEFINE_UNQUOTED(getgroups, rpl_getgroups,
43         [Define as rpl_getgroups if getgroups doesn't work right.])
44     fi
45   fi
46 ])