curlpp.m4 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. # LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
  2. # [ACTION-IF-YES], [ACTION-IF-NO])
  3. # ----------------------------------------------------------
  4. # David Shaw <dshaw@jabberwocky.com> Jun-21-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 guess what protocols are available.
  36. AC_DEFUN([CURLPP_CHECK_CONFIG],
  37. [
  38. LIBCURL_CHECK_CONFIG
  39. if test x"$LIBCURL" != "x" ; then
  40. AC_ARG_WITH(curlpp,
  41. AC_HELP_STRING([--with-curlpp=DIR],[look for the curlpp library in DIR]),
  42. [_curlpp_with=$withval],[_curlpp_with=ifelse([$1],,[yes],[$1])])
  43. if test "$_curlpp_with" != "no" ; then
  44. AC_PROG_AWK
  45. _curlpp_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
  46. _curlpp_try_link=yes
  47. if test -d "$_curlpp_with" ; then
  48. CPPFLAGS="${CPPFLAGS} -I$withval/include"
  49. LDFLAGS="${LDFLAGS} -L$withval/lib"
  50. fi
  51. AC_PATH_PROG([_curlpp_config],[curlpp-config])
  52. if test x$_curlpp_config != "x" ; then
  53. AC_CACHE_CHECK([for the version of curlpp],
  54. [curlpp_cv_lib_curlpp_version],
  55. [curlpp_cv_lib_curlpp_version=`$_curlpp_config --version | $AWK '{print $[]2}'`])
  56. _curlpp_version=`echo $curlpp_cv_lib_curlpp_version | $_curlpp_version_parse`
  57. _curlpp_wanted=`echo ifelse([$2],,[0],[$2]) | $_curlpp_version_parse`
  58. if test $_curlpp_wanted -gt 0 ; then
  59. AC_CACHE_CHECK([for curlpp >= version $2],
  60. [curlpp_cv_lib_version_ok],
  61. [
  62. if test $_curlpp_version -ge $_curlpp_wanted ; then
  63. curlpp_cv_lib_version_ok=yes
  64. else
  65. curlpp_cv_lib_version_ok=no
  66. fi
  67. ])
  68. fi
  69. if test $_curlpp_wanted -eq 0 || test x$curlpp_cv_lib_version_ok = xyes ; then
  70. if test x"$CURLPP_CPPFLAGS" = "x" ; then
  71. CURLPP_CPPFLAGS=`$_curlpp_config --cflags`
  72. fi
  73. if test x"$CURLPP" = "x" ; then
  74. CURLPP=`$_curlpp_config --libs`
  75. fi
  76. else
  77. _curlpp_try_link=no
  78. fi
  79. unset _curlpp_wanted
  80. fi
  81. if test $_curlpp_try_link = yes ; then
  82. # we didn't find curl-config, so let's see if the user-supplied
  83. # link line (or failing that, "-lcurl") is enough.
  84. CURLPP=${CURLPP-"-lcurl"}
  85. AC_CACHE_CHECK([whether curlpp is usable],
  86. [curlpp_cv_lib_curlpp_usable],
  87. [
  88. _curlpp_save_cppflags=$CPPFLAGS
  89. CPPFLAGS="$CPPFLAGS $CURLPP_CPPFLAGS"
  90. _libcurl_save_libs=$LIBS
  91. LIBS="$LIBS $CURLPP"
  92. AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curlpp/cURLpp.hpp>],[
  93. /* Try and use a few common options to force a failure if we are
  94. missing symbols or can't link. */
  95. int x;
  96. cURLpp::initialize();
  97. ]),curlpp_cv_lib_curlpp_usable=yes,curlpp_cv_lib_curlpp_usable=no)
  98. CPPFLAGS=$_curlpp_save_cppflags
  99. LIBS=$_curlpp_save_libs
  100. unset _curlpp_save_cppflags
  101. unset _curlpp_save_libs
  102. ])
  103. if test $curlpp_cv_lib_curlpp_usable = yes ; then
  104. AC_DEFINE(HAVE_CURLPP,1,
  105. [Define to 1 if you have a functional curlpp library.])
  106. AC_SUBST(CURLPP_CPPFLAGS)
  107. AC_SUBST(CURLPP)
  108. fi
  109. fi
  110. unset _curlpp_try_link
  111. unset _curlpp_version_parse
  112. unset _curlpp_config
  113. unset _curlpp_feature
  114. unset _curlpp_features
  115. unset _curlpp_protocol
  116. unset _curlpp_protocols
  117. unset _curlpp_version
  118. fi
  119. if test x$_curlpp_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
  120. # This is the IF-NO path
  121. ifelse([$4],,:,[$4])
  122. else
  123. # This is the IF-YES path
  124. ifelse([$3],,:,[$3])
  125. fi
  126. unset _curlpp_with
  127. fi
  128. ])dnl