c1e8dbf1e9b749a521cd2ed9aa837cb675327c4f
[gnulib.git] / m4 / getgroups.m4
1 #serial 1
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
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  # Run the program to test the functionality of the system-supplied
15  # getgroups function only if there is such a function.
16  if test $ac_cv_func_getgroups = yes; then
17    AC_CACHE_CHECK([for working getgroups], jm_cv_func_working_getgroups,
18     [AC_TRY_RUN([
19       int
20       main ()
21       {
22         /* On Ultrix 4.3, getgroups (0, 0) always fails.  */
23         exit (getgroups (0, 0) == -1 ? 1 : 0);
24       }
25                 ],
26                jm_cv_func_working_getgroups=yes,
27                jm_cv_func_working_getgroups=no,
28                dnl When crosscompiling, assume getgroups is broken.
29                jm_cv_func_working_getgroups=no)
30     ])
31     if test $jm_cv_func_working_getgroups = no; then
32       LIBOBJS="$LIBOBJS getgroups.o"
33       AC_DEFINE_UNQUOTED(getgroups, rpl_getgroups)
34     fi
35   fi
36 ])