3 dnl Initially derived from code in GNU grep.
4 dnl Mostly written by Jim Meyering.
6 AC_DEFUN(jm_WITH_REGEX,
10 dnl Even packages that don't use regex.c can use this macro.
11 dnl Of course, for them it doesn't do anything.
13 # By default, don't use the included regex.c on systems with a version
14 # of glibc 2 that's new enough to pass the following run test.
15 # If cross compiling, assume the test would fail and use the included
16 # regex.c. The failing regular expression is from `Spencer ere test
18 ac_use_included_regex=yes
20 if test "$ac_cv_glibc" = yes; then
21 # Without this run-test, on older glibc2 systems we'd end up
22 # using the buggy system regex.
23 AC_CACHE_CHECK([for working re_compile_pattern],
24 jm_cv_func_working_re_compile_pattern,
26 changequote(<<, >>)dnl
33 static struct re_pattern_buffer regex;
35 re_set_syntax (RE_SYNTAX_POSIX_EGREP);
36 /* Add this third left square bracket, [, to balance the
37 three right ones below. Otherwise autoconf-2.14 chokes. */
38 s = re_compile_pattern ("a[[:]:]]b\n", 9, ®ex);
39 /* This should fail with _Invalid character class name_ error. */
45 jm_cv_func_working_re_compile_pattern=yes,
46 jm_cv_func_working_re_compile_pattern=no,
47 dnl When crosscompiling, assume it's broken.
48 jm_cv_func_working_re_compile_pattern=no))
49 if test $jm_cv_func_working_re_compile_pattern = yes; then
50 ac_use_included_regex=no
54 test -n "$1" || AC_MSG_ERROR([missing argument])
59 AC_ARG_WITH(included-regex,
60 [ --without-included-regex don't compile regex; this is the default on
61 systems with version 2 of the GNU C library
62 (use with caution on other system)],
63 jm_with_regex=$withval,
64 jm_with_regex=$ac_use_included_regex)
65 if test "$jm_with_regex" = yes; then
66 LIBOBJS="$LIBOBJS regex.o"