Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / build / find_curl.m4
1 dnl Check for CURL Libraries
2 dnl CHECK_CURL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
3 dnl Sets:
4 dnl  CURL_CFLAGS
5 dnl  CURL_LIBS
6
7 CURL_CONFIG=""
8 CURL_CFLAGS=""
9 CURL_LIBS=""
10 CURL_MIN_VERSION="7.15.1"
11
12 AC_DEFUN([CHECK_CURL],
13 [dnl
14
15 AC_ARG_WITH(
16     curl,
17     [AC_HELP_STRING([--with-curl=PATH],[Path to curl prefix or config script])],
18     [test_paths="${with_curl}"],
19     [test_paths="/usr/local/libcurl /usr/local/curl /usr/local /opt/libcurl /opt/curl /opt /usr"])
20
21 AC_MSG_CHECKING([for libcurl config script])
22
23 for x in ${test_paths}; do
24     dnl # Determine if the script was specified and use it directly
25     if test ! -d "$x" -a -e "$x"; then
26         CURL_CONFIG=$x
27         curl_path="no"
28         break
29     fi
30
31     dnl # Try known config script names/locations
32     for CURL_CONFIG in curl-config; do
33         if test -e "${x}/bin/${CURL_CONFIG}"; then
34             curl_path="${x}/bin"
35             break
36         elif test -e "${x}/${CURL_CONFIG}"; then
37             curl_path="${x}"
38             break
39         else
40             curl_path=""
41         fi
42     done
43     if test -n "$curl_path"; then
44         break
45     fi
46 done
47
48 if test -n "${curl_path}"; then
49     if test "${curl_path}" != "no"; then
50         CURL_CONFIG="${curl_path}/${CURL_CONFIG}"
51     fi
52     AC_MSG_RESULT([${CURL_CONFIG}])
53     CURL_CFLAGS="`${CURL_CONFIG} --cflags`"
54     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(curl CFLAGS: $CURL_CFLAGS); fi
55     CURL_LIBS="`${CURL_CONFIG} --libs`"
56     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(curl LIBS: $CURL_LIBS); fi
57     CURL_VERSION=`${CURL_CONFIG} --version | sed 's/^[[^0-9]][[^[:space:]]][[^[:space:]]]*[[[:space:]]]*//'`
58     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(curl VERSION: $CURL_VERSION); fi
59     CFLAGS=$save_CFLAGS
60     LDFLAGS=$save_LDFLAGS
61
62     dnl # Check version is ok
63     AC_MSG_CHECKING([if libcurl is at least v${CURL_MIN_VERSION}])
64     curl_min_ver=`echo ${CURL_MIN_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
65     curl_ver=`echo ${CURL_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
66     if test "$curl_min_ver" -le "$curl_ver"; then
67         AC_MSG_RESULT([yes])
68     else
69         AC_MSG_RESULT([no])
70         AC_MSG_NOTICE([NOTE: curl library may be too old: $CURL_VERSION])
71     fi
72
73     dnl # Check/warn if GnuTLS is used
74     AC_MSG_CHECKING([if libcurl is linked with gnutls])
75     curl_uses_gnutls=`echo ${CURL_LIBS} | grep gnutls | wc -l`
76     if test "$curl_uses_gnutls" -ne 0; then
77         AC_MSG_RESULT([yes])
78         AC_MSG_NOTICE([NOTE: curl linked with gnutls may be buggy, openssl recommended])
79         CURL_USES_GNUTLS=yes
80     else
81         AC_MSG_RESULT([no])
82         CURL_USES_GNUTLS=no
83     fi
84
85 else
86     AC_MSG_RESULT([no])
87 fi
88
89 AC_SUBST(CURL_LIBS)
90 AC_SUBST(CURL_CFLAGS)
91 AC_SUBST(CURL_USES_GNUTLS)
92
93 if test -z "${CURL_LIBS}"; then
94   AC_MSG_NOTICE([*** curl library not found.])
95   ifelse([$2], , AC_MSG_NOTICE([NOTE: curl library is only required for building mlogc]), $2)
96 else
97   AC_MSG_NOTICE([using '${CURL_LIBS}' for curl Library])
98   ifelse([$1], , , $1) 
99 fi 
100 ])