4 dnl Replace the utime function on systems that need it.
6 # Copyright (C) 1998, 2000-2001, 2003-2004, 2009 Free Software Foundation, Inc.
7 # This file is free software; the Free Software Foundation
8 # gives unlimited permission to copy and/or distribute it,
9 # with or without modifications, as long as this notice is preserved.
13 AC_DEFUN([gl_FUNC_UTIME],
15 AC_REQUIRE([AC_FUNC_UTIME_NULL])
16 if test $ac_cv_func_utime_null = no; then
18 AC_DEFINE([utime], [rpl_utime],
19 [Define to rpl_utime if the replacement function should be used.])
24 # Prerequisites of lib/utime.c.
25 AC_DEFUN([gl_PREREQ_UTIME],
27 AC_CHECK_HEADERS_ONCE([utime.h])
28 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_UTIMBUF])
32 # Use the definition of AC_FUNC_UTIME_NULL from autoconf 2.64 or newer.
33 # Remove this macro when we can assume autoconf >= 2.64.
34 m4_version_prereq([2.64], [], [
35 AC_DEFUN([AC_FUNC_UTIME_NULL],
36 [AC_CHECK_HEADERS_ONCE([utime.h])
37 AC_CACHE_CHECK([whether utime accepts a null argument], [ac_cv_func_utime_null],
38 [rm -f conftest.data; >conftest.data
39 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
40 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
45 return ! (stat ("conftest.data", &s) == 0
46 && utime ("conftest.data", 0) == 0
47 && stat ("conftest.data", &t) == 0
48 && t.st_mtime >= s.st_mtime
49 && t.st_mtime - s.st_mtime < 120);]])],
50 ac_cv_func_utime_null=yes,
51 ac_cv_func_utime_null=no,
52 ac_cv_func_utime_null='guessing yes')])
53 if test "x$ac_cv_func_utime_null" != xno; then
54 ac_cv_func_utime_null=yes
55 AC_DEFINE([HAVE_UTIME_NULL], [1],
56 [Define to 1 if `utime(file, NULL)' sets file's timestamp to the