4 dnl Replace the utime function on systems that need it.
6 # Copyright (C) 1998, 2000-2001, 2003-2004, 2009-2010 Free Software Foundation,
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.
14 AC_DEFUN([gl_FUNC_UTIME],
16 AC_REQUIRE([AC_FUNC_UTIME_NULL])
17 if test $ac_cv_func_utime_null = no; then
19 AC_DEFINE([utime], [rpl_utime],
20 [Define to rpl_utime if the replacement function should be used.])
25 # Prerequisites of lib/utime.c.
26 AC_DEFUN([gl_PREREQ_UTIME],
28 AC_CHECK_HEADERS_ONCE([utime.h])
29 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
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
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