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