[evolution-data-server/evolution-data-server-3-12] Make libdb optional dependency



commit 6190f45949bb965b41fa46fe8d799754779536e7
Author: Milan Crha <mcrha redhat com>
Date:   Sun Jun 1 20:52:40 2014 +0200

    Make libdb optional dependency
    
    Since the file book backend uses sqlite as its summary, the libdb is
    needed "only" for migration of old data.

 addressbook/backends/file/Makefile.am           |    9 ++++-
 addressbook/backends/file/e-book-backend-file.c |   16 +++++++--
 addressbook/libedata-book/Makefile.am           |    9 ++++-
 configure.ac                                    |   45 +++++++++++++----------
 libebackend/Makefile.am                         |   15 ++++++--
 5 files changed, 64 insertions(+), 30 deletions(-)
---
diff --git a/addressbook/backends/file/Makefile.am b/addressbook/backends/file/Makefile.am
index de41f54..77fdfef 100644
--- a/addressbook/backends/file/Makefile.am
+++ b/addressbook/backends/file/Makefile.am
@@ -1,5 +1,11 @@
 NULL =
 
+if HAVE_LIBDB
+LIBDB_FILES = \
+       e-book-backend-file-migrate-bdb.c \
+       e-book-backend-file-migrate-bdb.h
+endif
+
 ebook_backend_LTLIBRARIES = libebookbackendfile.la
 
 libebookbackendfile_la_CPPFLAGS = \
@@ -19,9 +25,8 @@ libebookbackendfile_la_CPPFLAGS = \
 libebookbackendfile_la_SOURCES = \
        e-book-backend-file.c \
        e-book-backend-file.h \
-       e-book-backend-file-migrate-bdb.c \
-       e-book-backend-file-migrate-bdb.h \
        e-book-backend-file-factory.c \
+       $(LIBDB_FILES) \
        $(NULL)
 
 libebookbackendfile_la_LIBADD = \
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index bf506fe..7838947 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -39,7 +39,10 @@
 #include <glib/gi18n-lib.h>
 
 #include "e-book-backend-file.h"
+
+#ifdef HAVE_LIBDB
 #include "e-book-backend-file-migrate-bdb.h"
+#endif
 
 #define E_BOOK_BACKEND_FILE_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
@@ -1962,8 +1965,10 @@ book_backend_file_initable_init (GInitable *initable,
        ESourceRegistry *registry;
        ESource *source;
        const gchar *extension_name;
-       gchar *backup, *dirname;
-       gchar *filename, *fullpath;
+#ifdef HAVE_LIBDB
+       gchar *backup, *filename;
+#endif /* HAVE_LIBDB */
+       gchar *dirname, *fullpath;
        gboolean success = TRUE;
 
        priv = E_BOOK_BACKEND_FILE_GET_PRIVATE (initable);
@@ -1981,9 +1986,11 @@ book_backend_file_initable_init (GInitable *initable,
                dirname = e_book_backend_file_extract_path_from_source (
                        registry, source, GET_PATH_DB_DIR);
 
+       fullpath = g_build_filename (dirname, "contacts.db", NULL);
+
+#ifdef HAVE_LIBDB
        filename = g_build_filename (dirname, "addressbook.db", NULL);
        backup = g_build_filename (dirname, "addressbook.db.old", NULL);
-       fullpath = g_build_filename (dirname, "contacts.db", NULL);
 
        /* The old BDB exists, lets migrate that to sqlite right away. */
        if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
@@ -2018,6 +2025,7 @@ book_backend_file_initable_init (GInitable *initable,
                        goto exit;
                }
        }
+#endif /* HAVE_LIBDB */
 
        /* If we already have a handle on this, it means there
         * was an old BDB migrated and no need to reopen it. */
@@ -2081,8 +2089,10 @@ book_backend_file_initable_init (GInitable *initable,
 exit:
        g_free (dirname);
        g_free (fullpath);
+#ifdef HAVE_LIBDB
        g_free (filename);
        g_free (backup);
+#endif /* HAVE_LIBDB */
 
        return success;
 }
diff --git a/addressbook/libedata-book/Makefile.am b/addressbook/libedata-book/Makefile.am
index a05a9dc..75153cd 100644
--- a/addressbook/libedata-book/Makefile.am
+++ b/addressbook/libedata-book/Makefile.am
@@ -1,5 +1,10 @@
 NULL =
 
+if HAVE_LIBDB
+LIBDB_C_FILES = e-book-backend-db-cache.c
+LIBDB_H_FILES = e-book-backend-db-cache.h
+endif
+
 lib_LTLIBRARIES = libedata-book-1.2.la
 
 libedata_book_1_2_la_CPPFLAGS = \
@@ -26,7 +31,6 @@ libedata_book_1_2_la_SOURCES = \
        e-book-backend-sexp.c \
        e-book-backend-summary.c \
        e-book-backend-cache.c \
-       e-book-backend-db-cache.c \
        e-book-backend-sqlitedb.c \
        e-book-backend.c \
        e-book-sqlite.c \
@@ -37,6 +41,7 @@ libedata_book_1_2_la_SOURCES = \
        e-data-book-factory.c \
        e-data-book-view.c \
        ximian-vcard.h \
+       $(LIBDB_C_FILES) \
        $(NULL)
 
 libedata_book_1_2_la_LIBADD = \
@@ -71,8 +76,8 @@ libedata_bookinclude_HEADERS = \
        e-data-book-direct.h \
        e-book-backend-cache.h \
        e-book-backend-sqlitedb.h \
-       e-book-backend-db-cache.h \
        e-book-sqlite.h \
+       $(LIBDB_H_FILES) \
        $(NULL)
 
 factorydir = $(libexecdir)
diff --git a/configure.ac b/configure.ac
index 31ffb8e..f475c01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -604,29 +604,36 @@ dnl ******************************
 AC_ARG_WITH([libdb],
        AS_HELP_STRING([--with-libdb=PREFIX],
        [Prefix where libdb is installed]),
-       [
-               DB_CFLAGS="-I$withval/include"
-               DB_LIBS="-L$withval/lib -ldb"
-       ],
-       [
+       [with_libdb=$withval],[with_libdb=yes])
+
+if test "x$with_libdb" != "xno" ; then
+       if test "x$with_libdb" != "xyes" ; then
+               DB_CFLAGS="-I$with_libdb/include"
+               DB_LIBS="-L$with_libdb/lib -ldb"
+       else
                if test -z "$DB_CFLAGS" -a -z "$DB_LIBS"; then
                        DB_CFLAGS=""
                        DB_LIBS="-ldb"
                fi
-       ])
+       fi
+
+       AC_MSG_CHECKING([Berkeley DB])
+       save_cflags=$CFLAGS; CFLAGS=$DB_CFLAGS
+       save_libs=$LIBS; LIBS="$DB_LIBS"
+       AC_LINK_IFELSE([AC_LANG_PROGRAM(
+               [[#include <db.h>]],
+               [[db_create(NULL, NULL, 0)]])],
+               [AC_MSG_RESULT([yes])],
+               [AC_MSG_ERROR([Cannot find libdb])])
+       CFLAGS=$save_cflags
+       LIBS=$save_libs
+       AC_SUBST(DB_CFLAGS)
+       AC_SUBST(DB_LIBS)
+
+       AC_DEFINE(HAVE_LIBDB, 1, [Have libdb])
+fi
+AM_CONDITIONAL(HAVE_LIBDB, [test x$with_libdb != xno])
 
-AC_MSG_CHECKING([Berkeley DB])
-save_cflags=$CFLAGS; CFLAGS=$DB_CFLAGS
-save_libs=$LIBS; LIBS="$DB_LIBS"
-AC_LINK_IFELSE([AC_LANG_PROGRAM(
-       [[#include <db.h>]],
-       [[db_create(NULL, NULL, 0)]])],
-       [AC_MSG_RESULT([yes])],
-       [AC_MSG_ERROR([Cannot find libdb])])
-CFLAGS=$save_cflags
-LIBS=$save_libs
-AC_SUBST(DB_CFLAGS)
-AC_SUBST(DB_LIBS)
 
 dnl ******************************
 dnl db_load checking
diff --git a/libebackend/Makefile.am b/libebackend/Makefile.am
index f057181..703c28b 100644
--- a/libebackend/Makefile.am
+++ b/libebackend/Makefile.am
@@ -2,6 +2,15 @@ NULL =
 
 ENUM_TYPES = e-backend-enums.h
 
+if HAVE_LIBDB
+LIBDB_C_FILES = \
+       e-dbhash.c \
+       e-db3-utils.c
+LIBDB_H_FILES = \
+       e-db3-utils.h \
+       e-dbhash.h
+endif
+
 e-backend-enumtypes.h: $(top_srcdir)/enumtypes.h.template $(ENUM_TYPES)
        $(AM_V_GEN) $(GLIB_MKENUMS) --template $(top_srcdir)/enumtypes.h.template \
                --fhead "#ifndef E_BACKEND_ENUMTYPES_H\n#define E_BACKEND_ENUMTYPES_H\n" \
@@ -58,8 +67,6 @@ libebackend_1_2_la_SOURCES = \
        e-extension.c \
        e-oauth2-support.c \
        e-offline-listener.c \
-       e-dbhash.c \
-       e-db3-utils.c \
        e-module.c \
        e-server-side-source.c \
        e-soup-auth-bearer.c \
@@ -69,6 +76,7 @@ libebackend_1_2_la_SOURCES = \
        e-user-prompter-server.c \
        e-user-prompter-server-extension.c \
        e-file-cache.c \
+       $(LIBDB_C_FILES) \
        $(NULL)
 
 libebackend_1_2_la_LIBADD = \
@@ -106,8 +114,6 @@ libebackendinclude_HEADERS = \
        e-extension.h \
        e-oauth2-support.h \
        e-offline-listener.h \
-       e-db3-utils.h \
-       e-dbhash.h \
        e-module.h \
        e-server-side-source.h \
        e-soup-auth-bearer.h \
@@ -117,6 +123,7 @@ libebackendinclude_HEADERS = \
        e-user-prompter-server.h \
        e-user-prompter-server-extension.h \
        e-file-cache.h \
+       $(LIBDB_H_FILES) \
        $(NULL)
 
 %-$(API_VERSION).pc: %.pc


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]