xref: /netbsd-src/external/gpl3/gdb/dist/gnulib/import/m4/glob_h.m4 (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
1# glob_h.m4 serial 9
2dnl Copyright (C) 2018-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9AC_DEFUN_ONCE([gl_GLOB_H],
10[
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])
16
17  if test $ac_cv_header_glob_h = yes; then
18    HAVE_GLOB_H=1
19  else
20    HAVE_GLOB_H=0
21  fi
22  AC_SUBST([HAVE_GLOB_H])
23
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
30     else
31       if test $ac_cv_header_glob_h != yes; then
32         dnl Provide a substitute <glob.h> file.
33         GL_GENERATE_GLOB_H=true
34       fi
35     fi
36    ])
37
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>
41    ]],
42    [glob globfree glob_pattern_p])
43])
44
45dnl Unconditionally enables the replacement of <glob.h>.
46AC_DEFUN([gl_REPLACE_GLOB_H],
47[
48  gl_GLOB_H_REQUIRE_DEFAULTS
49  GL_GENERATE_GLOB_H=true
50])
51
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.
56AC_DEFUN([gl_GLOB_MODULE_INDICATOR],
57[
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])
63])
64
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.
68AC_DEFUN([gl_GLOB_H_REQUIRE_DEFAULTS],
69[
70  m4_defun(GL_MODULE_INDICATOR_PREFIX[_GLOB_H_MODULE_INDICATOR_DEFAULTS], [
71    gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GLOB])
72  ])
73  m4_require(GL_MODULE_INDICATOR_PREFIX[_GLOB_H_MODULE_INDICATOR_DEFAULTS])
74  AC_REQUIRE([gl_GLOB_H_DEFAULTS])
75])
76
77AC_DEFUN([gl_GLOB_H_DEFAULTS],
78[
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])
84])
85