* jm-macros.m4 (jm_MACROS): check for rpmatch.
[findutils.git] / m4 / fnmatchcase.m4
blobcf857a278f26d4b300529a15dcd0f998e7706712
1 #serial 2
3 dnl Determine whether to add fnmatch.o to LIBOBJS and to
4 dnl define fnmatch to rpl_fnmatch.
5 dnl
7 # AC_FUNC_FNMATCH
8 # ---------------
9 # We look for fnmatch.h to avoid that the test fails in C++.
10 AC_DEFUN(kd_FUNC_FNMATCH_CASE,
11 [AC_CHECK_HEADERS(fnmatch.h)
12 AC_CACHE_CHECK(for working fnmatch with case folding, ac_cv_func_fnmatch_works,
13 # Some versions of Solaris or SCO have a broken fnmatch function.
14 # So we run a test program.  If we are cross-compiling, take no chance.
15 # Also want FNM_CASEFOLD
16 # Thanks to John Oleynick and Franc,ois Pinard for this test.
17 [AC_TRY_RUN(
18 [#include <stdio.h>
19 #define _GNU_SOURCE
20 #if HAVE_FNMATCH_H
21 # include <fnmatch.h>
22 #endif
24 int
25 main ()
27   exit (fnmatch ("A*", "abc", FNM_CASEFOLD) != 0);
28 }],
29 ac_cv_func_fnmatch_works=yes, ac_cv_func_fnmatch_works=no,
30 ac_cv_func_fnmatch_works=no)])
31 if test $ac_cv_func_fnmatch_works = yes; then
32   AC_DEFINE(HAVE_FNMATCH, 1,
33             [Define if your system has a working `fnmatch' function with case folding.])
35 ])# AC_FUNC_FNMATCH
38 AC_DEFUN(kd_FUNC_FNMATCH_CASE_RPL,
40   AC_REQUIRE([AM_GLIBC])
41   kd_FUNC_FNMATCH_CASE
42   if test $ac_cv_func_fnmatch_works = no \
43       && test $ac_cv_gnu_library = no; then
44     AC_SUBST(LIBOBJS)
45     LIBOBJS="$LIBOBJS fnmatch.$ac_objext"
46     AC_DEFINE_UNQUOTED(fnmatch, rpl_fnmatch,
47       [Define to rpl_fnmatch if the replacement function should be used.])
48   fi