Use AC_SUBST(LIBOBJS) since we set LIBOBJS.
[gnulib.git] / m4 / regex.m4
1 #serial 4
2
3 dnl Initially derived from code in GNU grep.
4 dnl Mostly written by Jim Meyering.
5
6 AC_DEFUN(jm_WITH_REGEX,
7   [
8     AC_REQUIRE([AM_GLIBC])
9
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.
12
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
17     # #75' in grep-2.2f.
18     ac_use_included_regex=yes
19
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,
25         AC_TRY_RUN(
26           changequote(<<, >>)dnl
27           <<
28 #include <stdio.h>
29 #include <regex.h>
30             int
31             main ()
32             {
33               static struct re_pattern_buffer regex;
34               const char *s;
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, &regex);
39               /* This should fail with _Invalid character class name_ error.  */
40               exit (s ? 0 : 1);
41             }
42           >>,
43           changequote([, ])dnl
44
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
51       fi
52     fi
53
54     test -n "$1" || AC_MSG_ERROR([missing argument])
55     syscmd([test -f $1])
56     ifelse(sysval, 0,
57       [
58
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           AC_SUBST(LIBOBJS)
67           LIBOBJS="$LIBOBJS regex.$ac_objext"
68         fi
69       ],
70     )
71   ]
72 )