Debian Codegraph @

m4/utime.m4

raw
1 # utime.m4 serial 4
2 dnl Copyright (C) 2017-2023 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.
6
7 AC_DEFUN([gl_FUNC_UTIME],
8 [
9 AC_REQUIRE([gl_UTIME_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([lstat])
12 case "$host_os" in
13 mingw*)
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).
19 REPLACE_UTIME=1
20 ;;
21 *)
22 AC_CHECK_FUNCS([utime])
23 if test $ac_cv_func_utime = no; then
24 HAVE_UTIME=0
25 else
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],
29 [touch conftest.tmp
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
33 fi
34 AC_RUN_IFELSE(
35 [AC_LANG_PROGRAM(
36 [[#include <stddef.h>
37 #include <utime.h>
38 ]],
39 [[int result = 0;
40 if (!utime ("conftest.tmp/", NULL))
41 result |= 1;
42 #if HAVE_LSTAT
43 if (!utime ("conftest.lnk/", NULL))
44 result |= 2;
45 #endif
46 return result;
47 ]])],
48 [gl_cv_func_utime_file_slash=yes],
49 [gl_cv_func_utime_file_slash=no],
50 [case "$host_os" in
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" ;;
55 # Guess no on macOS.
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" ;;
59 esac
60 ])
61 rm -f conftest.tmp conftest.lnk
62 ])
63 case $gl_cv_func_stat_file_slash in
64 *no)
65 REPLACE_UTIME=1
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])
68 ;;
69 esac
70 fi
71 ;;
72 esac
73 ])
74
75 # Prerequisites of lib/utime.c.
76 AC_DEFUN([gl_PREREQ_UTIME], [:])