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