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