3 # This file contains macros that search for specific libraries that are
4 # required or utilized by Amanda.
12 # Check for LIBCURL support. Sets the shell variable HAVE_CURL to "yes" or
13 # "no" depending on the result of the test. If CURL is found, the necessary
14 # compiler flags are added, and a few other type checks are performed.
16 # Note that libcurl itself defines a number of useful symbols as well; see
17 # the libcurl distribution for details.
19 AC_DEFUN([AMANDA_CHECK_LIBCURL], [
21 sparc-sun-solaris2.10) # Solaris 10
22 # curl is not in the LD_LIBRARY_PATH on Solaris 10, so we search
23 # for it in a few common paths; we then extract the -L flags and
24 # translate them to -R flags, as required by the runtime linker.
25 AC_PATH_PROG(CURL_CONFIG, curl-config, [], $LOCSYSPATH:/opt/csw/bin:/usr/local/bin:/opt/local/bin)
26 if test -n "$CURL_CONFIG"; then
27 curlflags=`$CURL_CONFIG --libs 2>/dev/null`
28 for flag in curlflags; do
30 -L*) LDFLAGS="$LDFLAGS "`echo "x$flag" | sed -e 's/^x-L/-R/'`;;
37 LIBCURL_CHECK_CONFIG(yes, 7.10.0, HAVE_CURL=yes, HAVE_CURL=no)
38 if test x"$HAVE_CURL" = x"yes"; then
39 AMANDA_ADD_LIBS($LIBCURL)
40 AMANDA_ADD_CPPFLAGS($LIBCURL_CPPFLAGS)
42 AMANDA_CHECK_TYPE([curl_off_t], [off_t], [curl/curl.h])
52 # Check for HMAC support in -lcrypto. If found, the shell
53 # variable HAVE_HMAC will be set to 'yes'. The appropriate one of
54 # HAVE_OPENSSL_HMAC_H, HAVE_CRYPTO_HMAC_H, and HAVE_HMAC_H are also
55 # defined via AC_CHECK_HEADERS.
57 AC_DEFUN([AMANDA_CHECK_HMAC], [
59 AC_CHECK_LIB([crypto], [HMAC_CTX_init], [], [HAVE_HMAC=no])
62 AC_CHECK_HEADERS([openssl/hmac.h crypto/hmac.h hmac.h],
63 [found_hmac_h=yes; break])
64 if test x"$found_hmac_h" != x"yes"; then
71 # AMANDA_CHECK_NET_LIBS
75 # Check for the libraries we'll need to use sockets, etc.
77 AC_DEFUN([AMANDA_CHECK_NET_LIBS], [
78 # Make sure we don't use -lnsl and -lsun on Irix systems.
81 AC_CHECK_LIB(socket,main)
84 AC_CHECK_LIB(resolv,main)
85 AC_CHECK_LIB(nsl,main)
86 AC_CHECK_LIB(socket,main)
87 AC_CHECK_LIB(sun,main)
98 # Search for glib. This is basically a wrapper for AM_PATH_GLIB_2_0, with
99 # the addition of system-specific configuration to convince Amanda to compile
100 # "out of the box" on more boxes.
102 AC_DEFUN([AMANDA_CHECK_GLIB], [
103 AC_ARG_VAR(GLIB_CFLAGS, [CFLAGS to build with glib; disables use of pkg-config])
104 AC_ARG_VAR(GLIB_LIBS, [libraries to build with glib; disables use of pkg-config])
105 AC_ARG_VAR(GLIB_GENMARSHAL, [genmarshal binary to use with glib; disables use of pkg-config])
106 AC_ARG_VAR(GOBJECT_QUERY, [gobject_query binary to use with glib; disables use of pkg-config])
107 AC_ARG_VAR(GLIB_MKENUMS, [mkenums binary to use with glib; disables use of pkg-config])
109 # if any of the precious variables are set, disable the pkg-config run
111 test x"$GLIB_CFLAGS" = x"" || explicit_glib=yes
112 test x"$GLIB_LIBS" = x"" || explicit_glib=yes
113 test x"$GLIB_GENMARSHAL" = x"" || explicit_glib=yes
114 test x"$GOBJECT_QUERY" = x"" || explicit_glib=yes
115 test x"$GLIB_MKENUMS" = x"" || explicit_glib=yes
117 if test x"$explicit_glib" = x"no"; then
118 # search for pkg-config, which the glib configuration uses, adding a few
119 # system-specific search paths.
120 AC_PATH_PROG(PKG_CONFIG, pkg-config, [], $LOCSYSPATH:/opt/csw/bin:/usr/local/bin:/opt/local/bin)
123 sparc-sun-solaris2.8) # Solaris 8
124 # give the linker a runtime search path; pkg-config doesn't supply this.
125 # Users could also specify this with LD_LIBRARY_PATH to both ./configure
126 # and make. Adding this support here makes straight './configure; make'
127 # "just work" on Solaris 8
128 if test -n "$PKG_CONFIG"; then
129 glib_R_flag=`$PKG_CONFIG glib-2.0 --libs-only-L 2>/dev/null | sed -e 's/-L/-R/g'`
130 LDFLAGS="$LDFLAGS $glib_R_flag"
135 AM_PATH_GLIB_2_0(2.2.0,,[
136 AC_MSG_ERROR(glib not found or too old; See http://wiki.zmanda.com/index.php/Installation for help)
137 ], gmodule gobject gthread)
139 AC_MSG_ERROR(explicit glib)
142 # GLIB_CPPFLAGS is not set by autoconf, yet GLIB_CFLAGS contains what GLIB_CPPFLAGS should contain.
143 AMANDA_ADD_CPPFLAGS($GLIB_CFLAGS)
144 AMANDA_ADD_LIBS($GLIB_LIBS)
147 # LIBCURL_CHECK_CONFIG is from the libcurl
148 # distribution and licensed under the BSD license:
149 # Copyright (c) 1996 - 2007, Daniel Stenberg, <daniel@haxx.se>.
151 # All rights reserved.
153 # Permission to use, copy, modify, and distribute this software for any purpose
154 # with or without fee is hereby granted, provided that the above copyright
155 # notice and this permission notice appear in all copies.
157 # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
158 # [ACTION-IF-YES], [ACTION-IF-NO])
159 # ----------------------------------------------------------
160 # David Shaw <dshaw@jabberwocky.com> May-09-2006
162 # Checks for libcurl. DEFAULT-ACTION is the string yes or no to
163 # specify whether to default to --with-libcurl or --without-libcurl.
164 # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
165 # minimum version of libcurl to accept. Pass the version as a regular
166 # version number like 7.10.1. If not supplied, any version is
167 # accepted. ACTION-IF-YES is a list of shell commands to run if
168 # libcurl was successfully found and passed the various tests.
169 # ACTION-IF-NO is a list of shell commands that are run otherwise.
170 # Note that using --without-libcurl does run ACTION-IF-NO.
172 # This macro #defines HAVE_LIBCURL if a working libcurl setup is
173 # found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
174 # values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
175 # the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
176 # where yyy are the various protocols supported by libcurl. Both xxx
177 # and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
178 # the macro for the complete list of possible defines. Shell
179 # variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
180 # defined to 'yes' for those features and protocols that were found.
181 # Note that xxx and yyy keep the same capitalization as in the
182 # curl-config list (e.g. it's "HTTP" and not "http").
184 # Users may override the detected values by doing something like:
185 # LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
187 # For the sake of sanity, this macro assumes that any libcurl that is
188 # found is after version 7.7.2, the first version that included the
189 # curl-config script. Note that it is very important for people
190 # packaging binary versions of libcurl to include this script!
191 # Without curl-config, we can only guess what protocols are available,
192 # or use curl_version_info to figure it out at runtime.
194 AC_DEFUN([LIBCURL_CHECK_CONFIG],
196 AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
197 AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
198 AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
199 AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
200 AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
201 AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
202 AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
203 AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
205 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
206 AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
207 AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
208 AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
209 AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
210 AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
211 AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
212 AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
213 AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
216 AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
217 [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
219 if test "$_libcurl_with" != "no" ; then
223 _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
225 _libcurl_try_link=yes
227 if test -d "$_libcurl_with" ; then
228 LIBCURL_CPPFLAGS="-I$withval/include"
229 _libcurl_ldflags="-L$withval/lib"
230 AC_PATH_PROG([_libcurl_config],[curl-config],["$withval/bin"],["$withval/bin"])
232 AC_PATH_PROG([_libcurl_config],[curl-config])
235 if test x$_libcurl_config != "x" ; then
236 AC_CACHE_CHECK([for the version of libcurl],
237 [libcurl_cv_lib_curl_version],
238 [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
240 _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
241 _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
243 if test $_libcurl_wanted -gt 0 ; then
244 AC_CACHE_CHECK([for libcurl >= version $2],
245 [libcurl_cv_lib_version_ok],
247 if test $_libcurl_version -ge $_libcurl_wanted ; then
248 libcurl_cv_lib_version_ok=yes
250 libcurl_cv_lib_version_ok=no
255 if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
256 if test x"$LIBCURL_CPPFLAGS" = "x" ; then
257 LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
259 if test x"$LIBCURL" = "x" ; then
260 LIBCURL=`$_libcurl_config --libs`
262 # This is so silly, but Apple actually has a bug in their
263 # curl-config script. Fixed in Tiger, but there are still
264 # lots of Panther installs around.
266 powerpc-apple-darwin7*)
267 LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
272 # All curl-config scripts support --feature
273 _libcurl_features=`$_libcurl_config --feature`
275 # Is it modern enough to have --protocols? (7.12.4)
276 if test $_libcurl_version -ge 461828 ; then
277 _libcurl_protocols=`$_libcurl_config --protocols`
283 unset _libcurl_wanted
286 if test $_libcurl_try_link = yes ; then
288 # we didn't find curl-config, so let's see if the user-supplied
289 # link line (or failing that, "-lcurl") is enough.
290 LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
292 AC_CACHE_CHECK([whether libcurl is usable],
293 [libcurl_cv_lib_curl_usable],
295 _libcurl_save_cppflags=$CPPFLAGS
296 CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
297 _libcurl_save_libs=$LIBS
298 LIBS="$LIBCURL $LIBS"
300 AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
301 /* Try and use a few common options to force a failure if we are
302 missing symbols or can't link. */
304 curl_easy_setopt(NULL,CURLOPT_URL,NULL);
306 x=CURLOPT_WRITEFUNCTION;
308 x=CURLOPT_ERRORBUFFER;
311 ]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
313 CPPFLAGS=$_libcurl_save_cppflags
314 LIBS=$_libcurl_save_libs
315 unset _libcurl_save_cppflags
316 unset _libcurl_save_libs
319 if test $libcurl_cv_lib_curl_usable = yes ; then
321 # Does curl_free() exist in this version of libcurl?
322 # If not, fake it with free()
324 _libcurl_save_cppflags=$CPPFLAGS
325 CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
326 _libcurl_save_libs=$LIBS
327 LIBS="$LIBS $LIBCURL"
329 AC_CHECK_FUNC(curl_free,,
330 AC_DEFINE(curl_free,free,
331 [Define curl_free() as free() if our version of curl lacks curl_free.]))
333 CPPFLAGS=$_libcurl_save_cppflags
334 LIBS=$_libcurl_save_libs
335 unset _libcurl_save_cppflags
336 unset _libcurl_save_libs
338 AC_DEFINE(HAVE_LIBCURL,1,
339 [Define to 1 if you have a functional curl library.])
340 AC_SUBST(LIBCURL_CPPFLAGS)
343 for _libcurl_feature in $_libcurl_features ; do
344 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
345 eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
348 if test "x$_libcurl_protocols" = "x" ; then
350 # We don't have --protocols, so just assume that all
351 # protocols are available
352 _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT"
354 if test x$libcurl_feature_SSL = xyes ; then
355 _libcurl_protocols="$_libcurl_protocols HTTPS"
357 # FTPS wasn't standards-compliant until version
359 if test $_libcurl_version -ge 461568; then
360 _libcurl_protocols="$_libcurl_protocols FTPS"
365 for _libcurl_protocol in $_libcurl_protocols ; do
366 AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
367 eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
371 unset LIBCURL_CPPFLAGS
375 unset _libcurl_try_link
376 unset _libcurl_version_parse
377 unset _libcurl_config
378 unset _libcurl_feature
379 unset _libcurl_features
380 unset _libcurl_protocol
381 unset _libcurl_protocols
382 unset _libcurl_version
383 unset _libcurl_ldflags
386 if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
387 # This is the IF-NO path
390 # This is the IF-YES path