Debian Codegraph @

m4/dirent_h.m4

raw
1 # dirent_h.m4 serial 20
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
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 gl_DIRENT_DIR
25
26 dnl Check for declarations of anything we want to poison if the
27 dnl corresponding gnulib module is not in use.
28 gl_WARN_ON_USE_PREPARE([[#include <dirent.h>
29 ]], [alphasort closedir dirfd fdopendir opendir readdir rewinddir scandir])
30 ])
31
32 dnl Determine whether <dirent.h> needs to override the DIR type.
33 AC_DEFUN_ONCE([gl_DIRENT_DIR],
34 [
35 dnl Set DIR_HAS_FD_MEMBER if dirfd() works, i.e. not always returns -1,
36 dnl or has the __KLIBC__ workaround as in lib/dirfd.c.
37 dnl We could use the findings from gl_FUNC_DIRFD and gl_PREREQ_DIRFD, but
38 dnl it's simpler since we know the affected platforms.
39 AC_REQUIRE([AC_CANONICAL_HOST])
40 case "$host_os" in
41 mingw*) DIR_HAS_FD_MEMBER=0 ;;
42 *) DIR_HAS_FD_MEMBER=1 ;;
43 esac
44 AC_SUBST([DIR_HAS_FD_MEMBER])
45 ])
46
47 # gl_DIRENT_MODULE_INDICATOR([modulename])
48 # sets the shell variable that indicates the presence of the given module
49 # to a C preprocessor expression that will evaluate to 1.
50 # This macro invocation must not occur in macros that are AC_REQUIREd.
51 AC_DEFUN([gl_DIRENT_MODULE_INDICATOR],
52 [
53 dnl Ensure to expand the default settings once only.
54 gl_DIRENT_H_REQUIRE_DEFAULTS
55 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
56 dnl Define it also as a C macro, for the benefit of the unit tests.
57 gl_MODULE_INDICATOR_FOR_TESTS([$1])
58 ])
59
60 # Initializes the default values for AC_SUBSTed shell variables.
61 # This macro must not be AC_REQUIREd. It must only be invoked, and only
62 # outside of macros or in macros that are not AC_REQUIREd.
63 AC_DEFUN([gl_DIRENT_H_REQUIRE_DEFAULTS],
64 [
65 m4_defun(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS], [
66 gl_UNISTD_H_REQUIRE_DEFAULTS dnl for REPLACE_FCHDIR
67 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_OPENDIR])
68 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READDIR])
69 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_REWINDDIR])
70 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSEDIR])
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DIRFD])
72 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDOPENDIR])
73 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SCANDIR])
74 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ALPHASORT])
75 ])
76 m4_require(GL_MODULE_INDICATOR_PREFIX[_DIRENT_H_MODULE_INDICATOR_DEFAULTS])
77 AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
78 ])
79
80 AC_DEFUN([gl_DIRENT_H_DEFAULTS],
81 [
82 dnl Assume proper GNU behavior unless another module says otherwise.
83 HAVE_OPENDIR=1; AC_SUBST([HAVE_OPENDIR])
84 HAVE_READDIR=1; AC_SUBST([HAVE_READDIR])
85 HAVE_REWINDDIR=1; AC_SUBST([HAVE_REWINDDIR])
86 HAVE_CLOSEDIR=1; AC_SUBST([HAVE_CLOSEDIR])
87 HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD])
88 HAVE_DECL_FDOPENDIR=1;AC_SUBST([HAVE_DECL_FDOPENDIR])
89 HAVE_FDOPENDIR=1; AC_SUBST([HAVE_FDOPENDIR])
90 HAVE_SCANDIR=1; AC_SUBST([HAVE_SCANDIR])
91 HAVE_ALPHASORT=1; AC_SUBST([HAVE_ALPHASORT])
92 REPLACE_OPENDIR=0; AC_SUBST([REPLACE_OPENDIR])
93 REPLACE_READDIR=0; AC_SUBST([REPLACE_READDIR])
94 REPLACE_REWINDDIR=0; AC_SUBST([REPLACE_REWINDDIR])
95 REPLACE_CLOSEDIR=0; AC_SUBST([REPLACE_CLOSEDIR])
96 REPLACE_DIRFD=0; AC_SUBST([REPLACE_DIRFD])
97 REPLACE_FDOPENDIR=0; AC_SUBST([REPLACE_FDOPENDIR])
98 ])