Clean up libfetch checking in configure

Model it after the new OpenSSL check, and have it be a bit more useful. If
you do not explicitly pass a command line option, it will be linked if
available but will not error out if it is missing. Also bump the version to
that where connection caching was introduced as we use these new features in
the codebase.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2010-09-02 12:29:29 -05:00
parent eba521913d
commit 3e7b90ff69
4 changed files with 24 additions and 26 deletions

View File

@ -94,9 +94,9 @@ AC_ARG_WITH(openssl,
[], [with_openssl=check]) [], [with_openssl=check])
# Help line for libfetch # Help line for libfetch
AC_ARG_ENABLE(internal-download, AC_ARG_WITH(fetch,
AS_HELP_STRING([--disable-internal-download], [do not build with libfetch support]), AS_HELP_STRING([--with-fetch], [use libfetch as an internal downloader]),
[internaldownload=$enableval], [internaldownload=yes]) [], [with_fetch=check])
# Help line for documentation # Help line for documentation
AC_ARG_ENABLE(doc, AC_ARG_ENABLE(doc,
@ -150,21 +150,20 @@ AM_CONDITIONAL([HAVE_LIBSSL], [test "x$ac_cv_lib_ssl_MD5_Final" = "xyes"])
# Enable or disable usage of libfetch # Enable or disable usage of libfetch
AC_MSG_CHECKING(whether to link with libfetch) AC_MSG_CHECKING(whether to link with libfetch)
if test "x$internaldownload" = "xyes" ; then AS_IF([test "x$with_fetch" = "xyes"],
AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
AC_DEFINE([INTERNAL_DOWNLOAD], , [Use internal download library])
# Check for a download library if it was actually requested
AC_CHECK_LIB([fetch], [fetchParseURL], , AC_CHECK_LIB([fetch], [fetchParseURL], ,
AC_MSG_ERROR([libfetch is needed to compile with internal download support]), [-lcrypto -ldl] ) [if test "x$with_fetch" != "xcheck"; then
# Check if libfetch supports conditional GET AC_MSG_FAILURE([--with-fetch was given, but -lfetch was not found])
# (version >=2.21, struct url has member last_modified) fi],
AC_CHECK_MEMBER(struct url.last_modified, , [-lcrypto -ldl])
AC_MSG_ERROR([libfetch must be version 2.21 or greater]), # Check if libfetch supports connnection caching which we use
[#include <fetch.h>] ) AC_CHECK_DECL(fetchConnectionCacheInit, ,
else AC_MSG_ERROR([libfetch must be version 2.28 or greater]),
AC_MSG_RESULT(no) [#include <fetch.h>])
fi ],
AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes") AC_MSG_RESULT(no))
AM_CONDITIONAL([HAVE_LIBFETCH], [test "x$ac_cv_lib_fetch_fetchParseURL" = "xyes"])
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h]) AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
@ -406,7 +405,6 @@ ${PACKAGE_NAME}:
Compilation options: Compilation options:
Run make in doc/ dir : ${wantdoc} ${asciidoc} Run make in doc/ dir : ${wantdoc} ${asciidoc}
Use download library : ${internaldownload}
Doxygen support : ${usedoxygen} Doxygen support : ${usedoxygen}
debug support : ${debug} debug support : ${debug}
" "

View File

@ -24,7 +24,7 @@
#include "config.h" #include "config.h"
/* connection caching setup */ /* connection caching setup */
#if defined(INTERNAL_DOWNLOAD) #ifdef HAVE_FETCH
#include <fetch.h> #include <fetch.h>
#endif #endif
@ -59,7 +59,7 @@ int SYMEXPORT alpm_initialize(void)
bindtextdomain("libalpm", LOCALEDIR); bindtextdomain("libalpm", LOCALEDIR);
#endif #endif
#ifdef INTERNAL_DOWNLOAD #ifdef HAVE_FETCH
fetchConnectionCacheInit(5, 1); fetchConnectionCacheInit(5, 1);
#endif #endif
@ -82,7 +82,7 @@ int SYMEXPORT alpm_release(void)
_alpm_handle_free(handle); _alpm_handle_free(handle);
handle = NULL; handle = NULL;
#ifdef INTERNAL_DOWNLOAD #ifdef HAVE_FETCH
fetchConnectionCacheClose(); fetchConnectionCacheClose();
#endif #endif

View File

@ -38,7 +38,7 @@
#include <sys/param.h> /* MAXHOSTNAMELEN */ #include <sys/param.h> /* MAXHOSTNAMELEN */
#endif #endif
#if defined(INTERNAL_DOWNLOAD) #ifdef HAVE_FETCH
#include <fetch.h> #include <fetch.h>
#endif #endif
@ -58,7 +58,7 @@ static char *get_filename(const char *url) {
return(filename); return(filename);
} }
#if defined(INTERNAL_DOWNLOAD) #ifdef HAVE_FETCH
static char *get_destfile(const char *path, const char *filename) { static char *get_destfile(const char *path, const char *filename) {
char *destfile; char *destfile;
/* len = localpath len + filename len + null */ /* len = localpath len + filename len + null */
@ -338,7 +338,7 @@ cleanup:
static int download(const char *url, const char *localpath, static int download(const char *url, const char *localpath,
int force) { int force) {
if(handle->fetchcb == NULL) { if(handle->fetchcb == NULL) {
#if defined(INTERNAL_DOWNLOAD) #ifdef HAVE_FETCH
return(download_internal(url, localpath, force)); return(download_internal(url, localpath, force));
#else #else
RET_ERR(PM_ERR_EXTERNAL_DOWNLOAD, -1); RET_ERR(PM_ERR_EXTERNAL_DOWNLOAD, -1);

View File

@ -31,7 +31,7 @@
#include <sys/param.h> /* MAXHOSTNAMELEN */ #include <sys/param.h> /* MAXHOSTNAMELEN */
#endif #endif
#if defined(INTERNAL_DOWNLOAD) #ifdef HAVE_FETCH
#include <fetch.h> /* fetchLastErrString */ #include <fetch.h> /* fetchLastErrString */
#endif #endif
@ -145,7 +145,7 @@ const char SYMEXPORT *alpm_strerror(int err)
* error string instead. */ * error string instead. */
return _("libarchive error"); return _("libarchive error");
case PM_ERR_LIBFETCH: case PM_ERR_LIBFETCH:
#if defined(INTERNAL_DOWNLOAD) #ifdef HAVE_FETCH
return fetchLastErrString; return fetchLastErrString;
#else #else
/* obviously shouldn't get here... */ /* obviously shouldn't get here... */