ChangeLog: add entry for "init.sh: automatically accommodate programs with the .exe...
[gnulib.git] / m4 / utime.m4
1 # serial 9
2
3 dnl From Jim Meyering
4 dnl Replace the utime function on systems that need it.
5
6 # Copyright (C) 1998, 2000-2001, 2003-2004, 2009-2010 Free Software Foundation,
7 # Inc.
8 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
11
12 dnl FIXME
13
14 AC_DEFUN([gl_FUNC_UTIME],
15 [
16   AC_REQUIRE([AC_FUNC_UTIME_NULL])
17   if test $ac_cv_func_utime_null = no; then
18     AC_LIBOBJ([utime])
19     AC_DEFINE([utime], [rpl_utime],
20       [Define to rpl_utime if the replacement function should be used.])
21     gl_PREREQ_UTIME
22   fi
23 ])
24
25 # Prerequisites of lib/utime.c.
26 AC_DEFUN([gl_PREREQ_UTIME],
27 [
28   AC_CHECK_HEADERS_ONCE([utime.h])
29   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
30   gl_FUNC_UTIMES_NULL
31 ])
32
33 # Use the definition of AC_FUNC_UTIME_NULL from autoconf 2.64 or newer.
34 # Remove this macro when we can assume autoconf >= 2.64.
35 m4_version_prereq([2.64], [], [
36 AC_DEFUN([AC_FUNC_UTIME_NULL],
37 [AC_CHECK_HEADERS_ONCE([utime.h])
38 AC_CACHE_CHECK([whether utime accepts a null argument], [ac_cv_func_utime_null],
39 [rm -f conftest.data; >conftest.data
40 # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
41 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
42                #ifdef HAVE_UTIME_H
43                # include <utime.h>
44                #endif],
45 [[struct stat s, t;
46   return ! (stat ("conftest.data", &s) == 0
47             && utime ("conftest.data", 0) == 0
48             && stat ("conftest.data", &t) == 0
49             && t.st_mtime >= s.st_mtime
50             && t.st_mtime - s.st_mtime < 120);]])],
51               ac_cv_func_utime_null=yes,
52               ac_cv_func_utime_null=no,
53               ac_cv_func_utime_null='guessing yes')])
54 if test "x$ac_cv_func_utime_null" != xno; then
55   ac_cv_func_utime_null=yes
56   AC_DEFINE([HAVE_UTIME_NULL], [1],
57             [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
58              present.])
59 fi
60 rm -f conftest.data
61 ])
62 ])