.
[gnulib.git] / m4 / utimes.m4
1 #serial 1
2
3 dnl Shamelessly cloned from acspecific.m4's AC_FUNC_UTIME_NULL.
4
5 AC_DEFUN(jm_FUNC_UTIMES_NULL,
6 [AC_CACHE_CHECK(whether utimes accepts a null argument, ac_cv_func_utimes_null,
7 [rm -f conftestdata; > conftestdata
8 AC_TRY_RUN([#include <sys/types.h>
9 #include <sys/stat.h>
10 main() {
11 struct stat s, t;
12 exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0
13 && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
14 && t.st_mtime - s.st_mtime < 120));
15 }], ac_cv_func_utimes_null=yes, ac_cv_func_utimes_null=no,
16   ac_cv_func_utimes_null=no)
17 rm -f core core.* *.core])
18
19     if test $ac_cv_func_utimes_null = yes; then
20       if test x = y; then
21         # This code is deliberately never run via ./configure.
22         # FIXME: this is a hack to make autoheader put the corresponding
23         # HAVE_* undef for this symbol in config.h.in.  This saves me the
24         # trouble of having to maintain the #undef in acconfig.h manually.
25         AC_CHECK_FUNCS(UTIMES_NULL)
26       fi
27       # Defining it this way (rather than via AC_DEFINE) short-circuits the
28       # autoheader check -- autoheader doesn't know it's already been taken
29       # care of by the hack above.
30       ac_kludge=HAVE_UTIMES_NULL
31       AC_DEFINE_UNQUOTED($ac_kludge)
32     fi
33   ]
34 )