2 dnl Copyright (C) 2018-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.
9 AC_DEFUN_ONCE([gl_GLOB_H],
11 AC_REQUIRE([gl_GLOB_H_DEFAULTS])
12 m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])])
13 AC_REQUIRE([AC_C_RESTRICT])
14 AC_CHECK_HEADERS_ONCE([glob.h])
15 gl_CHECK_NEXT_HEADERS([glob.h])
17 if test $ac_cv_header_glob_h = yes; then
22 AC_SUBST([HAVE_GLOB_H])
24 m4_ifdef([gl_POSIXCHECK],
25 [GL_GENERATE_GLOB_H=true],
26 [GL_GENERATE_GLOB_H=false
27 if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then
28 dnl Override <glob.h> always, to support the C++ GNULIB_NAMESPACE.
29 GL_GENERATE_GLOB_H=true
31 if test $ac_cv_header_glob_h != yes; then
32 dnl Provide a substitute <glob.h> file.
33 GL_GENERATE_GLOB_H=true
38 dnl Check for declarations of anything we want to poison if the
39 dnl corresponding gnulib module is not in use.
40 gl_WARN_ON_USE_PREPARE([[#include <glob.h>
42 [glob globfree glob_pattern_p])
45 dnl Unconditionally enables the replacement of <glob.h>.
46 AC_DEFUN([gl_REPLACE_GLOB_H],
48 gl_GLOB_H_REQUIRE_DEFAULTS
49 GL_GENERATE_GLOB_H=true
52 # gl_GLOB_MODULE_INDICATOR([modulename])
53 # sets the shell variable that indicates the presence of the given module
54 # to a C preprocessor expression that will evaluate to 1.
55 # This macro invocation must not occur in macros that are AC_REQUIREd.
56 AC_DEFUN([gl_GLOB_MODULE_INDICATOR],
58 dnl Ensure to expand the default settings once only.
59 gl_GLOB_H_REQUIRE_DEFAULTS
60 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
61 dnl Define it also as a C macro, for the benefit of the unit tests.
62 gl_MODULE_INDICATOR_FOR_TESTS([$1])
65 # Initializes the default values for AC_SUBSTed shell variables.
66 # This macro must not be AC_REQUIREd. It must only be invoked, and only
67 # outside of macros or in macros that are not AC_REQUIREd.
68 AC_DEFUN([gl_GLOB_H_REQUIRE_DEFAULTS],
70 m4_defun(GL_MODULE_INDICATOR_PREFIX[_GLOB_H_MODULE_INDICATOR_DEFAULTS], [
71 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GLOB])
73 m4_require(GL_MODULE_INDICATOR_PREFIX[_GLOB_H_MODULE_INDICATOR_DEFAULTS])
74 AC_REQUIRE([gl_GLOB_H_DEFAULTS])
77 AC_DEFUN([gl_GLOB_H_DEFAULTS],
79 dnl Assume POSIX and GNU behavior unless another module says otherwise.
80 HAVE_GLOB=1; AC_SUBST([HAVE_GLOB])
81 HAVE_GLOB_PATTERN_P=1; AC_SUBST([HAVE_GLOB_PATTERN_P])
82 REPLACE_GLOB=0; AC_SUBST([REPLACE_GLOB])
83 REPLACE_GLOB_PATTERN_P=0; AC_SUBST([REPLACE_GLOB_PATTERN_P])