stat.m4 2.8 KB

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