annotate m4/stat.m4 @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents d7562698c771
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19660
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
1 # serial 15
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
2
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19660
diff changeset
3 # Copyright (C) 2009-2019 Free Software Foundation, Inc.
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
4 #
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
5 # This file is free software; the Free Software Foundation
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
6 # gives unlimited permission to copy and/or distribute it,
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
7 # with or without modifications, as long as this notice is preserved.
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
8
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
9 AC_DEFUN([gl_FUNC_STAT],
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
10 [
18828
77ab0568b369 Fix a few typos.
Bruno Haible <bruno@clisp.org>
parents: 18826
diff changeset
11 AC_REQUIRE([AC_CANONICAL_HOST])
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
13 AC_CHECK_FUNCS_ONCE([lstat])
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
14 case "$host_os" in
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
15 mingw*)
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
16 dnl On this platform, the original stat() returns st_atime, st_mtime,
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
17 dnl st_ctime values that are affected by the time zone.
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
18 REPLACE_STAT=1
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
19 ;;
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
20 *)
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
21 dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
22 dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
23 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
24 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
25 [gl_cv_func_stat_file_slash],
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
26 [touch conftest.tmp
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
27 # Assume that if we have lstat, we can also check symlinks.
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
28 if test $ac_cv_func_lstat = yes; then
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
29 ln -s conftest.tmp conftest.lnk
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
30 fi
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
31 AC_RUN_IFELSE(
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
32 [AC_LANG_PROGRAM(
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
33 [[#include <sys/stat.h>
13918
d5a74c6ec06b Put more information about failed tests into the test return codes.
Bruno Haible <bruno@clisp.org>
parents: 13499
diff changeset
34 ]], [[int result = 0;
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
35 struct stat st;
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
36 if (!stat ("conftest.tmp/", &st))
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
37 result |= 1;
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
38 #if HAVE_LSTAT
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
39 if (!stat ("conftest.lnk/", &st))
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
40 result |= 2;
12258
150adbe92b27 stat: detect FreeBSD bug
Eric Blake <ebb9@byu.net>
parents: 12037
diff changeset
41 #endif
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
42 return result;
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
43 ]])],
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
44 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
45 [case "$host_os" in
19660
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
46 # Guess yes on Linux systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
47 linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
48 # Guess yes on glibc systems.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
49 *-gnu* | gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
50 # If we don't know, assume the worst.
d7562698c771 Add cross-compilation guesses for Linux systems without glibc.
Bruno Haible <bruno@clisp.org>
parents: 19484
diff changeset
51 *) gl_cv_func_stat_file_slash="guessing no" ;;
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
52 esac
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
53 ])
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
54 rm -f conftest.tmp conftest.lnk])
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
55 case $gl_cv_func_stat_file_slash in
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
56 *no)
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
57 REPLACE_STAT=1
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
58 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
59 help when passed a file name with a trailing slash]);;
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
60 esac
19447
2d6db3f14060 stat: work around Solaris bug with tv_nsec < 0
Paul Eggert <eggert@cs.ucla.edu>
parents: 18828
diff changeset
61 case $host_os in
2d6db3f14060 stat: work around Solaris bug with tv_nsec < 0
Paul Eggert <eggert@cs.ucla.edu>
parents: 18828
diff changeset
62 dnl Solaris stat can return a negative tv_nsec.
2d6db3f14060 stat: work around Solaris bug with tv_nsec < 0
Paul Eggert <eggert@cs.ucla.edu>
parents: 18828
diff changeset
63 solaris*)
2d6db3f14060 stat: work around Solaris bug with tv_nsec < 0
Paul Eggert <eggert@cs.ucla.edu>
parents: 18828
diff changeset
64 REPLACE_FSTAT=1 ;;
2d6db3f14060 stat: work around Solaris bug with tv_nsec < 0
Paul Eggert <eggert@cs.ucla.edu>
parents: 18828
diff changeset
65 esac
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
66 ;;
12037
eb6b9da995d7 stat: fix Solaris 9 bug
Eric Blake <ebb9@byu.net>
parents: 12036
diff changeset
67 esac
12036
1762604ec0a7 stat: new module, for mingw bug
Eric Blake <ebb9@byu.net>
parents:
diff changeset
68 ])
15097
93a1703f75df stat: Move AC_LIBOBJ invocations to module description.
Bruno Haible <bruno@clisp.org>
parents: 14393
diff changeset
69
18826
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
70 # Prerequisites of lib/stat.c and lib/stat-w32.c.
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
71 AC_DEFUN([gl_PREREQ_STAT], [
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
72 AC_REQUIRE([gl_HEADER_SYS_STAT_H])
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
73 :
e52a680db3d0 stat: Fix time_t values and other problems on native Windows platforms.
Bruno Haible <bruno@clisp.org>
parents: 18626
diff changeset
74 ])