113498266Sopenharmony_ci#*************************************************************************** 213498266Sopenharmony_ci# _ _ ____ _ 313498266Sopenharmony_ci# Project ___| | | | _ \| | 413498266Sopenharmony_ci# / __| | | | |_) | | 513498266Sopenharmony_ci# | (__| |_| | _ <| |___ 613498266Sopenharmony_ci# \___|\___/|_| \_\_____| 713498266Sopenharmony_ci# 813498266Sopenharmony_ci# Copyright (C) David Shaw <dshaw@jabberwocky.com> 913498266Sopenharmony_ci# 1013498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which 1113498266Sopenharmony_ci# you should have received as part of this distribution. The terms 1213498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html. 1313498266Sopenharmony_ci# 1413498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell 1513498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is 1613498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file. 1713498266Sopenharmony_ci# 1813498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 1913498266Sopenharmony_ci# KIND, either express or implied. 2013498266Sopenharmony_ci# 2113498266Sopenharmony_ci# SPDX-License-Identifier: curl 2213498266Sopenharmony_ci# 2313498266Sopenharmony_ci########################################################################### 2413498266Sopenharmony_ci# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION], 2513498266Sopenharmony_ci# [ACTION-IF-YES], [ACTION-IF-NO]) 2613498266Sopenharmony_ci# ---------------------------------------------------------- 2713498266Sopenharmony_ci# David Shaw <dshaw@jabberwocky.com> May-09-2006 2813498266Sopenharmony_ci# 2913498266Sopenharmony_ci# Checks for libcurl. DEFAULT-ACTION is the string yes or no to 3013498266Sopenharmony_ci# specify whether to default to --with-libcurl or --without-libcurl. 3113498266Sopenharmony_ci# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the 3213498266Sopenharmony_ci# minimum version of libcurl to accept. Pass the version as a regular 3313498266Sopenharmony_ci# version number like 7.10.1. If not supplied, any version is 3413498266Sopenharmony_ci# accepted. ACTION-IF-YES is a list of shell commands to run if 3513498266Sopenharmony_ci# libcurl was successfully found and passed the various tests. 3613498266Sopenharmony_ci# ACTION-IF-NO is a list of shell commands that are run otherwise. 3713498266Sopenharmony_ci# Note that using --without-libcurl does run ACTION-IF-NO. 3813498266Sopenharmony_ci# 3913498266Sopenharmony_ci# This macro #defines HAVE_LIBCURL if a working libcurl setup is 4013498266Sopenharmony_ci# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary 4113498266Sopenharmony_ci# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are 4213498266Sopenharmony_ci# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy 4313498266Sopenharmony_ci# where yyy are the various protocols supported by libcurl. Both xxx 4413498266Sopenharmony_ci# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of 4513498266Sopenharmony_ci# the macro for the complete list of possible defines. Shell 4613498266Sopenharmony_ci# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also 4713498266Sopenharmony_ci# defined to 'yes' for those features and protocols that were found. 4813498266Sopenharmony_ci# Note that xxx and yyy keep the same capitalization as in the 4913498266Sopenharmony_ci# curl-config list (e.g. it's "HTTP" and not "http"). 5013498266Sopenharmony_ci# 5113498266Sopenharmony_ci# Users may override the detected values by doing something like: 5213498266Sopenharmony_ci# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure 5313498266Sopenharmony_ci# 5413498266Sopenharmony_ci# For the sake of sanity, this macro assumes that any libcurl that is found is 5513498266Sopenharmony_ci# after version 7.7.2, the first version that included the curl-config script. 5613498266Sopenharmony_ci# Note that it is important for people packaging binary versions of libcurl to 5713498266Sopenharmony_ci# include this script! Without curl-config, we can only guess what protocols 5813498266Sopenharmony_ci# are available, or use curl_version_info to figure it out at runtime. 5913498266Sopenharmony_ci 6013498266Sopenharmony_ciAC_DEFUN([LIBCURL_CHECK_CONFIG], 6113498266Sopenharmony_ci[ 6213498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL]) 6313498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4]) 6413498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6]) 6513498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz]) 6613498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS]) 6713498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN]) 6813498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI]) 6913498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM]) 7013498266Sopenharmony_ci 7113498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP]) 7213498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS]) 7313498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP]) 7413498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS]) 7513498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE]) 7613498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET]) 7713498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP]) 7813498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT]) 7913498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP]) 8013498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP]) 8113498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3]) 8213498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP]) 8313498266Sopenharmony_ci AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP]) 8413498266Sopenharmony_ci 8513498266Sopenharmony_ci AC_ARG_WITH(libcurl, 8613498266Sopenharmony_ci AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]), 8713498266Sopenharmony_ci [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])]) 8813498266Sopenharmony_ci 8913498266Sopenharmony_ci if test "$_libcurl_with" != "no" ; then 9013498266Sopenharmony_ci 9113498266Sopenharmony_ci AC_PROG_AWK 9213498266Sopenharmony_ci 9313498266Sopenharmony_ci _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'" 9413498266Sopenharmony_ci 9513498266Sopenharmony_ci _libcurl_try_link=yes 9613498266Sopenharmony_ci 9713498266Sopenharmony_ci if test -d "$_libcurl_with" ; then 9813498266Sopenharmony_ci LIBCURL_CPPFLAGS="-I$withval/include" 9913498266Sopenharmony_ci _libcurl_ldflags="-L$withval/lib" 10013498266Sopenharmony_ci AC_PATH_PROG([_libcurl_config],[curl-config],[], 10113498266Sopenharmony_ci ["$withval/bin"]) 10213498266Sopenharmony_ci else 10313498266Sopenharmony_ci AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH]) 10413498266Sopenharmony_ci fi 10513498266Sopenharmony_ci 10613498266Sopenharmony_ci if test x$_libcurl_config != "x" ; then 10713498266Sopenharmony_ci AC_CACHE_CHECK([for the version of libcurl], 10813498266Sopenharmony_ci [libcurl_cv_lib_curl_version], 10913498266Sopenharmony_ci [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`]) 11013498266Sopenharmony_ci 11113498266Sopenharmony_ci _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse` 11213498266Sopenharmony_ci _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse` 11313498266Sopenharmony_ci 11413498266Sopenharmony_ci if test $_libcurl_wanted -gt 0 ; then 11513498266Sopenharmony_ci AC_CACHE_CHECK([for libcurl >= version $2], 11613498266Sopenharmony_ci [libcurl_cv_lib_version_ok], 11713498266Sopenharmony_ci [ 11813498266Sopenharmony_ci if test $_libcurl_version -ge $_libcurl_wanted ; then 11913498266Sopenharmony_ci libcurl_cv_lib_version_ok=yes 12013498266Sopenharmony_ci else 12113498266Sopenharmony_ci libcurl_cv_lib_version_ok=no 12213498266Sopenharmony_ci fi 12313498266Sopenharmony_ci ]) 12413498266Sopenharmony_ci fi 12513498266Sopenharmony_ci 12613498266Sopenharmony_ci if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then 12713498266Sopenharmony_ci if test x"$LIBCURL_CPPFLAGS" = "x" ; then 12813498266Sopenharmony_ci LIBCURL_CPPFLAGS=`$_libcurl_config --cflags` 12913498266Sopenharmony_ci fi 13013498266Sopenharmony_ci if test x"$LIBCURL" = "x" ; then 13113498266Sopenharmony_ci LIBCURL=`$_libcurl_config --libs` 13213498266Sopenharmony_ci 13313498266Sopenharmony_ci # This is so silly, but Apple actually has a bug in their 13413498266Sopenharmony_ci # curl-config script. Fixed in Tiger, but there are still 13513498266Sopenharmony_ci # lots of Panther installs around. 13613498266Sopenharmony_ci case "${host}" in 13713498266Sopenharmony_ci powerpc-apple-darwin7*) 13813498266Sopenharmony_ci LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'` 13913498266Sopenharmony_ci ;; 14013498266Sopenharmony_ci esac 14113498266Sopenharmony_ci fi 14213498266Sopenharmony_ci 14313498266Sopenharmony_ci # All curl-config scripts support --feature 14413498266Sopenharmony_ci _libcurl_features=`$_libcurl_config --feature` 14513498266Sopenharmony_ci 14613498266Sopenharmony_ci # Is it modern enough to have --protocols? (7.12.4) 14713498266Sopenharmony_ci if test $_libcurl_version -ge 461828 ; then 14813498266Sopenharmony_ci _libcurl_protocols=`$_libcurl_config --protocols` 14913498266Sopenharmony_ci fi 15013498266Sopenharmony_ci else 15113498266Sopenharmony_ci _libcurl_try_link=no 15213498266Sopenharmony_ci fi 15313498266Sopenharmony_ci 15413498266Sopenharmony_ci unset _libcurl_wanted 15513498266Sopenharmony_ci fi 15613498266Sopenharmony_ci 15713498266Sopenharmony_ci if test $_libcurl_try_link = yes ; then 15813498266Sopenharmony_ci 15913498266Sopenharmony_ci # we did not find curl-config, so let's see if the user-supplied 16013498266Sopenharmony_ci # link line (or failing that, "-lcurl") is enough. 16113498266Sopenharmony_ci LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"} 16213498266Sopenharmony_ci 16313498266Sopenharmony_ci AC_CACHE_CHECK([whether libcurl is usable], 16413498266Sopenharmony_ci [libcurl_cv_lib_curl_usable], 16513498266Sopenharmony_ci [ 16613498266Sopenharmony_ci _libcurl_save_cppflags=$CPPFLAGS 16713498266Sopenharmony_ci CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS" 16813498266Sopenharmony_ci _libcurl_save_libs=$LIBS 16913498266Sopenharmony_ci LIBS="$LIBCURL $LIBS" 17013498266Sopenharmony_ci 17113498266Sopenharmony_ci AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[ 17213498266Sopenharmony_ci/* Try and use a few common options to force a failure if we are 17313498266Sopenharmony_ci missing symbols or cannot link. */ 17413498266Sopenharmony_ciint x; 17513498266Sopenharmony_cicurl_easy_setopt(NULL,CURLOPT_URL,NULL); 17613498266Sopenharmony_cix=CURL_ERROR_SIZE; 17713498266Sopenharmony_cix=CURLOPT_WRITEFUNCTION; 17813498266Sopenharmony_cix=CURLOPT_WRITEDATA; 17913498266Sopenharmony_cix=CURLOPT_ERRORBUFFER; 18013498266Sopenharmony_cix=CURLOPT_STDERR; 18113498266Sopenharmony_cix=CURLOPT_VERBOSE; 18213498266Sopenharmony_ciif (x) {;} 18313498266Sopenharmony_ci]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no) 18413498266Sopenharmony_ci 18513498266Sopenharmony_ci CPPFLAGS=$_libcurl_save_cppflags 18613498266Sopenharmony_ci LIBS=$_libcurl_save_libs 18713498266Sopenharmony_ci unset _libcurl_save_cppflags 18813498266Sopenharmony_ci unset _libcurl_save_libs 18913498266Sopenharmony_ci ]) 19013498266Sopenharmony_ci 19113498266Sopenharmony_ci if test $libcurl_cv_lib_curl_usable = yes ; then 19213498266Sopenharmony_ci 19313498266Sopenharmony_ci # Does curl_free() exist in this version of libcurl? 19413498266Sopenharmony_ci # If not, fake it with free() 19513498266Sopenharmony_ci 19613498266Sopenharmony_ci _libcurl_save_cppflags=$CPPFLAGS 19713498266Sopenharmony_ci CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS" 19813498266Sopenharmony_ci _libcurl_save_libs=$LIBS 19913498266Sopenharmony_ci LIBS="$LIBS $LIBCURL" 20013498266Sopenharmony_ci 20113498266Sopenharmony_ci AC_CHECK_DECL([curl_free],[], 20213498266Sopenharmony_ci [AC_DEFINE([curl_free],[free], 20313498266Sopenharmony_ci [Define curl_free() as free() if our version of curl lacks curl_free.])], 20413498266Sopenharmony_ci [[#include <curl/curl.h>]]) 20513498266Sopenharmony_ci 20613498266Sopenharmony_ci CPPFLAGS=$_libcurl_save_cppflags 20713498266Sopenharmony_ci LIBS=$_libcurl_save_libs 20813498266Sopenharmony_ci unset _libcurl_save_cppflags 20913498266Sopenharmony_ci unset _libcurl_save_libs 21013498266Sopenharmony_ci 21113498266Sopenharmony_ci AC_DEFINE(HAVE_LIBCURL,1, 21213498266Sopenharmony_ci [Define to 1 if you have a functional curl library.]) 21313498266Sopenharmony_ci AC_SUBST(LIBCURL_CPPFLAGS) 21413498266Sopenharmony_ci AC_SUBST(LIBCURL) 21513498266Sopenharmony_ci 21613498266Sopenharmony_ci for _libcurl_feature in $_libcurl_features ; do 21713498266Sopenharmony_ci AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1]) 21813498266Sopenharmony_ci eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes 21913498266Sopenharmony_ci done 22013498266Sopenharmony_ci 22113498266Sopenharmony_ci if test "x$_libcurl_protocols" = "x" ; then 22213498266Sopenharmony_ci 22313498266Sopenharmony_ci # We do not have --protocols, so just assume that all 22413498266Sopenharmony_ci # protocols are available 22513498266Sopenharmony_ci _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP" 22613498266Sopenharmony_ci 22713498266Sopenharmony_ci if test x$libcurl_feature_SSL = xyes ; then 22813498266Sopenharmony_ci _libcurl_protocols="$_libcurl_protocols HTTPS" 22913498266Sopenharmony_ci 23013498266Sopenharmony_ci # FTPS was not standards-compliant until version 23113498266Sopenharmony_ci # 7.11.0 (0x070b00 == 461568) 23213498266Sopenharmony_ci if test $_libcurl_version -ge 461568; then 23313498266Sopenharmony_ci _libcurl_protocols="$_libcurl_protocols FTPS" 23413498266Sopenharmony_ci fi 23513498266Sopenharmony_ci fi 23613498266Sopenharmony_ci 23713498266Sopenharmony_ci # RTSP, IMAP, POP3 and SMTP were added in 23813498266Sopenharmony_ci # 7.20.0 (0x071400 == 463872) 23913498266Sopenharmony_ci if test $_libcurl_version -ge 463872; then 24013498266Sopenharmony_ci _libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP" 24113498266Sopenharmony_ci fi 24213498266Sopenharmony_ci fi 24313498266Sopenharmony_ci 24413498266Sopenharmony_ci for _libcurl_protocol in $_libcurl_protocols ; do 24513498266Sopenharmony_ci AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1]) 24613498266Sopenharmony_ci eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes 24713498266Sopenharmony_ci done 24813498266Sopenharmony_ci else 24913498266Sopenharmony_ci unset LIBCURL 25013498266Sopenharmony_ci unset LIBCURL_CPPFLAGS 25113498266Sopenharmony_ci fi 25213498266Sopenharmony_ci fi 25313498266Sopenharmony_ci 25413498266Sopenharmony_ci unset _libcurl_try_link 25513498266Sopenharmony_ci unset _libcurl_version_parse 25613498266Sopenharmony_ci unset _libcurl_config 25713498266Sopenharmony_ci unset _libcurl_feature 25813498266Sopenharmony_ci unset _libcurl_features 25913498266Sopenharmony_ci unset _libcurl_protocol 26013498266Sopenharmony_ci unset _libcurl_protocols 26113498266Sopenharmony_ci unset _libcurl_version 26213498266Sopenharmony_ci unset _libcurl_ldflags 26313498266Sopenharmony_ci fi 26413498266Sopenharmony_ci 26513498266Sopenharmony_ci if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then 26613498266Sopenharmony_ci # This is the IF-NO path 26713498266Sopenharmony_ci ifelse([$4],,:,[$4]) 26813498266Sopenharmony_ci else 26913498266Sopenharmony_ci # This is the IF-YES path 27013498266Sopenharmony_ci ifelse([$3],,:,[$3]) 27113498266Sopenharmony_ci fi 27213498266Sopenharmony_ci 27313498266Sopenharmony_ci unset _libcurl_with 27413498266Sopenharmony_ci]) 275