2 dnl Copyright (C) 2017-2020 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_FUNC_UTIME],
9 AC_REQUIRE([gl_UTIME_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([lstat])
14 dnl On this platform, the original utime() or _utime() produces
15 dnl timestamps that are affected by the time zone.
16 dnl Use the function name 'rpl_utime' always, in order to avoid a
17 dnl possible conflict with the function name 'utime' from oldnames.lib
18 dnl (MSVC) or liboldnames.a (mingw).
22 AC_CHECK_FUNCS([utime])
23 if test $ac_cv_func_utime = no; then
26 dnl On macOS 10.13, utime("link-to-file/", NULL) mistakenly succeeds.
27 AC_CACHE_CHECK([whether utime handles trailing slashes on files],
28 [gl_cv_func_utime_file_slash],
30 # Assume that if we have lstat, we can also check symlinks.
31 if test $ac_cv_func_lstat = yes; then
32 ln -s conftest.tmp conftest.lnk
40 if (!utime ("conftest.tmp/", NULL))
43 if (!utime ("conftest.lnk/", NULL))
48 [gl_cv_func_utime_file_slash=yes],
49 [gl_cv_func_utime_file_slash=no],
51 # Guess yes on Linux systems.
52 linux-* | linux) gl_cv_func_utime_file_slash="guessing yes" ;;
53 # Guess yes on glibc systems.
54 *-gnu* | gnu*) gl_cv_func_utime_file_slash="guessing yes" ;;
56 darwin*) gl_cv_func_utime_file_slash="guessing no" ;;
57 # If we don't know, obey --enable-cross-guesses.
58 *) gl_cv_func_utime_file_slash="$gl_cross_guess_normal" ;;
61 rm -f conftest.tmp conftest.lnk
63 case $gl_cv_func_stat_file_slash in
66 AC_DEFINE([REPLACE_FUNC_UTIME_FILE], [1],
67 [Define to 1 if utime needs help when passed a file name with a trailing slash])
75 # Prerequisites of lib/utime.c.
76 AC_DEFUN([gl_PREREQ_UTIME], [:])