dirent_h.m4 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # dirent_h.m4 serial 19
  2. dnl Copyright (C) 2008-2023 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. dnl Written by Bruno Haible.
  7. AC_DEFUN_ONCE([gl_DIRENT_H],
  8. [
  9. dnl Ensure to expand the default settings once only, before all statements
  10. dnl that occur in other macros.
  11. AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
  12. dnl <dirent.h> is always overridden, because of GNULIB_POSIXCHECK.
  13. gl_CHECK_NEXT_HEADERS([dirent.h])
  14. if test $ac_cv_header_dirent_h = yes; then
  15. HAVE_DIRENT_H=1
  16. else
  17. HAVE_DIRENT_H=0
  18. fi
  19. AC_SUBST([HAVE_DIRENT_H])
  20. dnl Check for declarations of anything we want to poison if the
  21. dnl corresponding gnulib module is not in use.
  22. gl_WARN_ON_USE_PREPARE([[#include <dirent.h>
  23. ]], [alphasort closedir dirfd fdopendir opendir readdir rewinddir scandir])
  24. ])
  25. # gl_DIRENT_MODULE_INDICATOR([modulename])
  26. # sets the shell variable that indicates the presence of the given module
  27. # to a C preprocessor expression that will evaluate to 1.
  28. # This macro invocation must not occur in macros that are AC_REQUIREd.
  29. AC_DEFUN([gl_DIRENT_MODULE_INDICATOR],
  30. [
  31. dnl Ensure to expand the default settings once only.
  32. gl_DIRENT_H_REQUIRE_DEFAULTS
  33. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  34. dnl Define it also as a C macro, for the benefit of the unit tests.
  35. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  36. ])
  37. # Initializes the default values for AC_SUBSTed shell variables.
  38. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  39. # outside of macros or in macros that are not AC_REQUIREd.
  40. AC_DEFUN([gl_DIRENT_H_REQUIRE_DEFAULTS],
  41. [
  42. m4_defun(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS], [
  43. gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
  44. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENDIR])
  45. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READDIR])
  46. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REWINDDIR])
  47. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSEDIR])
  48. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DIRFD])
  49. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPENDIR])
  50. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANDIR])
  51. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALPHASORT])
  52. ])
  53. m4_require(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS])
  54. AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
  55. ])
  56. AC_DEFUN([gl_DIRENT_H_DEFAULTS],
  57. [
  58. dnl Assume proper GNU behavior unless another module says otherwise.
  59. HAVE_OPENDIR=1; AC_SUBST([HAVE_OPENDIR])
  60. HAVE_READDIR=1; AC_SUBST([HAVE_READDIR])
  61. HAVE_REWINDDIR=1; AC_SUBST([HAVE_REWINDDIR])
  62. HAVE_CLOSEDIR=1; AC_SUBST([HAVE_CLOSEDIR])
  63. HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD])
  64. HAVE_DECL_FDOPENDIR=1;AC_SUBST([HAVE_DECL_FDOPENDIR])
  65. HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR])
  66. HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR])
  67. HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT])
  68. REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR])
  69. REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR])
  70. REPLACE_DIRFD=0; AC_SUBST([REPLACE_DIRFD])
  71. REPLACE_FDOPENDIR=0; AC_SUBST([REPLACE_FDOPENDIR])
  72. ])