add description
[gnulib.git] / m4 / chown.m4
1 #serial 1
2
3 dnl From Jim Meyering.
4 dnl Determine whether chown accepts arguments of -1 for gid and uid.
5 dnl If it doesn't, arrange to use the replacement function.
6 dnl
7 dnl If you use this macro in a package, you should
8 dnl add the following two lines to acconfig.h:
9 dnl  /* Define to rpl_chown if the replacement function should be used.  */
10 dnl  #undef chown
11 dnl
12
13 AC_DEFUN(jm_FUNC_CHOWN,
14 [AC_REQUIRE([AC_TYPE_UID_T])dnl
15  test -z "$ac_cv_header_unistd_h" \
16    && AC_CHECK_HEADERS(unistd.h)
17  AC_CACHE_CHECK([for working chown], jm_cv_func_working_chown,
18   [AC_TRY_RUN([
19 #   include <sys/types.h>
20 #   include <fcntl.h>
21 #   ifdef HAVE_UNISTD_H
22 #    include <unistd.h>
23 #   endif
24
25     int
26     main ()
27     {
28       char *f = "conftestchown";
29       if (creat (f, 0600) < 0)
30         exit (1);
31       exit (chown (f, (gid_t) -1, (uid_t) -1) == -1 ? 1 : 0);
32     }
33               ],
34              jm_cv_func_working_chown=yes,
35              jm_cv_func_working_chown=no,
36              dnl When crosscompiling, assume chown is broken.
37              jm_cv_func_working_chown=no)
38   ])
39   if test $jm_cv_func_working_chown = no; then
40     LIBOBJS="$LIBOBJS chown.o"
41     AC_DEFINE_UNQUOTED(chown, rpl_chown)
42   fi
43 ])