immutable: Add tests.
[gnulib.git] / m4 / glob_h.m4
blobef4c9cc24693a03209a5aba6ba355cfc20f3c432
1 # glob_h.m4 serial 5
2 dnl Copyright (C) 2018-2021 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.
7 dnl From Bruno Haible.
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
18     HAVE_GLOB_H=1
19   else
20     HAVE_GLOB_H=0
21   fi
22   AC_SUBST([HAVE_GLOB_H])
24   m4_ifdef([gl_POSIXCHECK],
25     [GLOB_H=glob.h],
26     [GLOB_H=''
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        GLOB_H=glob.h
30      else
31        if test $ac_cv_header_glob_h != yes; then
32          dnl Provide a substitute <glob.h> file.
33          GLOB_H=glob.h
34        fi
35      fi
36     ])
37   AC_SUBST([GLOB_H])
38   AM_CONDITIONAL([GL_GENERATE_GLOB_H], [test -n "$GLOB_H"])
40   dnl Check for declarations of anything we want to poison if the
41   dnl corresponding gnulib module is not in use.
42   gl_WARN_ON_USE_PREPARE([[#include <glob.h>
43     ]],
44     [glob globfree glob_pattern_p])
47 dnl Unconditionally enables the replacement of <glob.h>.
48 AC_DEFUN([gl_REPLACE_GLOB_H],
50   AC_REQUIRE([gl_GLOB_H_DEFAULTS])
51   GLOB_H='glob.h'
52   AM_CONDITIONAL([GL_GENERATE_GLOB_H], [test -n "$GLOB_H"])
55 AC_DEFUN([gl_GLOB_MODULE_INDICATOR],
57   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
58   AC_REQUIRE([gl_GLOB_H_DEFAULTS])
59   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
60   dnl Define it also as a C macro, for the benefit of the unit tests.
61   gl_MODULE_INDICATOR_FOR_TESTS([$1])
64 AC_DEFUN([gl_GLOB_H_DEFAULTS],
66   GNULIB_GLOB=0;             AC_SUBST([GNULIB_GLOB])
67   dnl Assume POSIX and GNU behavior unless another module says otherwise.
68   HAVE_GLOB=1;               AC_SUBST([HAVE_GLOB])
69   HAVE_GLOB_PATTERN_P=1;     AC_SUBST([HAVE_GLOB_PATTERN_P])
70   REPLACE_GLOB=0;            AC_SUBST([REPLACE_GLOB])
71   REPLACE_GLOB_PATTERN_P=0;  AC_SUBST([REPLACE_GLOB_PATTERN_P])