| 1 |
# fnmatch_h.m4 |
| 2 |
# serial 8 |
| 3 |
dnl Copyright (C) 2009-2024 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_FNMATCH_H], |
| 12 |
[ |
| 13 |
AC_REQUIRE([gl_FNMATCH_H_DEFAULTS]) |
| 14 |
m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])]) |
| 15 |
AC_CHECK_HEADERS_ONCE([fnmatch.h]) |
| 16 |
gl_CHECK_NEXT_HEADERS([fnmatch.h]) |
| 17 |
|
| 18 |
dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc. |
| 19 |
dnl This is only needed if gl_fnmatch_required = GNU. It would be possible |
| 20 |
dnl to avoid this dependency for gl_FUNC_FNMATCH_POSIX by putting |
| 21 |
dnl gl_FUNC_FNMATCH_GNU into a separate .m4 file. |
| 22 |
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 23 |
|
| 24 |
if test $ac_cv_header_fnmatch_h = yes; then |
| 25 |
HAVE_FNMATCH_H=1 |
| 26 |
else |
| 27 |
HAVE_FNMATCH_H=0 |
| 28 |
fi |
| 29 |
AC_SUBST([HAVE_FNMATCH_H]) |
| 30 |
|
| 31 |
m4_ifdef([gl_POSIXCHECK], |
| 32 |
[GL_GENERATE_FNMATCH_H=true], |
| 33 |
[GL_GENERATE_FNMATCH_H=false |
| 34 |
if m4_ifdef([gl_ANSI_CXX], [test "$CXX" != no], [false]); then |
| 35 |
dnl Override <fnmatch.h> always, to support the C++ GNULIB_NAMESPACE. |
| 36 |
GL_GENERATE_FNMATCH_H=true |
| 37 |
else |
| 38 |
if test $ac_cv_header_fnmatch_h != yes; then |
| 39 |
dnl Provide a substitute <fnmatch.h> file. |
| 40 |
GL_GENERATE_FNMATCH_H=true |
| 41 |
fi |
| 42 |
fi |
| 43 |
]) |
| 44 |
|
| 45 |
dnl Check for declarations of anything we want to poison if the |
| 46 |
dnl corresponding gnulib module is not in use. |
| 47 |
gl_WARN_ON_USE_PREPARE([[#include <fnmatch.h> |
| 48 |
]], |
| 49 |
[fnmatch]) |
| 50 |
]) |
| 51 |
|
| 52 |
dnl Unconditionally enables the replacement of <fnmatch.h>. |
| 53 |
AC_DEFUN([gl_REPLACE_FNMATCH_H], |
| 54 |
[ |
| 55 |
gl_FNMATCH_H_REQUIRE_DEFAULTS |
| 56 |
GL_GENERATE_FNMATCH_H=true |
| 57 |
]) |
| 58 |
|
| 59 |
# gl_FNMATCH_MODULE_INDICATOR([modulename]) |
| 60 |
# sets the shell variable that indicates the presence of the given module |
| 61 |
# to a C preprocessor expression that will evaluate to 1. |
| 62 |
# This macro invocation must not occur in macros that are AC_REQUIREd. |
| 63 |
AC_DEFUN([gl_FNMATCH_MODULE_INDICATOR], |
| 64 |
[ |
| 65 |
dnl Ensure to expand the default settings once only. |
| 66 |
gl_FNMATCH_H_REQUIRE_DEFAULTS |
| 67 |
gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
| 68 |
dnl Define it also as a C macro, for the benefit of the unit tests. |
| 69 |
gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
| 70 |
]) |
| 71 |
|
| 72 |
# Initializes the default values for AC_SUBSTed shell variables. |
| 73 |
# This macro must not be AC_REQUIREd. It must only be invoked, and only |
| 74 |
# outside of macros or in macros that are not AC_REQUIREd. |
| 75 |
AC_DEFUN([gl_FNMATCH_H_REQUIRE_DEFAULTS], |
| 76 |
[ |
| 77 |
m4_defun(GL_MODULE_INDICATOR_PREFIX[_FNMATCH_H_MODULE_INDICATOR_DEFAULTS], [ |
| 78 |
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FNMATCH]) |
| 79 |
]) |
| 80 |
m4_require(GL_MODULE_INDICATOR_PREFIX[_FNMATCH_H_MODULE_INDICATOR_DEFAULTS]) |
| 81 |
AC_REQUIRE([gl_FNMATCH_H_DEFAULTS]) |
| 82 |
]) |
| 83 |
|
| 84 |
AC_DEFUN([gl_FNMATCH_H_DEFAULTS], |
| 85 |
[ |
| 86 |
dnl Assume POSIX behavior unless another module says otherwise. |
| 87 |
HAVE_FNMATCH=1; AC_SUBST([HAVE_FNMATCH]) |
| 88 |
REPLACE_FNMATCH=0; AC_SUBST([REPLACE_FNMATCH]) |
| 89 |
]) |