libgnurl.m4 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. # LIBGNURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
  2. # [ACTION-IF-YES], [ACTION-IF-NO])
  3. # ----------------------------------------------------------
  4. # David Shaw <dshaw@jabberwocky.com> May-09-2006
  5. #
  6. # Checks for libgnurl. DEFAULT-ACTION is the string yes or no to
  7. # specify whether to default to --with-libgnurl or --without-libgnurl.
  8. # If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
  9. # minimum version of libgnurl 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. # libgnurl 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-libgnurl does run ACTION-IF-NO.
  15. #
  16. # This macro #defines HAVE_LIBGNURL if a working libgnurl setup is
  17. # found, and sets @LIBGNURL@ and @LIBGNURL_CPPFLAGS@ to the necessary
  18. # values. Other useful defines are LIBGNURL_FEATURE_xxx where xxx are
  19. # the various features supported by libgnurl, and LIBGNURL_PROTOCOL_yyy
  20. # where yyy are the various protocols supported by libgnurl. 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 $libgnurl_feature_xxx and $libgnurl_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. # gnurl-config list (e.g. it's "HTTP" and not "http").
  27. #
  28. # Users may override the detected values by doing something like:
  29. # LIBGNURL="-lgnurl" LIBGNURL_CPPFLAGS="-I/usr/myinclude" ./configure
  30. #
  31. # For the sake of sanity, this macro assumes that any libgnurl that is
  32. # found is after version 7.7.2, the first version that included the
  33. # gnurl-config script. Note that it is very important for people
  34. # packaging binary versions of libgnurl to include this script!
  35. # Without gnurl-config, we can only guess what protocols are available,
  36. # or use gnurl_version_info to figure it out at runtime.
  37. AC_DEFUN([LIBGNURL_CHECK_CONFIG],
  38. [
  39. AH_TEMPLATE([LIBGNURL_FEATURE_SSL],[Defined if libgnurl supports SSL])
  40. AH_TEMPLATE([LIBGNURL_FEATURE_KRB4],[Defined if libgnurl supports KRB4])
  41. AH_TEMPLATE([LIBGNURL_FEATURE_IPV6],[Defined if libgnurl supports IPv6])
  42. AH_TEMPLATE([LIBGNURL_FEATURE_LIBZ],[Defined if libgnurl supports libz])
  43. AH_TEMPLATE([LIBGNURL_FEATURE_ASYNCHDNS],[Defined if libgnurl supports AsynchDNS])
  44. AH_TEMPLATE([LIBGNURL_FEATURE_IDN],[Defined if libgnurl supports IDN])
  45. AH_TEMPLATE([LIBGNURL_FEATURE_SSPI],[Defined if libgnurl supports SSPI])
  46. AH_TEMPLATE([LIBGNURL_FEATURE_NTLM],[Defined if libgnurl supports NTLM])
  47. AH_TEMPLATE([LIBGNURL_PROTOCOL_HTTP],[Defined if libgnurl supports HTTP])
  48. AH_TEMPLATE([LIBGNURL_PROTOCOL_HTTPS],[Defined if libgnurl supports HTTPS])
  49. AH_TEMPLATE([LIBGNURL_PROTOCOL_FTP],[Defined if libgnurl supports FTP])
  50. AH_TEMPLATE([LIBGNURL_PROTOCOL_FTPS],[Defined if libgnurl supports FTPS])
  51. AH_TEMPLATE([LIBGNURL_PROTOCOL_FILE],[Defined if libgnurl supports FILE])
  52. AH_TEMPLATE([LIBGNURL_PROTOCOL_TELNET],[Defined if libgnurl supports TELNET])
  53. AH_TEMPLATE([LIBGNURL_PROTOCOL_LDAP],[Defined if libgnurl supports LDAP])
  54. AH_TEMPLATE([LIBGNURL_PROTOCOL_DICT],[Defined if libgnurl supports DICT])
  55. AH_TEMPLATE([LIBGNURL_PROTOCOL_TFTP],[Defined if libgnurl supports TFTP])
  56. AH_TEMPLATE([LIBGNURL_PROTOCOL_RTSP],[Defined if libgnurl supports RTSP])
  57. AH_TEMPLATE([LIBGNURL_PROTOCOL_POP3],[Defined if libgnurl supports POP3])
  58. AH_TEMPLATE([LIBGNURL_PROTOCOL_IMAP],[Defined if libgnurl supports IMAP])
  59. AH_TEMPLATE([LIBGNURL_PROTOCOL_SMTP],[Defined if libgnurl supports SMTP])
  60. AC_ARG_WITH(libgnurl,
  61. AC_HELP_STRING([--with-libgnurl=PREFIX],[look for the gnurl library in PREFIX/lib and headers in PREFIX/include]),
  62. [_libgnurl_with=$withval],[_libgnurl_with=ifelse([$1],,[yes],[$1])])
  63. if test "$_libgnurl_with" != "no" ; then
  64. AC_PROG_AWK
  65. _libgnurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
  66. _libgnurl_try_link=yes
  67. if test -d "$_libgnurl_with" ; then
  68. LIBGNURL_CPPFLAGS="-I$withval/include"
  69. _libgnurl_ldflags="-L$withval/lib"
  70. AC_PATH_PROG([_libgnurl_config],[gnurl-config],[],
  71. ["$withval/bin"])
  72. else
  73. AC_PATH_PROG([_libgnurl_config],[gnurl-config],[],[$PATH])
  74. fi
  75. if test x$_libgnurl_config != "x" ; then
  76. AC_CACHE_CHECK([for the version of libgnurl],
  77. [libgnurl_cv_lib_gnurl_version],
  78. [libgnurl_cv_lib_gnurl_version=`$_libgnurl_config --version | $AWK '{print $[]2}'`])
  79. _libgnurl_version=`echo $libgnurl_cv_lib_gnurl_version | $_libgnurl_version_parse`
  80. _libgnurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libgnurl_version_parse`
  81. if test $_libgnurl_wanted -gt 0 ; then
  82. AC_CACHE_CHECK([for libgnurl >= version $2],
  83. [libgnurl_cv_lib_version_ok],
  84. [
  85. if test $_libgnurl_version -ge $_libgnurl_wanted ; then
  86. libgnurl_cv_lib_version_ok=yes
  87. else
  88. libgnurl_cv_lib_version_ok=no
  89. fi
  90. ])
  91. fi
  92. if test $_libgnurl_wanted -eq 0 || test x$libgnurl_cv_lib_version_ok = xyes ; then
  93. if test x"$LIBGNURL_CPPFLAGS" = "x" ; then
  94. LIBGNURL_CPPFLAGS=`$_libgnurl_config --cflags`
  95. fi
  96. if test x"$LIBGNURL" = "x" ; then
  97. LIBGNURL=`$_libgnurl_config --libs`
  98. # This is so silly, but Apple actually has a bug in their
  99. # gnurl-config script. Fixed in Tiger, but there are still
  100. # lots of Panther installs around.
  101. case "${host}" in
  102. powerpc-apple-darwin7*)
  103. LIBGNURL=`echo $LIBGNURL | sed -e 's|-arch i386||g'`
  104. ;;
  105. esac
  106. fi
  107. # All gnurl-config scripts support --feature
  108. _libgnurl_features=`$_libgnurl_config --feature`
  109. # Is it modern enough to have --protocols? (7.12.4)
  110. if test $_libgnurl_version -ge 461828 ; then
  111. _libgnurl_protocols=`$_libgnurl_config --protocols`
  112. fi
  113. else
  114. _libgnurl_try_link=no
  115. fi
  116. unset _libgnurl_wanted
  117. fi
  118. if test $_libgnurl_try_link = yes ; then
  119. # we didn't find gnurl-config, so let's see if the user-supplied
  120. # link line (or failing that, "-lgnurl") is enough.
  121. LIBGNURL=${LIBGNURL-"$_libgnurl_ldflags -lgnurl"}
  122. AC_CACHE_CHECK([whether libgnurl is usable],
  123. [libgnurl_cv_lib_gnurl_usable],
  124. [
  125. _libgnurl_save_cppflags=$CPPFLAGS
  126. CPPFLAGS="$LIBGNURL_CPPFLAGS $CPPFLAGS"
  127. _libgnurl_save_libs=$LIBS
  128. LIBS="$LIBGNURL $LIBS"
  129. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <curl/curl.h>],[
  130. /* Try and use a few common options to force a failure if we are
  131. missing symbols or can't link. */
  132. int x;
  133. curl_easy_setopt(NULL,CURLOPT_URL,NULL);
  134. x=CURL_ERROR_SIZE;
  135. x=CURLOPT_WRITEFUNCTION;
  136. x=CURLOPT_FILE;
  137. x=CURLOPT_ERRORBUFFER;
  138. x=CURLOPT_STDERR;
  139. x=CURLOPT_VERBOSE;
  140. ])],libgnurl_cv_lib_gnurl_usable=yes,libgnurl_cv_lib_gnurl_usable=no)
  141. # BEGIN Changes from original libcurl.m4:
  142. # Give it a 2nd shot using 'gnurl/curl.h'
  143. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <gnurl/curl.h>],[
  144. /* Try and use a few common options to force a failure if we are
  145. missing symbols or can't link. */
  146. int x;
  147. curl_easy_setopt(NULL,CURLOPT_URL,NULL);
  148. x=CURL_ERROR_SIZE;
  149. x=CURLOPT_WRITEFUNCTION;
  150. x=CURLOPT_FILE;
  151. x=CURLOPT_ERRORBUFFER;
  152. x=CURLOPT_STDERR;
  153. x=CURLOPT_VERBOSE;
  154. ])],libgnurl_cv_lib_gnurl_usable=yes)
  155. # END Changes from original libcurl.m4:
  156. CPPFLAGS=$_libgnurl_save_cppflags
  157. LIBS=$_libgnurl_save_libs
  158. unset _libgnurl_save_cppflags
  159. unset _libgnurl_save_libs
  160. ])
  161. if test $libgnurl_cv_lib_gnurl_usable = yes ; then
  162. # Does gnurl_free() exist in this version of libgnurl?
  163. # If not, fake it with free()
  164. _libgnurl_save_cppflags=$CPPFLAGS
  165. CPPFLAGS="$CPPFLAGS $LIBGNURL_CPPFLAGS"
  166. _libgnurl_save_libs=$LIBS
  167. LIBS="$LIBS $LIBGNURL"
  168. AC_CHECK_FUNC(curl_free,,
  169. AC_DEFINE(curl_free,free,
  170. [Define curl_free() as free() if our version of gnurl lacks curl_free.]))
  171. CPPFLAGS=$_libgnurl_save_cppflags
  172. LIBS=$_libgnurl_save_libs
  173. unset _libgnurl_save_cppflags
  174. unset _libgnurl_save_libs
  175. AC_DEFINE(HAVE_LIBGNURL,1,
  176. [Define to 1 if you have a functional gnurl library.])
  177. AC_SUBST(LIBGNURL_CPPFLAGS)
  178. AC_SUBST(LIBGNURL)
  179. for _libgnurl_feature in $_libgnurl_features ; do
  180. AC_DEFINE_UNQUOTED(AS_TR_CPP(libgnurl_feature_$_libgnurl_feature),[1])
  181. eval AS_TR_SH(libgnurl_feature_$_libgnurl_feature)=yes
  182. done
  183. if test "x$_libgnurl_protocols" = "x" ; then
  184. # We don't have --protocols, so just assume that all
  185. # protocols are available
  186. _libgnurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
  187. if test x$libgnurl_feature_SSL = xyes ; then
  188. _libgnurl_protocols="$_libgnurl_protocols HTTPS"
  189. # FTPS wasn't standards-compliant until version
  190. # 7.11.0 (0x070b00 == 461568)
  191. if test $_libgnurl_version -ge 461568; then
  192. _libgnurl_protocols="$_libgnurl_protocols FTPS"
  193. fi
  194. fi
  195. # RTSP, IMAP, POP3 and SMTP were added in
  196. # 7.20.0 (0x071400 == 463872)
  197. if test $_libgnurl_version -ge 463872; then
  198. _libgnurl_protocols="$_libgnurl_protocols RTSP IMAP POP3 SMTP"
  199. fi
  200. fi
  201. for _libgnurl_protocol in $_libgnurl_protocols ; do
  202. AC_DEFINE_UNQUOTED(AS_TR_CPP(libgnurl_protocol_$_libgnurl_protocol),[1])
  203. eval AS_TR_SH(libgnurl_protocol_$_libgnurl_protocol)=yes
  204. done
  205. else
  206. unset LIBGNURL
  207. unset LIBGNURL_CPPFLAGS
  208. fi
  209. fi
  210. unset _libgnurl_try_link
  211. unset _libgnurl_version_parse
  212. unset _libgnurl_config
  213. unset _libgnurl_feature
  214. unset _libgnurl_features
  215. unset _libgnurl_protocol
  216. unset _libgnurl_protocols
  217. unset _libgnurl_version
  218. unset _libgnurl_ldflags
  219. fi
  220. if test x$_libgnurl_with = xno || test x$libgnurl_cv_lib_gnurl_usable != xyes ; then
  221. # This is the IF-NO path
  222. ifelse([$4],,:,[$4])
  223. else
  224. # This is the IF-YES path
  225. ifelse([$3],,:,[$3])
  226. fi
  227. unset _libgnurl_with
  228. ])dnl