adam@0: # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION], adam@0: # [ACTION-IF-YES], [ACTION-IF-NO]) adam@0: # ---------------------------------------------------------- adam@0: # David Shaw May-09-2006 adam@0: # adam@0: # Checks for libcurl. DEFAULT-ACTION is the string yes or no to adam@0: # specify whether to default to --with-libcurl or --without-libcurl. adam@0: # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the adam@0: # minimum version of libcurl to accept. Pass the version as a regular adam@0: # version number like 7.10.1. If not supplied, any version is adam@0: # accepted. ACTION-IF-YES is a list of shell commands to run if adam@0: # libcurl was successfully found and passed the various tests. adam@0: # ACTION-IF-NO is a list of shell commands that are run otherwise. adam@0: # Note that using --without-libcurl does run ACTION-IF-NO. adam@0: # adam@0: # This macro #defines HAVE_LIBCURL if a working libcurl setup is adam@0: # found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary adam@0: # values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are adam@0: # the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy adam@0: # where yyy are the various protocols supported by libcurl. Both xxx adam@0: # and yyy are capitalized. See the list of AH_TEMPLATEs at the top of adam@0: # the macro for the complete list of possible defines. Shell adam@0: # variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also adam@0: # defined to 'yes' for those features and protocols that were found. adam@0: # Note that xxx and yyy keep the same capitalization as in the adam@0: # curl-config list (e.g. it's "HTTP" and not "http"). adam@0: # adam@0: # Users may override the detected values by doing something like: adam@0: # LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure adam@0: # adam@0: # For the sake of sanity, this macro assumes that any libcurl that is adam@0: # found is after version 7.7.2, the first version that included the adam@0: # curl-config script. Note that it is very important for people adam@0: # packaging binary versions of libcurl to include this script! adam@0: # Without curl-config, we can only guess what protocols are available, adam@0: # or use curl_version_info to figure it out at runtime. adam@0: adam@0: AC_DEFUN([LIBCURL_CHECK_CONFIG], adam@0: [ adam@0: AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI]) adam@0: AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM]) adam@0: adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP]) adam@0: AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP]) adam@0: adam@0: AC_ARG_WITH(libcurl, adam@0: AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]), adam@0: [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])]) adam@0: adam@0: if test "$_libcurl_with" != "no" ; then adam@0: adam@0: AC_PROG_AWK adam@0: adam@0: _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'" adam@0: adam@0: _libcurl_try_link=yes adam@0: adam@0: if test -d "$_libcurl_with" ; then adam@0: LIBCURL_CPPFLAGS="-I$withval/include" adam@0: _libcurl_ldflags="-L$withval/lib" adam@0: AC_PATH_PROG([_libcurl_config],[curl-config],["$withval/bin"], adam@0: ["$withval/bin"]) adam@0: else adam@0: AC_PATH_PROG([_libcurl_config],[curl-config]) adam@0: fi adam@0: adam@0: if test x$_libcurl_config != "x" ; then adam@0: AC_CACHE_CHECK([for the version of libcurl], adam@0: [libcurl_cv_lib_curl_version], adam@0: [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`]) adam@0: adam@0: _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` adam@0: _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse` adam@0: adam@0: if test $_libcurl_wanted -gt 0 ; then adam@0: AC_CACHE_CHECK([for libcurl >= version $2], adam@0: [libcurl_cv_lib_version_ok], adam@0: [ adam@0: if test $_libcurl_version -ge $_libcurl_wanted ; then adam@0: libcurl_cv_lib_version_ok=yes adam@0: else adam@0: libcurl_cv_lib_version_ok=no adam@0: fi adam@0: ]) adam@0: fi adam@0: adam@0: if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then adam@0: if test x"$LIBCURL_CPPFLAGS" = "x" ; then adam@0: LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` adam@0: fi adam@0: if test x"$LIBCURL" = "x" ; then adam@0: LIBCURL=`$_libcurl_config --libs` adam@0: adam@0: # This is so silly, but Apple actually has a bug in their adam@0: # curl-config script. Fixed in Tiger, but there are still adam@0: # lots of Panther installs around. adam@0: case "${host}" in adam@0: powerpc-apple-darwin7*) adam@0: LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` adam@0: ;; adam@0: esac adam@0: fi adam@0: adam@0: # All curl-config scripts support --feature adam@0: _libcurl_features=`$_libcurl_config --feature` adam@0: adam@0: # Is it modern enough to have --protocols? (7.12.4) adam@0: if test $_libcurl_version -ge 461828 ; then adam@0: _libcurl_protocols=`$_libcurl_config --protocols` adam@0: fi adam@0: else adam@0: _libcurl_try_link=no adam@0: fi adam@0: adam@0: unset _libcurl_wanted adam@0: fi adam@0: adam@0: if test $_libcurl_try_link = yes ; then adam@0: adam@0: # we didn't find curl-config, so let's see if the user-supplied adam@0: # link line (or failing that, "-lcurl") is enough. adam@0: LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} adam@0: adam@0: AC_CACHE_CHECK([whether libcurl is usable], adam@0: [libcurl_cv_lib_curl_usable], adam@0: [ adam@0: _libcurl_save_cppflags=$CPPFLAGS adam@0: CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" adam@0: _libcurl_save_libs=$LIBS adam@0: LIBS="$LIBCURL $LIBS" adam@0: adam@0: AC_LINK_IFELSE(AC_LANG_PROGRAM([#include ],[ adam@0: /* Try and use a few common options to force a failure if we are adam@0: missing symbols or can't link. */ adam@0: int x; adam@0: curl_easy_setopt(NULL,CURLOPT_URL,NULL); adam@0: x=CURL_ERROR_SIZE; adam@0: x=CURLOPT_WRITEFUNCTION; adam@0: x=CURLOPT_FILE; adam@0: x=CURLOPT_ERRORBUFFER; adam@0: x=CURLOPT_STDERR; adam@0: x=CURLOPT_VERBOSE; adam@0: ]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no) adam@0: adam@0: CPPFLAGS=$_libcurl_save_cppflags adam@0: LIBS=$_libcurl_save_libs adam@0: unset _libcurl_save_cppflags adam@0: unset _libcurl_save_libs adam@0: ]) adam@0: adam@0: if test $libcurl_cv_lib_curl_usable = yes ; then adam@0: adam@0: # Does curl_free() exist in this version of libcurl? adam@0: # If not, fake it with free() adam@0: adam@0: _libcurl_save_cppflags=$CPPFLAGS adam@0: CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" adam@0: _libcurl_save_libs=$LIBS adam@0: LIBS="$LIBS $LIBCURL" adam@0: adam@0: AC_CHECK_FUNC(curl_free,, adam@0: AC_DEFINE(curl_free,free, adam@0: [Define curl_free() as free() if our version of curl lacks curl_free.])) adam@0: adam@0: CPPFLAGS=$_libcurl_save_cppflags adam@0: LIBS=$_libcurl_save_libs adam@0: unset _libcurl_save_cppflags adam@0: unset _libcurl_save_libs adam@0: adam@0: AC_DEFINE(HAVE_LIBCURL,1, adam@0: [Define to 1 if you have a functional curl library.]) adam@0: AC_SUBST(LIBCURL_CPPFLAGS) adam@0: AC_SUBST(LIBCURL) adam@0: adam@0: for _libcurl_feature in $_libcurl_features ; do adam@0: AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1]) adam@0: eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes adam@0: done adam@0: adam@0: if test "x$_libcurl_protocols" = "x" ; then adam@0: adam@0: # We don't have --protocols, so just assume that all adam@0: # protocols are available adam@0: _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" adam@0: adam@0: if test x$libcurl_feature_SSL = xyes ; then adam@0: _libcurl_protocols="$_libcurl_protocols HTTPS" adam@0: adam@0: # FTPS wasn't standards-compliant until version adam@0: # 7.11.0 (0x070b00 == 461568) adam@0: if test $_libcurl_version -ge 461568; then adam@0: _libcurl_protocols="$_libcurl_protocols FTPS" adam@0: fi adam@0: fi adam@0: adam@0: # RTSP, IMAP, POP3 and SMTP were added in adam@0: # 7.20.0 (0x071400 == 463872) adam@0: if test $_libcurl_version -ge 463872; then adam@0: _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" adam@0: fi adam@0: fi adam@0: adam@0: for _libcurl_protocol in $_libcurl_protocols ; do adam@0: AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1]) adam@0: eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes adam@0: done adam@0: else adam@0: unset LIBCURL adam@0: unset LIBCURL_CPPFLAGS adam@0: fi adam@0: fi adam@0: adam@0: unset _libcurl_try_link adam@0: unset _libcurl_version_parse adam@0: unset _libcurl_config adam@0: unset _libcurl_feature adam@0: unset _libcurl_features adam@0: unset _libcurl_protocol adam@0: unset _libcurl_protocols adam@0: unset _libcurl_version adam@0: unset _libcurl_ldflags adam@0: fi adam@0: adam@0: if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then adam@0: # This is the IF-NO path adam@0: ifelse([$4],,:,[$4]) adam@0: else adam@0: # This is the IF-YES path adam@0: ifelse([$3],,:,[$3]) adam@0: fi adam@0: adam@0: unset _libcurl_with adam@0: ])dnl