open.m4 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # open.m4 serial 5
  2. dnl Copyright (C) 2007-2009 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. AC_DEFUN([gl_FUNC_OPEN],
  7. [
  8. AC_REQUIRE([AC_CANONICAL_HOST])
  9. case "$host_os" in
  10. mingw* | pw*)
  11. gl_REPLACE_OPEN
  12. ;;
  13. *)
  14. dnl open("foo/") should not create a file when the file name has a
  15. dnl trailing slash.
  16. AC_CACHE_CHECK([whether open recognizes a trailing slash],
  17. [gl_cv_func_open_slash],
  18. [
  19. AC_TRY_RUN([
  20. #include <fcntl.h>
  21. #if HAVE_UNISTD_H
  22. # include <unistd.h>
  23. #endif
  24. int main ()
  25. {
  26. return open ("conftest.sl/", O_CREAT, 0600) >= 0;
  27. }], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
  28. [
  29. changequote(,)dnl
  30. case "$host_os" in
  31. solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
  32. hpux*) gl_cv_func_open_slash="guessing no" ;;
  33. *) gl_cv_func_open_slash="guessing yes" ;;
  34. esac
  35. changequote([,])dnl
  36. ])
  37. rm -f conftest.sl
  38. ])
  39. case "$gl_cv_func_open_slash" in
  40. *no)
  41. AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
  42. [Define to 1 if open() fails to recognize a trailing slash.])
  43. gl_REPLACE_OPEN
  44. ;;
  45. esac
  46. ;;
  47. esac
  48. ])
  49. AC_DEFUN([gl_REPLACE_OPEN],
  50. [
  51. AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
  52. if test $REPLACE_OPEN != 1; then
  53. AC_LIBOBJ([open])
  54. gl_PREREQ_OPEN
  55. fi
  56. REPLACE_OPEN=1
  57. ])
  58. # Prerequisites of lib/open.c.
  59. AC_DEFUN([gl_PREREQ_OPEN],
  60. [
  61. AC_REQUIRE([AC_C_INLINE])
  62. :
  63. ])