PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/amanda/branches/amanda-260/config/amanda/libs.m4

#
m4 | 377 lines | 213 code | 47 blank | 117 comment | 0 complexity | 87a84479432e6c2a26617c6b4ec33d50 MD5 | raw file
  1. # OVERVIEW
  2. #
  3. # This file contains macros that search for specific libraries that are
  4. # required or utilized by Amanda.
  5. # SYNOPSIS
  6. #
  7. # AMANDA_CHECK_LIBCURL
  8. #
  9. # OVERVIEW
  10. #
  11. # Check for LIBCURL support. Sets the shell variable HAVE_CURL to "yes" or
  12. # "no" depending on the result of the test. If CURL is found, the necessary
  13. # compiler flags are added, and a few other type checks are performed.
  14. #
  15. # Note that libcurl itself defines a number of useful symbols as well; see
  16. # the libcurl distribution for details.
  17. #
  18. AC_DEFUN([AMANDA_CHECK_LIBCURL], [
  19. case "$target" in
  20. sparc-sun-solaris2.10) # Solaris 10
  21. # curl is not in the LD_LIBRARY_PATH on Solaris 10, so we search
  22. # for it in a few common paths; we then extract the -L flags and
  23. # translate them to -R flags, as required by the runtime linker.
  24. AC_PATH_PROG(CURL_CONFIG, curl-config, [], $LOCSYSPATH:/opt/csw/bin:/usr/local/bin:/opt/local/bin)
  25. if test -n "$CURL_CONFIG"; then
  26. curlflags=`$CURL_CONFIG --libs 2>/dev/null`
  27. for flag in curlflags; do
  28. case $flag in
  29. -L*) LDFLAGS="$LDFLAGS "`echo "x$flag" | sed -e 's/^x-L/-R/'`;;
  30. esac
  31. done
  32. fi
  33. ;;
  34. esac
  35. LIBCURL_CHECK_CONFIG(yes, 7.10.0, HAVE_CURL=yes, HAVE_CURL=no)
  36. if test x"$HAVE_CURL" = x"yes"; then
  37. AMANDA_ADD_LIBS($LIBCURL)
  38. AMANDA_ADD_CPPFLAGS($LIBCURL_CPPFLAGS)
  39. AMANDA_CHECK_TYPE([curl_off_t], [off_t], [curl/curl.h])
  40. fi
  41. ])
  42. # SYNOPSIS
  43. #
  44. # AMANDA_CHECK_HMAC
  45. #
  46. # OVERVIEW
  47. #
  48. # Check for HMAC support in -lcrypto. If found, the shell
  49. # variable HAVE_HMAC will be set to 'yes'. The appropriate one of
  50. # HAVE_OPENSSL_HMAC_H, HAVE_CRYPTO_HMAC_H, and HAVE_HMAC_H are also
  51. # defined via AC_CHECK_HEADERS.
  52. #
  53. AC_DEFUN([AMANDA_CHECK_HMAC], [
  54. HAVE_HMAC=yes
  55. AC_CHECK_LIB([crypto], [HMAC_CTX_init], [], [HAVE_HMAC=no])
  56. found_hmac_h=no
  57. AC_CHECK_HEADERS([openssl/hmac.h crypto/hmac.h hmac.h],
  58. [found_hmac_h=yes; break])
  59. if test x"$found_hmac_h" != x"yes"; then
  60. HAVE_HMAC=no
  61. fi
  62. ])
  63. # SYNOPSIS
  64. #
  65. # AMANDA_CHECK_NET_LIBS
  66. #
  67. # OVERIVEW
  68. #
  69. # Check for the libraries we'll need to use sockets, etc.
  70. #
  71. AC_DEFUN([AMANDA_CHECK_NET_LIBS], [
  72. # Make sure we don't use -lnsl and -lsun on Irix systems.
  73. case "$target" in
  74. *sgi-irix*)
  75. AC_CHECK_LIB(socket,main)
  76. ;;
  77. *)
  78. AC_CHECK_LIB(resolv,main)
  79. AC_CHECK_LIB(nsl,main)
  80. AC_CHECK_LIB(socket,main)
  81. AC_CHECK_LIB(sun,main)
  82. ;;
  83. esac
  84. ])
  85. # SYNOPSIS
  86. #
  87. # AMANDA_CHECK_GLIB
  88. #
  89. # OVERVIEW
  90. #
  91. # Search for glib. This is basically a wrapper for AM_PATH_GLIB_2_0, with
  92. # the addition of system-specific configuration to convince Amanda to compile
  93. # "out of the box" on more boxes.
  94. #
  95. AC_DEFUN([AMANDA_CHECK_GLIB], [
  96. # search for pkg-config, which the glib configuration uses, adding a few
  97. # system-specific search paths.
  98. AC_PATH_PROG(PKG_CONFIG, pkg-config, [], $LOCSYSPATH:/opt/csw/bin:/usr/local/bin:/opt/local/bin)
  99. case "$target" in
  100. sparc-sun-solaris2.8) # Solaris 8
  101. # give the linker a runtime search path; pkg-config doesn't supply this.
  102. # Users could also specify this with LD_LIBRARY_PATH to both ./configure
  103. # and make. Adding this support here makes straight './configure; make'
  104. # "just work" on Solaris 8
  105. if test -n "$PKG_CONFIG"; then
  106. glib_R_flag=`$PKG_CONFIG glib-2.0 --libs-only-L 2>/dev/null | sed -e 's/-L/-R/g'`
  107. LDFLAGS="$LDFLAGS $glib_R_flag"
  108. fi
  109. ;;
  110. esac
  111. AM_PATH_GLIB_2_0(2.2.0,,[
  112. AC_MSG_ERROR(glib not found or too old; See http://wiki.zmanda.com/index.php/Installation for help)
  113. ], gmodule gobject gthread)
  114. AMANDA_ADD_CFLAGS($GLIB_CFLAGS)
  115. AMANDA_ADD_CPPFLAGS($GLIB_CPPFLAGS)
  116. AMANDA_ADD_LIBS($GLIB_LIBS)
  117. ])
  118. # LIBCURL_CHECK_CONFIG is from the libcurl
  119. # distribution and licensed under the BSD license:
  120. # Copyright (c) 1996 - 2007, Daniel Stenberg, <daniel@haxx.se>.
  121. #
  122. # All rights reserved.
  123. #
  124. # Permission to use, copy, modify, and distribute this software for any purpose
  125. # with or without fee is hereby granted, provided that the above copyright
  126. # notice and this permission notice appear in all copies.
  127. #
  128. # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
  129. # [ACTION-IF-YES], [ACTION-IF-NO])
  130. # ----------------------------------------------------------
  131. # David Shaw <dshaw@jabberwocky.com> May-09-2006
  132. #
  133. # Checks for libcurl. DEFAULT-ACTION is the string yes or no to
  134. # specify whether to default to --with-libcurl or --without-libcurl.
  135. # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
  136. # minimum version of libcurl to accept. Pass the version as a regular
  137. # version number like 7.10.1. If not supplied, any version is
  138. # accepted. ACTION-IF-YES is a list of shell commands to run if
  139. # libcurl was successfully found and passed the various tests.
  140. # ACTION-IF-NO is a list of shell commands that are run otherwise.
  141. # Note that using --without-libcurl does run ACTION-IF-NO.
  142. #
  143. # This macro #defines HAVE_LIBCURL if a working libcurl setup is
  144. # found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
  145. # values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
  146. # the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
  147. # where yyy are the various protocols supported by libcurl. Both xxx
  148. # and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
  149. # the macro for the complete list of possible defines. Shell
  150. # variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
  151. # defined to 'yes' for those features and protocols that were found.
  152. # Note that xxx and yyy keep the same capitalization as in the
  153. # curl-config list (e.g. it's "HTTP" and not "http").
  154. #
  155. # Users may override the detected values by doing something like:
  156. # LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
  157. #
  158. # For the sake of sanity, this macro assumes that any libcurl that is
  159. # found is after version 7.7.2, the first version that included the
  160. # curl-config script. Note that it is very important for people
  161. # packaging binary versions of libcurl to include this script!
  162. # Without curl-config, we can only guess what protocols are available,
  163. # or use curl_version_info to figure it out at runtime.
  164. AC_DEFUN([LIBCURL_CHECK_CONFIG],
  165. [
  166. AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
  167. AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
  168. AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
  169. AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
  170. AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
  171. AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
  172. AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
  173. AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
  174. AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
  175. AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
  176. AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
  177. AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
  178. AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
  179. AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
  180. AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
  181. AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
  182. AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
  183. AC_ARG_WITH(libcurl,
  184. AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
  185. [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
  186. if test "$_libcurl_with" != "no" ; then
  187. AC_PROG_AWK
  188. _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
  189. _libcurl_try_link=yes
  190. if test -d "$_libcurl_with" ; then
  191. LIBCURL_CPPFLAGS="-I$withval/include"
  192. _libcurl_ldflags="-L$withval/lib"
  193. AC_PATH_PROG([_libcurl_config],[curl-config],["$withval/bin"],["$withval/bin"])
  194. else
  195. AC_PATH_PROG([_libcurl_config],[curl-config])
  196. fi
  197. if test x$_libcurl_config != "x" ; then
  198. AC_CACHE_CHECK([for the version of libcurl],
  199. [libcurl_cv_lib_curl_version],
  200. [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
  201. _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
  202. _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
  203. if test $_libcurl_wanted -gt 0 ; then
  204. AC_CACHE_CHECK([for libcurl >= version $2],
  205. [libcurl_cv_lib_version_ok],
  206. [
  207. if test $_libcurl_version -ge $_libcurl_wanted ; then
  208. libcurl_cv_lib_version_ok=yes
  209. else
  210. libcurl_cv_lib_version_ok=no
  211. fi
  212. ])
  213. fi
  214. if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
  215. if test x"$LIBCURL_CPPFLAGS" = "x" ; then
  216. LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
  217. fi
  218. if test x"$LIBCURL" = "x" ; then
  219. LIBCURL=`$_libcurl_config --libs`
  220. # This is so silly, but Apple actually has a bug in their
  221. # curl-config script. Fixed in Tiger, but there are still
  222. # lots of Panther installs around.
  223. case "${host}" in
  224. powerpc-apple-darwin7*)
  225. LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
  226. ;;
  227. esac
  228. fi
  229. # All curl-config scripts support --feature
  230. _libcurl_features=`$_libcurl_config --feature`
  231. # Is it modern enough to have --protocols? (7.12.4)
  232. if test $_libcurl_version -ge 461828 ; then
  233. _libcurl_protocols=`$_libcurl_config --protocols`
  234. fi
  235. else
  236. _libcurl_try_link=no
  237. fi
  238. unset _libcurl_wanted
  239. fi
  240. if test $_libcurl_try_link = yes ; then
  241. # we didn't find curl-config, so let's see if the user-supplied
  242. # link line (or failing that, "-lcurl") is enough.
  243. LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
  244. AC_CACHE_CHECK([whether libcurl is usable],
  245. [libcurl_cv_lib_curl_usable],
  246. [
  247. _libcurl_save_cppflags=$CPPFLAGS
  248. CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
  249. _libcurl_save_libs=$LIBS
  250. LIBS="$LIBCURL $LIBS"
  251. AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
  252. /* Try and use a few common options to force a failure if we are
  253. missing symbols or can't link. */
  254. int x;
  255. curl_easy_setopt(NULL,CURLOPT_URL,NULL);
  256. x=CURL_ERROR_SIZE;
  257. x=CURLOPT_WRITEFUNCTION;
  258. x=CURLOPT_FILE;
  259. x=CURLOPT_ERRORBUFFER;
  260. x=CURLOPT_STDERR;
  261. x=CURLOPT_VERBOSE;
  262. ]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
  263. CPPFLAGS=$_libcurl_save_cppflags
  264. LIBS=$_libcurl_save_libs
  265. unset _libcurl_save_cppflags
  266. unset _libcurl_save_libs
  267. ])
  268. if test $libcurl_cv_lib_curl_usable = yes ; then
  269. # Does curl_free() exist in this version of libcurl?
  270. # If not, fake it with free()
  271. _libcurl_save_cppflags=$CPPFLAGS
  272. CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
  273. _libcurl_save_libs=$LIBS
  274. LIBS="$LIBS $LIBCURL"
  275. AC_CHECK_FUNC(curl_free,,
  276. AC_DEFINE(curl_free,free,
  277. [Define curl_free() as free() if our version of curl lacks curl_free.]))
  278. CPPFLAGS=$_libcurl_save_cppflags
  279. LIBS=$_libcurl_save_libs
  280. unset _libcurl_save_cppflags
  281. unset _libcurl_save_libs
  282. AC_DEFINE(HAVE_LIBCURL,1,
  283. [Define to 1 if you have a functional curl library.])
  284. AC_SUBST(LIBCURL_CPPFLAGS)
  285. AC_SUBST(LIBCURL)
  286. for _libcurl_feature in $_libcurl_features ; do
  287. AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
  288. eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
  289. done
  290. if test "x$_libcurl_protocols" = "x" ; then
  291. # We don't have --protocols, so just assume that all
  292. # protocols are available
  293. _libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT"
  294. if test x$libcurl_feature_SSL = xyes ; then
  295. _libcurl_protocols="$_libcurl_protocols HTTPS"
  296. # FTPS wasn't standards-compliant until version
  297. # 7.11.0
  298. if test $_libcurl_version -ge 461568; then
  299. _libcurl_protocols="$_libcurl_protocols FTPS"
  300. fi
  301. fi
  302. fi
  303. for _libcurl_protocol in $_libcurl_protocols ; do
  304. AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
  305. eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
  306. done
  307. else
  308. unset LIBCURL
  309. unset LIBCURL_CPPFLAGS
  310. fi
  311. fi
  312. unset _libcurl_try_link
  313. unset _libcurl_version_parse
  314. unset _libcurl_config
  315. unset _libcurl_feature
  316. unset _libcurl_features
  317. unset _libcurl_protocol
  318. unset _libcurl_protocols
  319. unset _libcurl_version
  320. unset _libcurl_ldflags
  321. fi
  322. if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
  323. # This is the IF-NO path
  324. ifelse([$4],,:,[$4])
  325. else
  326. # This is the IF-YES path
  327. ifelse([$3],,:,[$3])
  328. fi
  329. unset _libcurl_with
  330. ])dnl