4 dnl Determine whether chown accepts arguments of -1 for uid and gid.
5 dnl If it doesn't, arrange to use the replacement function.
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. */
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,
19 # include <sys/types.h>
20 # include <sys/stat.h>
29 char *f = "conftestchown";
30 struct stat before, after;
32 if (creat (f, 0600) < 0)
34 if (stat (f, &before) < 0)
36 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
38 if (stat (f, &after) < 0)
40 exit ((before.st_uid == after.st_uid
41 && before.st_gid == after.st_gid) ? 0 : 1);
44 jm_cv_func_working_chown=yes,
45 jm_cv_func_working_chown=no,
46 dnl When crosscompiling, assume chown is broken.
47 jm_cv_func_working_chown=no)
49 if test $jm_cv_func_working_chown = no; then
50 LIBOBJS="$LIBOBJS chown.o"
51 AC_DEFINE_UNQUOTED(chown, rpl_chown)