[libgda: 1/2] Improve apple platform support




commit 98f014c783583e3ad87ee546e8dccf34d50f1e37
Author: taozuhong <taozuhong gmail com>
Date:   Thu Sep 30 17:24:02 2021 +0800

    Improve apple platform support

 libgda/gda-config.c                 |  4 ++++
 libgda/sqlite/gda-sqlite-provider.c | 16 ++++++++++++++++
 providers/mysql/meson.build         | 10 +++++++---
 providers/postgres/meson.build      | 10 +++++++---
 4 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index 1ec424899..9219490b6 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -60,6 +60,10 @@
 #include <io.h>
 #endif
 
+#if defined(__APPLE__)
+#define G_MODULE_SUFFIX "dylib"
+#endif
+
 #ifdef HAVE_LIBSECRET
   #include <libsecret/secret.h>
   const SecretSchema *_gda_secret_get_schema (void) G_GNUC_CONST;
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index b5fb8563e..5aba4032d 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -69,6 +69,11 @@
 #include <libgda/gda-provider.h>
 #include <libgda/gda-server-provider.h>
 
+#if defined(__APPLE__)
+#include <dlfcn.h>
+#define G_MODULE_SUFFIX "dylib"
+#endif
+
 #define FILE_EXTENSION ".db"
 static gchar *get_table_nth_column_name (GdaServerProvider *prov, GdaConnection *cnc, const gchar 
*table_name, gint pos);
 
@@ -5169,6 +5174,17 @@ gda_sqlite_find_library (const gchar *name_part)
        GModule *handle = NULL;
        const gchar *env;
 
+#if defined(__APPLE__)
+       /* try to load from dir with libgda on runtime */
+       Dl_info dlinfo;
+       if (dladdr(gda_sqlite_find_library, &dlinfo)) {
+               gchar *libgda_dir = g_path_get_dirname( dlinfo.dli_fname );
+               handle = find_sqlite_in_dir (libgda_dir, name_part);
+               if (handle)
+                       return handle;
+       }
+#endif
+
        /* first use the compile time SEARCH_LIB_PATH */
        if (SEARCH_LIB_PATH) {
                gchar **array;
diff --git a/providers/mysql/meson.build b/providers/mysql/meson.build
index abfd77b50..c3e45bc86 100644
--- a/providers/mysql/meson.build
+++ b/providers/mysql/meson.build
@@ -132,6 +132,12 @@ mysql_args += [
 
 mysql_args += c_args
 
+link_args = [ '-Wl,--export-dynamic' ]
+host_os = host_machine.system().to_lower()
+if host_os.contains('darwin') or host_os.contains('machten') or host_os.contains('rhapsody')
+  link_args = [ '-Wl,-export_dynamic' ]
+endif
+
 libgda_mysql_provider = library ('gda-mysql-'+project_api_version,
        libgda_mysql_sources,
        dependencies: [
@@ -144,9 +150,7 @@ libgda_mysql_provider = library ('gda-mysql-'+project_api_version,
                inc_mysqlh_dep
                ],
        c_args: mysql_args,
-       link_args: [
-               '-Wl,--export-dynamic',
-               ],
+       link_args:link_args,
        link_with: libgda,
        install: true,
        install_dir: join_paths(get_option('libdir'), project_package, 'providers')
diff --git a/providers/postgres/meson.build b/providers/postgres/meson.build
index e2cfa4d9e..a7f640e51 100644
--- a/providers/postgres/meson.build
+++ b/providers/postgres/meson.build
@@ -107,6 +107,12 @@ libgda_postgres_cargs = [
 
 libgda_postgres_cargs += c_args
 
+link_args = [ '-Wl,--export-dynamic' ]
+host_os = host_machine.system().to_lower()
+if host_os.contains('darwin') or host_os.contains('machten') or host_os.contains('rhapsody')
+  link_args = [ '-Wl,-export_dynamic' ]
+endif
+
 libgda_postgres_provider = library ('gda-postgres-'+project_api_version,
        libgda_postgres_sources,
        dependencies: [
@@ -116,9 +122,7 @@ libgda_postgres_provider = library ('gda-postgres-'+project_api_version,
                inc_postgresh_dep
                ],
        c_args: libgda_postgres_cargs,
-       link_args: [
-               '-Wl,--export-dynamic',
-               ],
+       link_args: link_args,
        link_with: libgda,
        install: true,
        install_dir: join_paths(get_option('libdir'), project_package, 'providers')


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