source: trunk/essentials/app-arch/cpio/m4/fnmatch.m4

Last change on this file was 3332, checked in by bird, 18 years ago

cpio 2.7

File size: 3.7 KB
Line 
1# Check for fnmatch.
2
3# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4# Foundation, Inc.
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9# Autoconf defines AC_FUNC_FNMATCH, but that is obsolescent.
10# New applications should use the macros below instead.
11
12# _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
13# -------------------------------------------------------------------------
14# If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
15# IF-FALSE. Use CACHE_VAR.
16AC_DEFUN([_AC_FUNC_FNMATCH_IF],
17[AC_CACHE_CHECK(
18 [for working $1 fnmatch],
19 [$2],
20 [dnl Some versions of Solaris, SCO, and the GNU C Library
21 dnl have a broken or incompatible fnmatch.
22 dnl So we run a test program. If we are cross-compiling, take no chance.
23 dnl Thanks to John Oleynick, François Pinard, and Paul Eggert for this test.
24 AC_RUN_IFELSE(
25 [AC_LANG_PROGRAM(
26 [
27# include <stdlib.h>
28# include <fnmatch.h>
29# define y(a, b, c) (fnmatch (a, b, c) == 0)
30# define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
31 static int
32 fnm (char const *pattern, char const *string, int flags)
33 {
34 return fnmatch (pattern, string, flags);
35 }
36 ],
37 [exit
38 (!(fnm ("a*", "", 0) == FNM_NOMATCH
39 && y ("a*", "abc", 0)
40 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
41 && y ("a\\\\bc", "abc", 0)
42 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
43 && y ("*x", ".x", 0)
44 && n ("*x", ".x", FNM_PERIOD)
45 && m4_if([$1], [GNU],
46 [y ("xxXX", "xXxX", FNM_CASEFOLD)
47 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
48 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
49 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
50 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
51 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
52 1)));])],
53 [$2=yes],
54 [$2=no],
55 [$2=cross])])
56AS_IF([test $$2 = yes], [$3], [$4])
57])# _AC_FUNC_FNMATCH_IF
58
59
60# _AC_LIBOBJ_FNMATCH
61# ------------------
62# Prepare the replacement of fnmatch.
63AC_DEFUN([_AC_LIBOBJ_FNMATCH],
64[AC_REQUIRE([AC_FUNC_ALLOCA])dnl
65AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
66AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
67AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmemchr wmemcpy wmempcpy])
68AC_CHECK_HEADERS([wchar.h wctype.h])
69AC_LIBOBJ([fnmatch])
70FNMATCH_H=fnmatch.h
71])# _AC_LIBOBJ_FNMATCH
72
73
74AC_DEFUN([gl_FUNC_FNMATCH_POSIX],
75[
76 FNMATCH_H=
77 _AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_posix],
78 [rm -f lib/fnmatch.h],
79 [_AC_LIBOBJ_FNMATCH])
80 if test $ac_cv_func_fnmatch_posix != yes; then
81 dnl We must choose a different name for our function, since on ELF systems
82 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
83 dnl compiled into a shared library.
84 AC_DEFINE([fnmatch], [posix_fnmatch],
85 [Define to a replacement function name for fnmatch().])
86 fi
87 AC_SUBST([FNMATCH_H])
88])
89
90
91AC_DEFUN([gl_FUNC_FNMATCH_GNU],
92[
93 dnl Persuade glibc <fnmatch.h> to declare FNM_CASEFOLD etc.
94 AC_REQUIRE([AC_GNU_SOURCE])
95
96 FNMATCH_H=
97 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
98 [rm -f lib/fnmatch.h],
99 [_AC_LIBOBJ_FNMATCH])
100 if test $ac_cv_func_fnmatch_gnu != yes; then
101 dnl We must choose a different name for our function, since on ELF systems
102 dnl a broken fnmatch() in libc.so would override our fnmatch() if it is
103 dnl compiled into a shared library.
104 AC_DEFINE([fnmatch], [gnu_fnmatch],
105 [Define to a replacement function name for fnmatch().])
106 fi
107 AC_SUBST([FNMATCH_H])
108])
Note: See TracBrowser for help on using the repository browser.