3 # This is a modified version of autoconf's AC_FUNC_FNMATCH.
4 # This file should be simplified after Autoconf 2.57 is required.
6 dnl Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
7 dnl This file is free software; the Free Software Foundation
8 dnl gives unlimited permission to copy and/or distribute it,
9 dnl with or without modifications, as long as this notice is preserved.
11 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
12 # -------------------------------------------------------------------------
13 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
14 # IF-FALSE. Use CACHE_VAR.
15 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
17 [for working $1 fnmatch],
19 [dnl Some versions of Solaris, SCO, and the GNU C Library
20 dnl have a broken or incompatible fnmatch.
21 dnl So we run a test program. If we are cross-compiling, take no chance.
22 dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this test.
28 # define y(a, b, c) (fnmatch (a, b, c) == 0)
29 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
33 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
34 && y ("a\\\\bc", "abc", 0)
35 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
37 && n ("*x", ".x", FNM_PERIOD)
39 [y ("xxXX", "xXxX", FNM_CASEFOLD)
40 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
41 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
42 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
43 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
44 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
49 AS_IF([test $$2 = yes], [$3], [$4])
50 ])# _AC_FUNC_FNMATCH_IF
55 # Prepare the replacement of fnmatch.
56 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
57 [AC_REQUIRE([AC_C_CONST])dnl
58 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
59 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
60 AC_CHECK_DECLS([getenv])
61 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
62 AC_CHECK_HEADERS([wchar.h wctype.h])
65 ])# _AC_LIBOBJ_FNMATCH
68 AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
71 _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix],
72 [rm -f lib/fnmatch.h],
74 if test $ac_cv_func_fnmatch_posix != yes; then
75 dnl We must choose a different name for our function, since on ELF systems
76 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
77 dnl compiled into a shared library.
78 AC_DEFINE([fnmatch], [posix_fnmatch],
79 [Define to a replacement function name for fnmatch().])
85 AC_DEFUN([gl_FUNC_FNMATCH_GNU],
87 dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
88 AC_REQUIRE([AC_GNU_SOURCE])
91 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
92 [rm -f lib/fnmatch.h],
94 if test $ac_cv_func_fnmatch_gnu != yes; then
95 dnl We must choose a different name for our function, since on ELF systems
96 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
97 dnl compiled into a shared library.
98 AC_DEFINE([fnmatch], [gnu_fnmatch],
99 [Define to a replacement function name for fnmatch().])
101 AC_SUBST([FNMATCH_H])