summaryrefslogtreecommitdiffabout
path: root/acinclude.d
authorMichael Krelin <hacker@klever.net>2005-07-19 13:08:32 (UTC)
committer Michael Krelin <hacker@klever.net>2005-07-19 13:08:32 (UTC)
commit4c82851dd5d5644a89d4f269079bf901f763ee33 (patch) (unidiff)
treeb64c8b3c9a1be88e2a9c3f762272e0b4509ba7d9 /acinclude.d
parent907343b0c973eb295bec8795902a6d49744e9174 (diff)
downloadlibopkele-4c82851dd5d5644a89d4f269079bf901f763ee33.zip
libopkele-4c82851dd5d5644a89d4f269079bf901f763ee33.tar.gz
libopkele-4c82851dd5d5644a89d4f269079bf901f763ee33.tar.bz2
initial commit of libopkele - OpenID support library
Diffstat (limited to 'acinclude.d') (more/less context) (ignore whitespace changes)
-rw-r--r--acinclude.d/libcurl.m4209
1 files changed, 209 insertions, 0 deletions
diff --git a/acinclude.d/libcurl.m4 b/acinclude.d/libcurl.m4
new file mode 100644
index 0000000..e80c206
--- a/dev/null
+++ b/acinclude.d/libcurl.m4
@@ -0,0 +1,209 @@
1# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
2# [ACTION-IF-YES], [ACTION-IF-NO])
3# ----------------------------------------------------------
4# David Shaw <dshaw@jabberwocky.com> Jan-23-2005
5#
6# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
7# specify whether to default to --with-libcurl or --without-libcurl.
8# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
9# minimum version of libcurl to accept. Pass the version as a regular
10# version number like 7.10.1. If not supplied, any version is
11# accepted. ACTION-IF-YES is a list of shell commands to run if
12# libcurl was successfully found and passed the various tests.
13# ACTION-IF-NO is a list of shell commands that are run otherwise.
14# Note that using --without-libcurl does run ACTION-IF-NO.
15#
16# This macro defines HAVE_LIBCURL if a working libcurl setup is found,
17# and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary values.
18# Other useful defines are LIBCURL_FEATURE_xxx where xxx are the
19# various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
20# where yyy are the various protocols supported by libcurl. Both xxx
21# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
22# the macro for the complete list of possible defines. Shell
23# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
24# defined to 'yes' for those features and protocols that were found.
25# Note that xxx and yyy keep the same capitalization as in the
26# curl-config list (e.g. it's "HTTP" and not "http").
27#
28# Users may override the detected values by doing something like:
29# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
30#
31# For the sake of sanity, this macro assumes that any libcurl that is
32# found is after version 7.7.2, the first version that included the
33# curl-config script. Note that it is very important for people
34# packaging binary versions of libcurl to include this script!
35# Without curl-config, we can only make educated guesses as to what
36# protocols are available. Specifically, we assume that all of HTTP,
37# FTP, GOPHER, FILE, TELNET, LDAP, and DICT exist, and (if SSL exists)
38# HTTPS is present. All of these protocols existed when libcurl was
39# first created in version 7, so this is a safe assumption. If the
40# version is 7.11.0 or later, FTPS is assumed to be present as well.
41# FTPS existed before then, but was not yet fully standards compliant.
42
43AC_DEFUN([LIBCURL_CHECK_CONFIG],
44[
45 AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
46 AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
47 AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
48 AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
49 AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
50
51 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
52 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
53 AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
54 AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
55 AH_TEMPLATE([LIBCURL_PROTOCOL_GOPHER],[Defined if libcurl supports GOPHER])
56 AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
57 AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
58 AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
59 AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
60
61 AC_ARG_WITH(libcurl,
62 AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
63 [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
64
65 if test "$_libcurl_with" != "no" ; then
66
67 AC_PROG_AWK
68
69 _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
70
71 _libcurl_try_link=yes
72
73 if test -d "$_libcurl_with" ; then
74 CPPFLAGS="${CPPFLAGS} -I$withval/include"
75 LDFLAGS="${LDFLAGS} -L$withval/lib"
76 fi
77
78 AC_PATH_PROG([_libcurl_config],[curl-config])
79
80 if test x$_libcurl_config != "x" ; then
81 AC_CACHE_CHECK([for the version of libcurl],
82 [libcurl_cv_lib_curl_version],
83 [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
84
85 _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
86 _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
87
88 if test $_libcurl_wanted -gt 0 ; then
89 AC_CACHE_CHECK([for libcurl >= version $2],
90 [libcurl_cv_lib_version_ok],
91 [
92 if test $_libcurl_version -ge $_libcurl_wanted ; then
93 libcurl_cv_lib_version_ok=yes
94 else
95 libcurl_cv_lib_version_ok=no
96 fi
97 ])
98 fi
99
100 if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
101 if test x"$LIBCURL_CPPFLAGS" = "x" ; then
102 LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
103 fi
104 if test x"$LIBCURL" = "x" ; then
105 LIBCURL=`$_libcurl_config --libs`
106 fi
107
108 # All curl-config scripts support --feature
109 _libcurl_features=`$_libcurl_config --feature`
110
111 # Is it modern enough to have --protocols? (7.12.4)
112 if test $_libcurl_version -ge 461828 ; then
113 _libcurl_protocols=`$_libcurl_config --protocols`
114 fi
115 else
116 _libcurl_try_link=no
117 fi
118
119 unset _libcurl_wanted
120 fi
121
122 if test $_libcurl_try_link = yes ; then
123
124 # we didn't find curl-config, so let's see if the user-supplied
125 # link line (or failing that, "-lcurl") is enough.
126 LIBCURL=${LIBCURL-"-lcurl"}
127
128 AC_CACHE_CHECK([whether libcurl is usable],
129 [libcurl_cv_lib_curl_usable],
130 [
131 _libcurl_save_cppflags=$CPPFLAGS
132 CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
133 _libcurl_save_ldflags=$LDFLAGS
134 LDFLAGS="$LDFLAGS $LIBCURL"
135
136 AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
137/* Try and use a few common options to force a failure if we are
138 missing symbols or can't link. */
139int x;
140curl_easy_setopt(NULL,CURLOPT_URL,NULL);
141x=CURL_ERROR_SIZE;
142x=CURLOPT_WRITEFUNCTION;
143x=CURLOPT_FILE;
144x=CURLOPT_ERRORBUFFER;
145x=CURLOPT_STDERR;
146x=CURLOPT_VERBOSE;
147]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
148
149 CPPFLAGS=$_libcurl_save_cppflags
150 LDFLAGS=$_libcurl_save_ldflags
151 unset _libcurl_save_cppflags
152 unset _libcurl_save_ldflags
153 ])
154
155 if test $libcurl_cv_lib_curl_usable = yes ; then
156 AC_DEFINE(HAVE_LIBCURL,1,
157 [Define to 1 if you have a functional curl library.])
158 AC_SUBST(LIBCURL_CPPFLAGS)
159 AC_SUBST(LIBCURL)
160
161 for _libcurl_feature in $_libcurl_features ; do
162 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
163 eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
164 done
165
166 if test "x$_libcurl_protocols" = "x" ; then
167
168 # We don't have --protocols, so just assume that all
169 # protocols are available
170 _libcurl_protocols="HTTP FTP GOPHER FILE TELNET LDAP DICT"
171
172 if test x$libcurl_feature_SSL = xyes ; then
173 _libcurl_protocols="$_libcurl_protocols HTTPS"
174
175 # FTPS wasn't standards-compliant until version
176 # 7.11.0
177 if test $_libcurl_version -ge 461568; then
178 _libcurl_protocols="$_libcurl_protocols FTPS"
179 fi
180 fi
181 fi
182
183 for _libcurl_protocol in $_libcurl_protocols ; do
184 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
185 eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
186 done
187 fi
188 fi
189
190 unset _libcurl_try_link
191 unset _libcurl_version_parse
192 unset _libcurl_config
193 unset _libcurl_feature
194 unset _libcurl_features
195 unset _libcurl_protocol
196 unset _libcurl_protocols
197 unset _libcurl_version
198 fi
199
200 if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
201 # This is the IF-NO path
202 ifelse([$4],,:,[$4])
203 else
204 # This is the IF-YES path
205 ifelse([$3],,:,[$3])
206 fi
207
208 unset _libcurl_with
209])dnl