*** empty log message ***
[gnulib.git] / m4 / utimes.m4
1 #serial 2
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([
9 /* In case stat has been defined to rpl_stat, undef it here.  */
10 #undef stat
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 main() {
14 struct stat s, t;
15 exit(!(stat ("conftestdata", &s) == 0 && utimes("conftestdata", (long *)0) == 0
16 && stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime
17 && t.st_mtime - s.st_mtime < 120));
18 }], ac_cv_func_utimes_null=yes, ac_cv_func_utimes_null=no,
19   ac_cv_func_utimes_null=no)
20 rm -f core core.* *.core])
21
22     if test $ac_cv_func_utimes_null = yes; then
23       if test x = y; then
24         # This code is deliberately never run via ./configure.
25         # FIXME: this is a hack to make autoheader put the corresponding
26         # HAVE_* undef for this symbol in config.h.in.  This saves me the
27         # trouble of having to maintain the #undef in acconfig.h manually.
28         AC_CHECK_FUNCS(UTIMES_NULL)
29       fi
30       # Defining it this way (rather than via AC_DEFINE) short-circuits the
31       # autoheader check -- autoheader doesn't know it's already been taken
32       # care of by the hack above.
33       ac_kludge=HAVE_UTIMES_NULL
34       AC_DEFINE_UNQUOTED($ac_kludge)
35     fi
36   ]
37 )