gnucash maint: Bug 747300 - SQL backend missing from most recent DMG?

John Ralls jralls at code.gnucash.org
Fri Apr 3 17:00:54 EDT 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/1d6fd557 (commit)
	from  https://github.com/Gnucash/gnucash/commit/f717e091 (commit)



commit 1d6fd557676936cf719e435b53c8e6de15303889
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Apr 3 13:57:27 2015 -0700

    Bug 747300 - SQL backend missing from most recent DMG?
    
    Fix configure.ac so that ${prefix}/lib/dbd is searched for modules.
    Use gnc_path_get_libdir() to check for modules in the event that
    $GNC_DBD_DIR is either empty or wrong and the path compiled into libdbi
    itself is invalid. This applies mostly to Mac as other OSes tend to
    leave their binaries where configure installs them.

diff --git a/configure.ac b/configure.ac
index 761f3fc..752f8f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -617,7 +617,7 @@ then
         if test $? -eq 0; then
           EXTRA_SEARCH_LIBS="$(pkg-config --variable=libdir dbi)/dbd"
         else
-          EXTRA_SEARCH_LIBS="/usr/lib/dbd:/usr/lib64/dbd:${libdir}/dbd:$(prefix)/lib/dbd"
+          EXTRA_SEARCH_LIBS="/usr/lib/dbd:/usr/lib64/dbd:${libdir}/dbd:${prefix}/lib/dbd"
         fi]]
        )
     case $host_os in
@@ -633,12 +633,14 @@ then
 	 export LIBS="$lt_cv_dlopen_libs $LIBS"
 	 ;;
       esac
-      export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$EXTRA_SEARCH_LIBS"
-      AC_MSG_CHECKING([Looking for at least one supported DBD module])
-      AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
+    old_ld_library_path="$LD_LIBRARY_PATH"
+    LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$EXTRA_SEARCH_LIBS"
+    AC_MSG_NOTICE([Search Path $(LD_LIBRARY_PATH)])
+    AC_MSG_CHECKING([Looking for at least one supported DBD module])
+    AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
 				     [[if (!$lt_cv_dlopen("libdbdsqlite3.$LDEXT"$LDFUNCARGS)) return -1;
 				     ]])],AC_MSG_RESULT([SQLite3]),
-      	AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
+    	AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
 				     [[if (!$lt_cv_dlopen("libdbdmysql.$LDEXT"$LDFUNCARGS)) return -1;
 					]])],AC_MSG_RESULT([MySql]),
 	  AC_RUN_IFELSE([AC_LANG_PROGRAM([$LDINC],
@@ -661,6 +663,7 @@ to the configure argument list and run it again.
     LIBDBI_LIBS=-ldbi
     _COMPONENTS="$_COMPONENTS dbi"
     LIBS=$saved_libs
+    LD_LIBRARY_PATH="$old_ld_library_path"
   else
     AC_MSG_ERROR([
 
diff --git a/src/backend/dbi/gnc-backend-dbi.c b/src/backend/dbi/gnc-backend-dbi.c
index 4903a12..6733de3 100644
--- a/src/backend/dbi/gnc-backend-dbi.c
+++ b/src/backend/dbi/gnc-backend-dbi.c
@@ -48,6 +48,7 @@
 
 #include "gnc-uri-utils.h"
 #include "gnc-filepath-utils.h"
+#include <gnc-path.h>
 #include "gnc-locale-utils.h"
 
 #include "gnc-backend-dbi.h"
@@ -1883,13 +1884,25 @@ gnc_module_init_backend_dbi(void)
     }
 
     /* dbi_initialize returns -1 in case of errors */
-    #if HAVE_LIBDBI_R
+#if HAVE_LIBDBI_R
     if (dbi_instance)
         return;
     num_drivers = dbi_initialize_r( driver_dir, &dbi_instance );
-    #else
+#else
     num_drivers = dbi_initialize( driver_dir );
-    #endif
+#endif
+    if ( num_drivers <= 0 )
+    {
+	gchar *dir = g_build_filename(gnc_path_get_libdir(), "dbd", NULL);
+#if HAVE_LIBDBI_R
+	if (dbi_instance)
+	    return;
+	num_drivers = dbi_initialize_r( dir, &dbi_instance );
+#else
+	num_drivers = dbi_initialize( dir );
+#endif
+	g_free (dir);
+    }
     if ( num_drivers <= 0 )
     {
         PWARN( "No DBD drivers found\n" );



Summary of changes:
 configure.ac                      | 13 ++++++++-----
 src/backend/dbi/gnc-backend-dbi.c | 19 ++++++++++++++++---
 2 files changed, 24 insertions(+), 8 deletions(-)



More information about the gnucash-changes mailing list