Use AC_SUBST(LIBOBJS) since we set LIBOBJS.
[gnulib.git] / m4 / chown.m4
1 #serial 4
2
3 dnl From Jim Meyering.
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.
6 dnl
7
8 AC_DEFUN(jm_FUNC_CHOWN,
9 [AC_REQUIRE([AC_TYPE_UID_T])dnl
10  test -z "$ac_cv_header_unistd_h" \
11    && AC_CHECK_HEADERS(unistd.h)
12  AC_CACHE_CHECK([for working chown], jm_cv_func_working_chown,
13   [AC_TRY_RUN([
14 #   include <sys/types.h>
15 #   include <sys/stat.h>
16 #   include <fcntl.h>
17 #   ifdef HAVE_UNISTD_H
18 #    include <unistd.h>
19 #   endif
20
21     int
22     main ()
23     {
24       char *f = "conftestchown";
25       struct stat before, after;
26
27       if (creat (f, 0600) < 0)
28         exit (1);
29       if (stat (f, &before) < 0)
30         exit (1);
31       if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
32         exit (1);
33       if (stat (f, &after) < 0)
34         exit (1);
35       exit ((before.st_uid == after.st_uid
36              && before.st_gid == after.st_gid) ? 0 : 1);
37     }
38               ],
39              jm_cv_func_working_chown=yes,
40              jm_cv_func_working_chown=no,
41              dnl When crosscompiling, assume chown is broken.
42              jm_cv_func_working_chown=no)
43   ])
44   if test $jm_cv_func_working_chown = no; then
45     AC_SUBST(LIBOBJS)
46     LIBOBJS="$LIBOBJS chown.$ac_objext"
47     AC_DEFINE_UNQUOTED(chown, rpl_chown,
48       [Define to rpl_chown if the replacement function should be used.])
49   fi
50 ])