annotate m4/libcurl.m4 @ 48:3f475c6fb168

Make logout clear the session on the server (which necessitates turning it from a link into a button)
author Robin Green <greenrd@greenrd.org>
date Mon, 04 Jul 2011 14:08:00 +0100
parents 3c209338e596
children ba203b170476
rev   line source
adam@0 1 # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
adam@0 2 # [ACTION-IF-YES], [ACTION-IF-NO])
adam@0 3 # ----------------------------------------------------------
adam@0 4 # David Shaw <dshaw@jabberwocky.com> May-09-2006
adam@0 5 #
adam@0 6 # Checks for libcurl. DEFAULT-ACTION is the string yes or no to
adam@0 7 # specify whether to default to --with-libcurl or --without-libcurl.
adam@0 8 # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
adam@0 9 # minimum version of libcurl to accept. Pass the version as a regular
adam@0 10 # version number like 7.10.1. If not supplied, any version is
adam@0 11 # accepted. ACTION-IF-YES is a list of shell commands to run if
adam@0 12 # libcurl was successfully found and passed the various tests.
adam@0 13 # ACTION-IF-NO is a list of shell commands that are run otherwise.
adam@0 14 # Note that using --without-libcurl does run ACTION-IF-NO.
adam@0 15 #
adam@0 16 # This macro #defines HAVE_LIBCURL if a working libcurl setup is
adam@0 17 # found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
adam@0 18 # values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
adam@0 19 # the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
adam@0 20 # where yyy are the various protocols supported by libcurl. Both xxx
adam@0 21 # and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
adam@0 22 # the macro for the complete list of possible defines. Shell
adam@0 23 # variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
adam@0 24 # defined to 'yes' for those features and protocols that were found.
adam@0 25 # Note that xxx and yyy keep the same capitalization as in the
adam@0 26 # curl-config list (e.g. it's "HTTP" and not "http").
adam@0 27 #
adam@0 28 # Users may override the detected values by doing something like:
adam@0 29 # LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
adam@0 30 #
adam@0 31 # For the sake of sanity, this macro assumes that any libcurl that is
adam@0 32 # found is after version 7.7.2, the first version that included the
adam@0 33 # curl-config script. Note that it is very important for people
adam@0 34 # packaging binary versions of libcurl to include this script!
adam@0 35 # Without curl-config, we can only guess what protocols are available,
adam@0 36 # or use curl_version_info to figure it out at runtime.
adam@0 37
adam@0 38 AC_DEFUN([LIBCURL_CHECK_CONFIG],
adam@0 39 [
adam@0 40 AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
adam@0 41 AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
adam@0 42 AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
adam@0 43 AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
adam@0 44 AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
adam@0 45 AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
adam@0 46 AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
adam@0 47 AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
adam@0 48
adam@0 49 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
adam@0 50 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
adam@0 51 AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
adam@0 52 AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
adam@0 53 AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
adam@0 54 AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
adam@0 55 AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
adam@0 56 AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
adam@0 57 AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
adam@0 58 AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
adam@0 59 AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
adam@0 60 AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
adam@0 61 AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
adam@0 62
adam@0 63 AC_ARG_WITH(libcurl,
adam@0 64 AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
adam@0 65 [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
adam@0 66
adam@0 67 if test "$_libcurl_with" != "no" ; then
adam@0 68
adam@0 69 AC_PROG_AWK
adam@0 70
adam@0 71 _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
adam@0 72
adam@0 73 _libcurl_try_link=yes
adam@0 74
adam@0 75 if test -d "$_libcurl_with" ; then
adam@0 76 LIBCURL_CPPFLAGS="-I$withval/include"
adam@0 77 _libcurl_ldflags="-L$withval/lib"
adam@0 78 AC_PATH_PROG([_libcurl_config],[curl-config],["$withval/bin"],
adam@0 79 ["$withval/bin"])
adam@0 80 else
adam@0 81 AC_PATH_PROG([_libcurl_config],[curl-config])
adam@0 82 fi
adam@0 83
adam@0 84 if test x$_libcurl_config != "x" ; then
adam@0 85 AC_CACHE_CHECK([for the version of libcurl],
adam@0 86 [libcurl_cv_lib_curl_version],
adam@0 87 [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
adam@0 88
adam@0 89 _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
adam@0 90 _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
adam@0 91
adam@0 92 if test $_libcurl_wanted -gt 0 ; then
adam@0 93 AC_CACHE_CHECK([for libcurl >= version $2],
adam@0 94 [libcurl_cv_lib_version_ok],
adam@0 95 [
adam@0 96 if test $_libcurl_version -ge $_libcurl_wanted ; then
adam@0 97 libcurl_cv_lib_version_ok=yes
adam@0 98 else
adam@0 99 libcurl_cv_lib_version_ok=no
adam@0 100 fi
adam@0 101 ])
adam@0 102 fi
adam@0 103
adam@0 104 if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
adam@0 105 if test x"$LIBCURL_CPPFLAGS" = "x" ; then
adam@0 106 LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
adam@0 107 fi
adam@0 108 if test x"$LIBCURL" = "x" ; then
adam@0 109 LIBCURL=`$_libcurl_config --libs`
adam@0 110
adam@0 111 # This is so silly, but Apple actually has a bug in their
adam@0 112 # curl-config script. Fixed in Tiger, but there are still
adam@0 113 # lots of Panther installs around.
adam@0 114 case "${host}" in
adam@0 115 powerpc-apple-darwin7*)
adam@0 116 LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
adam@0 117 ;;
adam@0 118 esac
adam@0 119 fi
adam@0 120
adam@0 121 # All curl-config scripts support --feature
adam@0 122 _libcurl_features=`$_libcurl_config --feature`
adam@0 123
adam@0 124 # Is it modern enough to have --protocols? (7.12.4)
adam@0 125 if test $_libcurl_version -ge 461828 ; then
adam@0 126 _libcurl_protocols=`$_libcurl_config --protocols`
adam@0 127 fi
adam@0 128 else
adam@0 129 _libcurl_try_link=no
adam@0 130 fi
adam@0 131
adam@0 132 unset _libcurl_wanted
adam@0 133 fi
adam@0 134
adam@0 135 if test $_libcurl_try_link = yes ; then
adam@0 136
adam@0 137 # we didn't find curl-config, so let's see if the user-supplied
adam@0 138 # link line (or failing that, "-lcurl") is enough.
adam@0 139 LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
adam@0 140
adam@0 141 AC_CACHE_CHECK([whether libcurl is usable],
adam@0 142 [libcurl_cv_lib_curl_usable],
adam@0 143 [
adam@0 144 _libcurl_save_cppflags=$CPPFLAGS
adam@0 145 CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
adam@0 146 _libcurl_save_libs=$LIBS
adam@0 147 LIBS="$LIBCURL $LIBS"
adam@0 148
adam@0 149 AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
adam@0 150 /* Try and use a few common options to force a failure if we are
adam@0 151 missing symbols or can't link. */
adam@0 152 int x;
adam@0 153 curl_easy_setopt(NULL,CURLOPT_URL,NULL);
adam@0 154 x=CURL_ERROR_SIZE;
adam@0 155 x=CURLOPT_WRITEFUNCTION;
adam@0 156 x=CURLOPT_FILE;
adam@0 157 x=CURLOPT_ERRORBUFFER;
adam@0 158 x=CURLOPT_STDERR;
adam@0 159 x=CURLOPT_VERBOSE;
adam@0 160 ]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
adam@0 161
adam@0 162 CPPFLAGS=$_libcurl_save_cppflags
adam@0 163 LIBS=$_libcurl_save_libs
adam@0 164 unset _libcurl_save_cppflags
adam@0 165 unset _libcurl_save_libs
adam@0 166 ])
adam@0 167
adam@0 168 if test $libcurl_cv_lib_curl_usable = yes ; then
adam@0 169
adam@0 170 # Does curl_free() exist in this version of libcurl?
adam@0 171 # If not, fake it with free()
adam@0 172
adam@0 173 _libcurl_save_cppflags=$CPPFLAGS
adam@0 174 CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
adam@0 175 _libcurl_save_libs=$LIBS
adam@0 176 LIBS="$LIBS $LIBCURL"
adam@0 177
adam@0 178 AC_CHECK_FUNC(curl_free,,
adam@0 179 AC_DEFINE(curl_free,free,
adam@0 180 [Define curl_free() as free() if our version of curl lacks curl_free.]))
adam@0 181
adam@0 182 CPPFLAGS=$_libcurl_save_cppflags
adam@0 183 LIBS=$_libcurl_save_libs
adam@0 184 unset _libcurl_save_cppflags
adam@0 185 unset _libcurl_save_libs
adam@0 186
adam@0 187 AC_DEFINE(HAVE_LIBCURL,1,
adam@0 188 [Define to 1 if you have a functional curl library.])
adam@0 189 AC_SUBST(LIBCURL_CPPFLAGS)
adam@0 190 AC_SUBST(LIBCURL)
adam@0 191
adam@0 192 for _libcurl_feature in $_libcurl_features ; do
adam@0 193 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
adam@0 194 eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
adam@0 195 done
adam@0 196
adam@0 197 if test "x$_libcurl_protocols" = "x" ; then
adam@0 198
adam@0 199 # We don't have --protocols, so just assume that all
adam@0 200 # protocols are available
adam@0 201 _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
adam@0 202
adam@0 203 if test x$libcurl_feature_SSL = xyes ; then
adam@0 204 _libcurl_protocols="$_libcurl_protocols HTTPS"
adam@0 205
adam@0 206 # FTPS wasn't standards-compliant until version
adam@0 207 # 7.11.0 (0x070b00 == 461568)
adam@0 208 if test $_libcurl_version -ge 461568; then
adam@0 209 _libcurl_protocols="$_libcurl_protocols FTPS"
adam@0 210 fi
adam@0 211 fi
adam@0 212
adam@0 213 # RTSP, IMAP, POP3 and SMTP were added in
adam@0 214 # 7.20.0 (0x071400 == 463872)
adam@0 215 if test $_libcurl_version -ge 463872; then
adam@0 216 _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
adam@0 217 fi
adam@0 218 fi
adam@0 219
adam@0 220 for _libcurl_protocol in $_libcurl_protocols ; do
adam@0 221 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
adam@0 222 eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
adam@0 223 done
adam@0 224 else
adam@0 225 unset LIBCURL
adam@0 226 unset LIBCURL_CPPFLAGS
adam@0 227 fi
adam@0 228 fi
adam@0 229
adam@0 230 unset _libcurl_try_link
adam@0 231 unset _libcurl_version_parse
adam@0 232 unset _libcurl_config
adam@0 233 unset _libcurl_feature
adam@0 234 unset _libcurl_features
adam@0 235 unset _libcurl_protocol
adam@0 236 unset _libcurl_protocols
adam@0 237 unset _libcurl_version
adam@0 238 unset _libcurl_ldflags
adam@0 239 fi
adam@0 240
adam@0 241 if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
adam@0 242 # This is the IF-NO path
adam@0 243 ifelse([$4],,:,[$4])
adam@0 244 else
adam@0 245 # This is the IF-YES path
adam@0 246 ifelse([$3],,:,[$3])
adam@0 247 fi
adam@0 248
adam@0 249 unset _libcurl_with
adam@0 250 ])dnl