simplify the configure.ac using PKG_CONFIG to detect qdbm correctly.
authorPierre Habouzit <madcoder@debian.org>
Wed, 8 Nov 2006 12:07:41 +0000 (13:07 +0100)
committerPierre Habouzit <madcoder@debian.org>
Wed, 8 Nov 2006 12:07:41 +0000 (13:07 +0100)
also symplify gpgme using its .m4 as well.

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Makefile.am
configure.ac
doconfig.sh
globals.h
hcache.c

index 93aa896..1692199 100644 (file)
@@ -59,7 +59,7 @@ DEFS=-DPKGDATADIR=\"$(pkgdatadir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
        -DBINDIR=\"$(bindir)\" -DMUTTLOCALEDIR=\"$(datadir)/locale\" \
        -DHAVE_CONFIG_H=1 -DPKGDOCDIR=\"$(docdir)\"
 
-INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) $(NNTP_INCLUDES) $(LIBGPGME_CFLAGS) -Iintl
+INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) $(NNTP_INCLUDES) $(GPGME_CFLAGS) -Iintl
 
 CPPFLAGS=@CPPFLAGS@ -I$(includedir)
 
index 033ef14..2f71dfd 100644 (file)
@@ -37,6 +37,7 @@ AC_PROG_MAKE_SET
 AC_PROG_INSTALL
 AC_PROG_RANLIB
 AC_PROG_GPERF
+PKG_PROG_PKG_CONFIG
 AC_CHECK_TOOL(AR, ar, ar)
 
 AC_C_INLINE
@@ -104,27 +105,12 @@ dnl ---------------- gpgme ----------------
             have_gpgme=yes
         fi
     ])
-    AC_ARG_WITH(gpgme-prefix, AC_HELP_STRING([--with-gpgme-prefix=PFX], [prefix where GPGME is installed (optional)]),
-    gpgme_config_prefix="$withval", gpgme_config_prefix="")
-
     if test x$have_gpgme = xyes; then
-        if test x$gpgme_config_prefix != x; then
-            GPGME_CONFIG="$gpgme_config_prefix/bin/gpgme-config"
-        else
-            AC_PATH_PROG(GPGME_CONFIG, gpgme-config, no)
-        fi
-        if test "x$GPGME_CONFIG" = "xno"; then
-            AC_MSG_ERROR([GPGME not found])
-        else
-            LIBGPGME_CFLAGS=`$GPGME_CONFIG --cflags`
-            LIBGPGME_LIBS=`$GPGME_CONFIG --libs`
-            MUTTLIBS="$MUTTLIBS $LIBGPGME_LIBS"
-            MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS crypt-gpgme.o crypt-mod-pgp-gpgme.o crypt-mod-smime-gpgme.o"
-            AC_DEFINE(CRYPT_BACKEND_GPGME, 1, [Defined, if GPGME support is enabled])
-        fi
+        AM_PATH_GPGME(,,[AC_MSG_ERROR(GPGME not found)])
+        MUTTLIBS="$MUTTLIBS $GPGME_LIBS"
+        MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS crypt-gpgme.o crypt-mod-pgp-gpgme.o crypt-mod-smime-gpgme.o"
+        AC_DEFINE(CRYPT_BACKEND_GPGME, 1, [Defined, if GPGME support is enabled])
     fi
-    AC_SUBST(LIBGPGME_CFLAGS)
-    AC_SUBST(LIBGPGME_LIBS)
 
 dnl ---------------- mixmaster ----------------
 
@@ -603,29 +589,13 @@ AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching])
     AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]),
         ac_prefer_qdbm=$withval)
     if test x$ac_prefer_qdbm != xno; then
-        ac_cv_vlopen=no
-        QDBM_DIRS="$mutt_cv_prefix /usr/local /usr"
-        AC_MSG_CHECKING([for vlopen])
-        for d in $QDBM_DIRS; do
-          if test x$ac_cv_vlopen = xno && test -d "$d/include" && test -d "$d/lib"; then
-            QDBM_INC="-I$d/include"
-            QDBM_LIB="-L$d/lib"
-            CPPFLAGS="$OLDCPPFLAGS $QDBM_INC"
-            LIBS="$OLDLIBS $QDBM_LIB -lqdbm"
-            AC_TRY_LINK([#include <villa.h>],[vlopen(0,0,0);],[ac_cv_vlopen=yes])
-          fi
-        done
-        if test x$ac_cv_vlopen = xyes; then
-          AC_MSG_RESULT(yes)
-        else
-          AC_MSG_RESULT(no)
-        fi
+        PKG_CHECK_MODULES(QDBM,qdbm,[ac_qdbm_here=yes],[ac_qdbm_here=no])
     fi
 
     ac_prefer_gdbm=yes
     AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]),
         ac_prefer_gdbm=$withval)
-    if test x$ac_prefer_gdbm != xno -a x$ac_cv_vlopen != xyes; then
+    if test x$ac_prefer_gdbm != xno -a x$ac_qdbm_here != xyes; then
         ac_cv_gdbmopen=no
         GDBM_DIRS="$mutt_cv_prefix /usr/local /usr"
         AC_MSG_CHECKING([for gdbm_open])
@@ -644,11 +614,11 @@ AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching])
           AC_MSG_RESULT(no)
         fi
     fi
-   
+
     ac_bdb_prefix=yes
     AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available ]),
         ac_bdb_prefix=$withval)
-    if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_cv_vlopen != xyes; then
+    if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_qdbm_here != xyes; then
         test x$ac_bdb_prefix = xyes && ac_bdb_prefix="$mutt_cv_prefix /opt/csw/bdb4 /opt /usr/local /usr"
         for d in $ac_bdb_prefix; do
             bdbpfx="$bdbpfx $d"
@@ -694,9 +664,9 @@ AC_ARG_ENABLE(hcache, AC_HELP_STRING([--enable-hcache], [Enable header caching])
         fi
     fi
 
-    if test x$ac_cv_vlopen = xyes; then
-        CPPFLAGS="$OLDCPPFLAGS $QDBM_INC"
-        LIBS="$OLDLIBS $QDBM_LIB -lqdbm"
+    if test x$ac_qdbm_here = xyes; then
+        CPPFLAGS="$OLDCPPFLAGS $QDBM_CFLAGS"
+        LIBS="$OLDLIBS $QDBM_LIBS"
         AC_DEFINE(HAVE_QDBM, 1, [QDBM Support])
     elif test x$ac_cv_gdbmopen = xyes; then
         CPPFLAGS="$OLDCPPFLAGS $GDBM_INC"
index abb7e5f..fd1203a 100755 (executable)
@@ -1,2 +1,6 @@
 ./autogen.sh
-./configure --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man --with-sharedir=/usr/share/mutt-ng --with-docdir=/usr/share/doc/mutt-ng --with-mailpath=/var/mail --enable-fcntl --with-mixmaster --with-sasl2 --with-idn --with-curses --enable-nntp --enable-debug --with-gnutls --enable-gpgme
+./configure -C --prefix=/usr --sysconfdir=/etc --mandir=/usr/share/man       \
+    --with-sharedir=/usr/share/mutt-ng --with-docdir=/usr/share/doc/mutt-ng  \
+    --with-mailpath=/var/mail --enable-fcntl --with-mixmaster --with-sasl2   \
+    --with-idn --with-curses --enable-nntp --enable-debug --with-gnutls      \
+    --enable-gpgme --enable-hcache
index e8d498f..8e690b8 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -72,7 +72,7 @@ WHERE char *Maildir;
 
 #ifdef USE_HCACHE
 WHERE char *HeaderCache;
-#if HAVE_GDBM || HAVE_DB4
+#if defined(HAVE_GDBM) || defined(HAVE_DB4)
 WHERE char *HeaderCachePageSize;
 #endif /* HAVE_GDBM || HAVE_DB4 */
 #endif /* USE_HCACHE */
index b479dc2..e089bf1 100644 (file)
--- a/hcache.c
+++ b/hcache.c
 
 #define MUTTNG_HCACHE_ID        "0x004"
 
-# if HAVE_INTTYPES_H
+# ifdef HAVE_INTTYPES_H
 #  include <inttypes.h>
 # else
-#  if HAVE_STDINT_H
+#  ifdef HAVE_STDINT_H
 #   include <stdint.h>
 #  endif
 # endif
 
-#if HAVE_QDBM
+#if defined(HAVE_QDBM)
 #include <depot.h>
 #include <cabin.h>
 #include <villa.h>
-#elif HAVE_GDBM
+#elif defined(HAVE_GDBM)
 #include <gdbm.h>
-#elif HAVE_DB4
+#elif defined(HAVE_DB4)
 #include <db.h>
 #endif
 
 #include <errno.h>
 #include <fcntl.h>
-#if HAVE_SYS_TIME_H
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif
 
 
 #include "lib/debug.h"
 
-#if HAVE_QDBM
-static struct
-  header_cache {
+static struct header_cache {
+#if defined(HAVE_QDBM)
   VILLA *db;
   char *folder;
   unsigned int crc;
-} HEADER_CACHE;
-#elif HAVE_GDBM
-static struct
-  header_cache {
+#elif defined(HAVE_GDBM)
   GDBM_FILE db;
   char *folder;
   unsigned int crc;
-} HEADER_CACHE;
-#elif HAVE_DB4
-static struct
-  header_cache {
+#elif defined(HAVE_DB4)
   DB_ENV *env;
   DB *db;
   unsigned int crc;
   int fd;
   char lockfile[_POSIX_PATH_MAX];
-} HEADER_CACHE;
 #endif
+} HEADER_CACHE;
 
 typedef union {
   struct timeval timeval;
@@ -91,7 +84,7 @@ static void *lazy_malloc (size_t siz)
   return xmalloc(siz);
 }
 
-static void lazy_realloc (void *ptr, size_t siz)
+static void lazy_realloc(void *ptr, ssize_t siz)
 {
   void **p = (void **) ptr;
 
@@ -99,7 +92,7 @@ static void lazy_realloc (void *ptr, size_t siz)
     return;
   }
 
-  p_realloc(ptr, siz);
+  p_realloc(p, siz);
 }
 
 static unsigned char *dump_int (unsigned int i, unsigned char *d, int *off)
@@ -453,7 +446,7 @@ static int generate_crc32 ()
                m_strlen
                (MUTTNG_HCACHE_ID "sithglan@stud.uni-erlangen.de[sithglan]|hcache.c|20041108231548|29613"));
 
-#if HAVE_LANGINFO_CODESET
+#ifdef HAVE_LANGINFO_CODESET
   crc = crc32(crc, (unsigned char const *) Charset, m_strlen(Charset));
   crc = crc32(crc, (unsigned char const *) "HAVE_LANGINFO_CODESET",
               m_strlen("HAVE_LANGINFO_CODESET"));
@@ -594,11 +587,11 @@ HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
   return h;
 }
 
-#if HAVE_QDBM
+#if defined(HAVE_QDBM)
 void *
 mutt_hcache_open(const char *path, const char *folder)
 {
-  struct header_cache *h = p_new(HEADER_CACHE, 1);
+  struct header_cache *h = p_new(struct header_cache, 1);
   int    flags = VL_OWRITER | VL_OCREAT;
   h->db = NULL;
   h->folder = m_strdup(folder);
@@ -647,7 +640,7 @@ mutt_hcache_fetch(void *db, const char *filename,
 {
   struct header_cache *h = db;
   char path[_POSIX_PATH_MAX];
-  int ksize, len;
+  int ksize;
   char *data = NULL;
 
   if (!h)
@@ -716,7 +709,7 @@ mutt_hcache_delete(void *db, const char *filename,
   return vlout(h->db, path, ksize);
 }
 
-#elif HAVE_GDBM
+#elif defined(HAVE_GDBM)
 
 void *mutt_hcache_open (const char *path, const char *folder)
 {
@@ -843,7 +836,7 @@ mutt_hcache_delete (void *db, const char *filename,
 
   return gdbm_delete (h->db, key);
 }
-#elif HAVE_DB4
+#elif defined(HAVE_DB4)
 
 static void mutt_hcache_dbt_init (DBT * dbt, void *data, size_t len)
 {