| 1 |
# glob_h.m4 |
| 2 |
# serial 9 |
| 3 |
dnl Copyright (C) 2018-2026 Free Software Foundation, Inc. |
| 4 |
dnl This file is free software; the Free Software Foundation |
| 5 |
dnl gives unlimited permission to copy and/or distribute it, |
| 6 |
dnl with or without modifications, as long as this notice is preserved. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
dnl From Bruno Haible. |
| 10 |
|
| 11 |
AC_DEFUN_ONCE([gl_GLOB_H], |
| 12 |
[ |
| 13 |
AC_REQUIRE([gl_GLOB_H_DEFAULTS]) |
| 14 |
m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])]) |
| 15 |
AC_REQUIRE([AC_C_RESTRICT]) |
| 16 |
AC_CHECK_HEADERS_ONCE([glob.h]) |
| 17 |
gl_CHECK_NEXT_HEADERS([glob.h]) |
| 18 |
|
| 19 |
if test $ac_cv_header_glob_h = yes; then |
| 20 |
HAVE_GLOB_H=1 |
| 21 |
else |
| 22 |
HAVE_GLOB_H=0 |
| 23 |
fi |
| 24 |
AC_SUBST([HAVE_GLOB_H]) |
| 25 |
|
| 26 |
m4_ifdef([gl_POSIXCHECK], |
| 27 |
[GL_GENERATE_GLOB_H=true], |
| 28 |
[GL_GENERATE_GLOB_H=false |
| 29 |
if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then |
| 30 |
dnl Override <glob.h> always, to support the C++ GNULIB_NAMESPACE. |
| 31 |
GL_GENERATE_GLOB_H=true |
| 32 |
else |
| 33 |
if test $ac_cv_header_glob_h != yes; then |
| 34 |
dnl Provide a substitute <glob.h> file. |
| 35 |
GL_GENERATE_GLOB_H=true |
| 36 |
fi |
| 37 |
fi |
| 38 |
]) |
| 39 |
|
| 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]) |
| 45 |
]) |
| 46 |
|
| 47 |
dnl Unconditionally enables the replacement of <glob.h>. |
| 48 |
AC_DEFUN([gl_REPLACE_GLOB_H], |
| 49 |
[ |
| 50 |
gl_GLOB_H_REQUIRE_DEFAULTS |
| 51 |
GL_GENERATE_GLOB_H=true |
| 52 |
]) |
| 53 |
|
| 54 |
# gl_GLOB_MODULE_INDICATOR([modulename]) |
| 55 |
# sets the shell variable that indicates the presence of the given module |
| 56 |
# to a C preprocessor expression that will evaluate to 1. |
| 57 |
# This macro invocation must not occur in macros that are AC_REQUIREd. |
| 58 |
AC_DEFUN([gl_GLOB_MODULE_INDICATOR], |
| 59 |
[ |
| 60 |
dnl Ensure to expand the default settings once only. |
| 61 |
gl_GLOB_H_REQUIRE_DEFAULTS |
| 62 |
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
| 63 |
dnl Define it also as a C macro, for the benefit of the unit tests. |
| 64 |
gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
| 65 |
]) |
| 66 |
|
| 67 |
# Initializes the default values for AC_SUBSTed shell variables. |
| 68 |
# This macro must not be AC_REQUIREd. It must only be invoked, and only |
| 69 |
# outside of macros or in macros that are not AC_REQUIREd. |
| 70 |
AC_DEFUN([gl_GLOB_H_REQUIRE_DEFAULTS], |
| 71 |
[ |
| 72 |
m4_defun(GL_MODULE_INDICATOR_PREFIX[_GLOB_H_MODULE_INDICATOR_DEFAULTS], [ |
| 73 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GLOB]) |
| 74 |
]) |
| 75 |
m4_require(GL_MODULE_INDICATOR_PREFIX[_GLOB_H_MODULE_INDICATOR_DEFAULTS]) |
| 76 |
AC_REQUIRE([gl_GLOB_H_DEFAULTS]) |
| 77 |
]) |
| 78 |
|
| 79 |
AC_DEFUN([gl_GLOB_H_DEFAULTS], |
| 80 |
[ |
| 81 |
dnl Assume POSIX and GNU behavior unless another module says otherwise. |
| 82 |
HAVE_GLOB=1; AC_SUBST([HAVE_GLOB]) |
| 83 |
HAVE_GLOB_PATTERN_P=1; AC_SUBST([HAVE_GLOB_PATTERN_P]) |
| 84 |
REPLACE_GLOB=0; AC_SUBST([REPLACE_GLOB]) |
| 85 |
REPLACE_GLOB_PATTERN_P=0; AC_SUBST([REPLACE_GLOB_PATTERN_P]) |
| 86 |
]) |