Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / build / find_pcre.m4
1 dnl Check for PCRE Libraries
2 dnl CHECK_PCRE(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
3 dnl Sets:
4 dnl  PCRE_CFLAGS
5 dnl  PCRE_LIBS
6
7 PCRE_CONFIG=""
8 PCRE_CFLAGS=""
9 PCRE_LIBS=""
10
11 AC_DEFUN([CHECK_PCRE],
12 [dnl
13
14 AC_ARG_WITH(
15     pcre,
16     [AC_HELP_STRING([--with-pcre=PATH],[Path to pcre prefix or config script])],
17     [test_paths="${with_pcre}"],
18     [test_paths="/usr/local/libpcre /usr/local/pcre /usr/local /opt/libpcre /opt/pcre /opt /usr"])
19
20 AC_MSG_CHECKING([for libpcre config script])
21
22 dnl # Determine pcre lib directory
23 if test -z "${with_pcre}"; then
24     test_paths="/usr/local/pcre /usr/local /usr"
25 else
26     test_paths="${with_pcre}"
27 fi
28
29 for x in ${test_paths}; do
30     dnl # Determine if the script was specified and use it directly
31     if test ! -d "$x" -a -e "$x"; then
32         PCRE_CONFIG=$x
33         pcre_path="no"
34         break
35     fi
36
37     dnl # Try known config script names/locations
38     for PCRE_CONFIG in pcre-config; do
39         if test -e "${x}/bin/${PCRE_CONFIG}"; then
40             pcre_path="${x}/bin"
41             break
42         elif test -e "${x}/${PCRE_CONFIG}"; then
43             pcre_path="${x}"
44             break
45         else
46             pcre_path=""
47         fi
48     done
49     if test -n "$pcre_path"; then
50         break
51     fi
52 done
53     CFLAGS=$save_CFLAGS
54     LDFLAGS=$save_LDFLAGS
55
56 if test -n "${pcre_path}"; then
57     if test "${pcre_path}" != "no"; then
58         PCRE_CONFIG="${pcre_path}/${PCRE_CONFIG}"
59     fi
60     AC_MSG_RESULT([${PCRE_CONFIG}])
61     PCRE_CFLAGS="`${PCRE_CONFIG} --cflags`"
62     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre CFLAGS: $PCRE_CFLAGS); fi
63     PCRE_LIBS="`${PCRE_CONFIG} --libs`"
64     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(pcre LIBS: $PCRE_LIBS); fi
65     CFLAGS=$save_CFLAGS
66     LDFLAGS=$save_LDFLAGS
67 else
68     AC_MSG_RESULT([no])
69 fi
70
71 AC_SUBST(PCRE_LIBS)
72 AC_SUBST(PCRE_CFLAGS)
73
74 if test -z "${PCRE_LIBS}"; then
75     AC_MSG_NOTICE([*** pcre library not found.])
76     ifelse([$2], , AC_MSG_ERROR([pcre library is required]), $2)
77 else
78     AC_MSG_NOTICE([using '${PCRE_LIBS}' for pcre Library])
79     ifelse([$1], , , $1) 
80 fi 
81 ])