| 1 |
# dirent_h.m4 |
| 2 |
# serial 22 |
| 3 |
dnl Copyright (C) 2008-2024 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
dnl Written by Bruno Haible. |
| 10 |
|
| 11 |
AC_DEFUN_ONCE([gl_DIRENT_H], |
| 12 |
[ |
| 13 |
dnl Ensure to expand the default settings once only, before all statements |
| 14 |
dnl that occur in other macros. |
| 15 |
AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) |
| 16 |
|
| 17 |
dnl <dirent.h> is always overridden, because of GNULIB_POSIXCHECK. |
| 18 |
gl_CHECK_NEXT_HEADERS([dirent.h]) |
| 19 |
if test $ac_cv_header_dirent_h = yes; then |
| 20 |
HAVE_DIRENT_H=1 |
| 21 |
else |
| 22 |
HAVE_DIRENT_H=0 |
| 23 |
fi |
| 24 |
AC_SUBST([HAVE_DIRENT_H]) |
| 25 |
|
| 26 |
gl_DIRENT_DIR |
| 27 |
|
| 28 |
dnl Check for declarations of anything we want to poison if the |
| 29 |
dnl corresponding gnulib module is not in use. |
| 30 |
gl_WARN_ON_USE_PREPARE([[#include <dirent.h> |
| 31 |
]], [alphasort closedir dirfd fdopendir opendir readdir rewinddir scandir]) |
| 32 |
]) |
| 33 |
|
| 34 |
dnl Determine whether <dirent.h> needs to override the DIR type. |
| 35 |
AC_DEFUN_ONCE([gl_DIRENT_DIR], |
| 36 |
[ |
| 37 |
dnl Set DIR_HAS_FD_MEMBER if dirfd() works, i.e. not always returns -1. |
| 38 |
dnl We could use the findings from gl_FUNC_DIRFD and gl_PREREQ_DIRFD, but |
| 39 |
dnl it's simpler since we know the affected platforms. |
| 40 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 41 |
case "$host_os" in |
| 42 |
mingw* | windows* | os2*) DIR_HAS_FD_MEMBER=0 ;; |
| 43 |
*) DIR_HAS_FD_MEMBER=1 ;; |
| 44 |
esac |
| 45 |
AC_SUBST([DIR_HAS_FD_MEMBER]) |
| 46 |
]) |
| 47 |
|
| 48 |
# gl_DIRENT_MODULE_INDICATOR([modulename]) |
| 49 |
# sets the shell variable that indicates the presence of the given module |
| 50 |
# to a C preprocessor expression that will evaluate to 1. |
| 51 |
# This macro invocation must not occur in macros that are AC_REQUIREd. |
| 52 |
AC_DEFUN([gl_DIRENT_MODULE_INDICATOR], |
| 53 |
[ |
| 54 |
dnl Ensure to expand the default settings once only. |
| 55 |
gl_DIRENT_H_REQUIRE_DEFAULTS |
| 56 |
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
| 57 |
dnl Define it also as a C macro, for the benefit of the unit tests. |
| 58 |
gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
| 59 |
]) |
| 60 |
|
| 61 |
# Initializes the default values for AC_SUBSTed shell variables. |
| 62 |
# This macro must not be AC_REQUIREd. It must only be invoked, and only |
| 63 |
# outside of macros or in macros that are not AC_REQUIREd. |
| 64 |
AC_DEFUN([gl_DIRENT_H_REQUIRE_DEFAULTS], |
| 65 |
[ |
| 66 |
m4_defun(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS], [ |
| 67 |
gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR |
| 68 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENDIR]) |
| 69 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READDIR]) |
| 70 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REWINDDIR]) |
| 71 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSEDIR]) |
| 72 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DIRFD]) |
| 73 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPENDIR]) |
| 74 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANDIR]) |
| 75 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALPHASORT]) |
| 76 |
]) |
| 77 |
m4_require(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS]) |
| 78 |
AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) |
| 79 |
]) |
| 80 |
|
| 81 |
AC_DEFUN([gl_DIRENT_H_DEFAULTS], |
| 82 |
[ |
| 83 |
dnl Assume proper GNU behavior unless another module says otherwise. |
| 84 |
HAVE_OPENDIR=1; AC_SUBST([HAVE_OPENDIR]) |
| 85 |
HAVE_READDIR=1; AC_SUBST([HAVE_READDIR]) |
| 86 |
HAVE_REWINDDIR=1; AC_SUBST([HAVE_REWINDDIR]) |
| 87 |
HAVE_CLOSEDIR=1; AC_SUBST([HAVE_CLOSEDIR]) |
| 88 |
HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD]) |
| 89 |
HAVE_DECL_FDOPENDIR=1;AC_SUBST([HAVE_DECL_FDOPENDIR]) |
| 90 |
HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR]) |
| 91 |
HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR]) |
| 92 |
HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT]) |
| 93 |
REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR]) |
| 94 |
REPLACE_READDIR=0; AC_SUBST([REPLACE_READDIR]) |
| 95 |
REPLACE_REWINDDIR=0; AC_SUBST([REPLACE_REWINDDIR]) |
| 96 |
REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR]) |
| 97 |
REPLACE_DIRFD=0; AC_SUBST([REPLACE_DIRFD]) |
| 98 |
REPLACE_FDOPENDIR=0; AC_SUBST([REPLACE_FDOPENDIR]) |
| 99 |
]) |