Debian Codegraph @

tools/gnulib/m4/stat.m4

raw
1 # stat.m4
2 # serial 21
3 dnl Copyright (C) 2009-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
8 AC_DEFUN([gl_FUNC_STAT],
9 [
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
12 AC_CHECK_FUNCS_ONCE([lstat])
13 case "$host_os" in
14 mingw* | windows*)
15 dnl On this platform, the original stat() returns st_atime, st_mtime,
16 dnl st_ctime values that are affected by the time zone.
17 REPLACE_STAT=1
18 ;;
19 *)
20 dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
21 dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
22 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
23 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
24 [gl_cv_func_stat_file_slash],
25 [touch conftest.tmp
26 # Assume that if we have lstat, we can also check symlinks.
27 if test $ac_cv_func_lstat = yes; then
28 ln -s conftest.tmp conftest.lnk
29 fi
30 AC_RUN_IFELSE(
31 [AC_LANG_PROGRAM(
32 [[#include <sys/stat.h>
33 ]], [[int result = 0;
34 struct stat st;
35 if (!stat ("conftest.tmp/", &st))
36 result |= 1;
37 #if HAVE_LSTAT
38 if (!stat ("conftest.lnk/", &st))
39 result |= 2;
40 #endif
41 return result;
42 ]])],
43 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
44 [case "$host_os" in
45 # Guess yes on Linux systems.
46 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
47 # Guess yes on systems that emulate the Linux system calls.
48 midipix*) gl_cv_func_stat_file_slash="guessing yes" ;;
49 # Guess yes on glibc systems.
50 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
51 # If we don't know, obey --enable-cross-guesses.
52 *) gl_cv_func_stat_file_slash="$gl_cross_guess_normal" ;;
53 esac
54 ])
55 rm -f conftest.tmp conftest.lnk])
56 case $gl_cv_func_stat_file_slash in
57 *no)
58 REPLACE_STAT=1
59 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
60 help when passed a file name with a trailing slash]);;
61 esac
62 case $host_os in
63 dnl macOS and Solaris stat can return a negative tv_nsec.
64 darwin* | solaris*)
65 REPLACE_FSTAT=1 ;;
66 esac
67 ;;
68 esac
69 ])
70
71 # Prerequisites of lib/stat.c and lib/stat-w32.c.
72 AC_DEFUN([gl_PREREQ_STAT], [
73 AC_REQUIRE([gl_SYS_STAT_H])
74 AC_REQUIRE([gl_PREREQ_STAT_W32])
75 :
76 ])
77
78 # Prerequisites of lib/stat-w32.c.
79 AC_DEFUN([gl_PREREQ_STAT_W32], [
80 AC_REQUIRE([AC_CANONICAL_HOST])
81 case "$host_os" in
82 mingw* | windows*)
83 AC_CHECK_HEADERS([sdkddkver.h])
84 ;;
85 esac
86 ])