More cleanup of "allow to".
[gnupg.git] / m4 / libcurl.m4
index a9bfa2e..49caecc 100644 (file)
@@ -58,20 +58,28 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG],
 
   AC_ARG_WITH(libcurl,
      AC_HELP_STRING([--with-libcurl=DIR],[look for the curl library in DIR]),
-     [_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
+     [_libcurl_with=$withval],[_libcurl_with=m4_if([$1],,[yes],[$1])])
 
   if test "$_libcurl_with" != "no" ; then
 
      AC_PROG_AWK
 
      _libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
+     # More recent versions of curl-config have a direct --vernum
+     # option, but we'd like this code to work with older versions as
+     # well, so just convert --version.
+     _libcurl_vernum_parse="eval $AWK '{printf \"0x%06X\",\$NF}'"
 
      _libcurl_try_link=yes
 
      if test -d "$_libcurl_with" ; then
         LIBCURL_CPPFLAGS="-I$withval/include"
         _libcurl_ldflags="-L$withval/lib"
-        AC_PATH_PROG([_libcurl_config],["$withval/bin/curl-config"])
+        if test -x "$withval/bin/curl-config" ; then
+          _libcurl_config="$withval/bin/curl-config"
+        else
+          _libcurl_config=
+        fi
      else
        AC_PATH_PROG([_libcurl_config],[curl-config])
      fi
@@ -82,7 +90,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG],
            [libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
 
        _libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
-       _libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
+       _libcurl_wanted=`echo m4_if([$2],,[0],[$2]) | $_libcurl_version_parse`
 
         if test $_libcurl_wanted -gt 0 ; then
           AC_CACHE_CHECK([for libcurl >= version $2],
@@ -141,9 +149,9 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG],
            _libcurl_save_libs=$LIBS
            LIBS="$LIBCURL $LIBS"
 
-           AC_LINK_IFELSE(AC_LANG_PROGRAM([#include <curl/curl.h>],[
+           AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[
 /* Try and use a few common options to force a failure if we are
-   missing symbols or can't link. */
+   missing symbols or cannot link. */
 int x;
 curl_easy_setopt(NULL,CURLOPT_URL,NULL);
 x=CURL_ERROR_SIZE;
@@ -152,7 +160,7 @@ x=CURLOPT_FILE;
 x=CURLOPT_ERRORBUFFER;
 x=CURLOPT_STDERR;
 x=CURLOPT_VERBOSE;
-]),libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
+]])],[libcurl_cv_lib_curl_usable=yes],[libcurl_cv_lib_curl_usable=no])
 
            CPPFLAGS=$_libcurl_save_cppflags
            LIBS=$_libcurl_save_libs
@@ -184,6 +192,11 @@ x=CURLOPT_VERBOSE;
            AC_SUBST(LIBCURL_CPPFLAGS)
            AC_SUBST(LIBCURL)
 
+           _libcurl_vernum=`echo $_libcurl_version | $_libcurl_vernum_parse`
+
+           AC_DEFINE_UNQUOTED(LIBCURL_VERNUM, $_libcurl_vernum,
+                  [The version of the libcurl library in packed hex form])
+
            for _libcurl_feature in $_libcurl_features ; do
              AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
              eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
@@ -224,15 +237,16 @@ x=CURLOPT_VERBOSE;
      unset _libcurl_protocol
      unset _libcurl_protocols
      unset _libcurl_version
+     unset _libcurl_vernum
      unset _libcurl_ldflags
   fi
 
   if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
      # This is the IF-NO path
-     ifelse([$4],,:,[$4])
+     m4_if([$4],,:,[$4])
   else
      # This is the IF-YES path
-     ifelse([$3],,:,[$3])
+     m4_if([$3],,:,[$3])
   fi
 
   unset _libcurl_with