| 1 |
# utime.m4 |
| 2 |
# serial 6 |
| 3 |
dnl Copyright (C) 2017-2024 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
AC_DEFUN([gl_FUNC_UTIME], |
| 10 |
[ |
| 11 |
AC_REQUIRE([gl_UTIME_H_DEFAULTS]) |
| 12 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 13 |
AC_CHECK_FUNCS_ONCE([lstat]) |
| 14 |
case "$host_os" in |
| 15 |
mingw* | windows*) |
| 16 |
dnl On this platform, the original utime() or _utime() produces |
| 17 |
dnl timestamps that are affected by the time zone. |
| 18 |
dnl Use the function name 'rpl_utime' always, in order to avoid a |
| 19 |
dnl possible conflict with the function name 'utime' from oldnames.lib |
| 20 |
dnl (MSVC) or liboldnames.a (mingw). |
| 21 |
REPLACE_UTIME=1 |
| 22 |
;; |
| 23 |
*) |
| 24 |
AC_CHECK_FUNCS([utime]) |
| 25 |
if test $ac_cv_func_utime = no; then |
| 26 |
HAVE_UTIME=0 |
| 27 |
else |
| 28 |
dnl On macOS 10.13, utime("link-to-file/", NULL) mistakenly succeeds. |
| 29 |
AC_CACHE_CHECK([whether utime handles trailing slashes on files], |
| 30 |
[gl_cv_func_utime_file_slash], |
| 31 |
[touch conftest.tmp |
| 32 |
# Assume that if we have lstat, we can also check symlinks. |
| 33 |
if test $ac_cv_func_lstat = yes; then |
| 34 |
ln -s conftest.tmp conftest.lnk |
| 35 |
fi |
| 36 |
AC_RUN_IFELSE( |
| 37 |
[AC_LANG_PROGRAM( |
| 38 |
[[#include <stddef.h> |
| 39 |
#include <utime.h> |
| 40 |
]], |
| 41 |
[[int result = 0; |
| 42 |
if (!utime ("conftest.tmp/", NULL)) |
| 43 |
result |= 1; |
| 44 |
#if HAVE_LSTAT |
| 45 |
if (!utime ("conftest.lnk/", NULL)) |
| 46 |
result |= 2; |
| 47 |
#endif |
| 48 |
return result; |
| 49 |
]])], |
| 50 |
[gl_cv_func_utime_file_slash=yes], |
| 51 |
[gl_cv_func_utime_file_slash=no], |
| 52 |
[case "$host_os" in |
| 53 |
# Guess yes on Linux systems |
| 54 |
# and on systems that emulate the Linux system calls. |
| 55 |
linux* | midipix*) gl_cv_func_utime_file_slash="guessing yes" ;; |
| 56 |
# Guess yes on glibc systems. |
| 57 |
*-gnu* | gnu*) gl_cv_func_utime_file_slash="guessing yes" ;; |
| 58 |
# Guess no on macOS. |
| 59 |
darwin*) gl_cv_func_utime_file_slash="guessing no" ;; |
| 60 |
# If we don't know, obey --enable-cross-guesses. |
| 61 |
*) gl_cv_func_utime_file_slash="$gl_cross_guess_normal" ;; |
| 62 |
esac |
| 63 |
]) |
| 64 |
rm -f conftest.tmp conftest.lnk |
| 65 |
]) |
| 66 |
case $gl_cv_func_stat_file_slash in |
| 67 |
*no) |
| 68 |
REPLACE_UTIME=1 |
| 69 |
AC_DEFINE([REPLACE_FUNC_UTIME_FILE], [1], |
| 70 |
[Define to 1 if utime needs help when passed a file name with a trailing slash]) |
| 71 |
;; |
| 72 |
esac |
| 73 |
fi |
| 74 |
;; |
| 75 |
esac |
| 76 |
]) |
| 77 |
|
| 78 |
# Prerequisites of lib/utime.c. |
| 79 |
AC_DEFUN([gl_PREREQ_UTIME], [:]) |