stat.m4 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # serial 8
  2. # Copyright (C) 2009-2011 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]) dnl for cross-compiles
  10. AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
  11. AC_CHECK_FUNCS_ONCE([lstat])
  12. dnl mingw is the only known platform where stat(".") and stat("./") differ
  13. AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
  14. [gl_cv_func_stat_dir_slash],
  15. [AC_RUN_IFELSE(
  16. [AC_LANG_PROGRAM(
  17. [[#include <sys/stat.h>
  18. ]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
  19. [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
  20. [case $host_os in
  21. mingw*) gl_cv_func_stat_dir_slash="guessing no";;
  22. *) gl_cv_func_stat_dir_slash="guessing yes";;
  23. esac])])
  24. dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/")
  25. dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
  26. AC_CACHE_CHECK([whether stat handles trailing slashes on files],
  27. [gl_cv_func_stat_file_slash],
  28. [touch conftest.tmp
  29. # Assume that if we have lstat, we can also check symlinks.
  30. if test $ac_cv_func_lstat = yes; then
  31. ln -s conftest.tmp conftest.lnk
  32. fi
  33. AC_RUN_IFELSE(
  34. [AC_LANG_PROGRAM(
  35. [[#include <sys/stat.h>
  36. ]], [[int result = 0;
  37. struct stat st;
  38. if (!stat ("conftest.tmp/", &st))
  39. result |= 1;
  40. #if HAVE_LSTAT
  41. if (!stat ("conftest.lnk/", &st))
  42. result |= 2;
  43. #endif
  44. return result;
  45. ]])],
  46. [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
  47. [gl_cv_func_stat_file_slash="guessing no"])
  48. rm -f conftest.tmp conftest.lnk])
  49. case $gl_cv_func_stat_dir_slash in
  50. *no) REPLACE_STAT=1
  51. AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
  52. help when passed a directory name with a trailing slash]);;
  53. esac
  54. case $gl_cv_func_stat_file_slash in
  55. *no) 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. ])
  60. # Prerequisites of lib/stat.c.
  61. AC_DEFUN([gl_PREREQ_STAT],
  62. [
  63. AC_REQUIRE([AC_C_INLINE])
  64. :
  65. ])