1d35c98390c3cdde569aa09a3a641390af3fd545
[platform/upstream/automake.git] / m4 / regex.m4
1 ## --------------------------------- ##
2 ## Check if --with-regex was given.  ##
3 ## --------------------------------- ##
4
5 # serial 2
6
7 # AM_WITH_REGEX
8 # -------------
9 #
10 # The idea is to distribute rx.[hc] and regex.[hc] together, for a
11 # while.  The WITH_REGEX symbol is used to decide which of regex.h or
12 # rx.h should be included in the application.  If `./configure
13 # --with-regex' is given (the default), the package will use gawk's
14 # regex.  If `./configure --without-regex', a check is made to see if
15 # rx is already installed, as with newer Linux'es.  If not found, the
16 # package will use the rx from the distribution.  If found, the
17 # package will use the system's rx which, on Linux at least, will
18 # result in a smaller executable file.
19 #
20 # FIXME: This macro seems quite obsolete now since rx doesn't seem to
21 # be maintained, while regex is.
22 AC_DEFUN([AM_WITH_REGEX],
23 [ifdef([AC_LIBSOURCES],
24        [AC_LIBSOURCES([rx.h, rx.c, regex.c, regex.h])])dnl
25 AC_MSG_CHECKING([which of GNU rx or gawk's regex is wanted])
26 AC_ARG_WITH(regex,
27 [  --without-regex         use GNU rx in lieu of gawk's regex for matching],
28             [test "$withval" = yes && am_with_regex=1],
29             [am_with_regex=1])
30 if test -n "$am_with_regex"; then
31   AC_MSG_RESULT(regex)
32   AC_DEFINE(WITH_REGEX, 1, [Define if using GNU regex])
33   AC_CACHE_CHECK([for GNU regex in libc], am_cv_gnu_regex,
34     [AC_TRY_LINK([],
35                  [extern int re_max_failures; re_max_failures = 1],
36                  [am_cv_gnu_regex=yes],
37                  [am_cv_gnu_regex=no])])
38   if test $am_cv_gnu_regex = no; then
39     LIBOBJS="$LIBOBJS regex.$ac_objext"
40   fi
41 else
42   AC_MSG_RESULT(rx)
43   AC_CHECK_FUNC(re_rx_search, , [LIBOBJS="$LIBOBJS rx.$ac_objext"])
44 fi
45 AC_SUBST(LIBOBJS)dnl
46 ])