Merge branch '346_fix_faq'
[midnight-commander.git] / m4.include / ax_path_lib_pcre.m4
blob88cc1695bb94477eced20fef356be5720635d03c
1 dnl @synopsis AX_PATH_LIB_PCRE [(A/NA)]
2 dnl
3 dnl check for pcre lib and set PCRE_LIBS and PCRE_CFLAGS accordingly.
4 dnl
5 dnl also provide --with-pcre option that may point to the $prefix of
6 dnl the pcre installation - the macro will check $pcre/include and
7 dnl $pcre/lib to contain the necessary files.
8 dnl
9 dnl the usual two ACTION-IF-FOUND / ACTION-IF-NOT-FOUND are supported
10 dnl and they can take advantage of the LIBS/CFLAGS additions.
11 dnl
12 dnl @category InstalledPackages
13 dnl @author Guido U. Draheim <guidod@gmx.de>
14 dnl @version 2006-10-13
15 dnl @license GPLWithACException
17 AC_DEFUN([AX_PATH_LIB_PCRE],[dnl
18 AC_MSG_CHECKING([lib pcre])
19 AC_ARG_WITH(pcre,
20 [  --with-pcre[[=prefix]]    compile xmlpcre part (via libpcre check)],,
21      with_pcre="yes")
22 if test ".$with_pcre" = ".no" ; then
23   AC_MSG_RESULT([disabled])
24   m4_ifval($2,$2)
25 else
26   AC_MSG_RESULT([(testing)])
27   AC_CHECK_LIB(pcre, pcre_study)
28   if test "$ac_cv_lib_pcre_pcre_study" = "yes" ; then
29      PCRE_LIBS="-lpcre"
30      AC_MSG_CHECKING([lib pcre])
31      AC_MSG_RESULT([$PCRE_LIBS])
32      m4_ifval($1,$1)
33   else
34      OLDLDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$with_pcre/lib"
35      OLDCPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$with_pcre/include"
36      AC_CHECK_LIB(pcre, pcre_compile)
37      CPPFLAGS="$OLDCPPFLAGS"
38      LDFLAGS="$OLDLDFLAGS"
39      if test "$ac_cv_lib_pcre_pcre_compile" = "yes" ; then
40         AC_MSG_RESULT(.setting PCRE_LIBS -L$with_pcre/lib -lpcre)
41         PCRE_LIBS="-L$with_pcre/lib -lpcre"
42         test -d "$with_pcre/include" && PCRE_CFLAGS="-I$with_pcre/include"
43         AC_MSG_CHECKING([lib pcre])
44         AC_MSG_RESULT([$PCRE_LIBS])
45         m4_ifval($1,$1)
46      else
47         AC_MSG_CHECKING([lib pcre])
48         AC_MSG_RESULT([no, (WARNING)])
49         m4_ifval($2,$2)
50      fi
51   fi
53 AC_SUBST([PCRE_LIBS])
54 AC_SUBST([PCRE_CFLAGS])