summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-07-04 20:53:42 -0400
committerAlberto Fanjul <albertofanjul@gmail.com>2019-07-02 10:04:51 +0000
commit27c2286bd9062d2c77cfc1b0eb26fb02523a50b6 (patch)
tree70468be20592f4e9514bbdd052b032abfb55e2fa
parent258a7dde2fb6a4fb2593d567b5422dcfdf195e10 (diff)
downloadglade-27c2286bd9062d2c77cfc1b0eb26fb02523a50b6.tar.gz
Fix loading dylibs on OSX
-rw-r--r--configure.ac16
-rw-r--r--gladeui/glade-utils.c25
2 files changed, 41 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index fffccfba..79e4d58d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -276,6 +276,22 @@ case $host_os in
esac
AM_CONDITIONAL(NATIVE_WIN32, test x"$native_win32" = "xyes")
+dnl ================================================================
+dnl Check for osx
+dnl ================================================================
+AC_MSG_CHECKING([for Mac OS X platform])
+case "$host" in
+ *-*-darwin*)
+ platform_osx=yes
+ ;;
+ *)
+ platform_osx=no
+ ;;
+esac
+AC_MSG_RESULT([$platform_osx])
+AM_CONDITIONAL(PLATFORM_OSX, test x"$platform_osx" = "xyes")
+AC_DEFINE(PLATFORM_OSX, test x"$platform_osx" = "xyes", [On OSX Platform])
+
if test "$native_win32" = "yes"; then
AC_CHECK_TOOL(WINDRES, windres, no)
if test "$WINDRES" = no; then
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index 6148561a..82bd34c2 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -876,6 +876,31 @@ try_load_library (const gchar *library_path, const gchar *library_name)
g_warning ("Failed to load %s: %s", path, g_module_error ());
}
+#ifdef PLATFORM_OSX
+ /* Handle .dylib's on OSX */
+ if (!module)
+ {
+ gchar *osx_path;
+
+ /* Remove possible trailing .so */
+ if (g_str_has_suffix (path, ".so"))
+ {
+ gchar *tmp = g_strndup (path, strlen(path) - 3);
+ g_free (path);
+ path = tmp;
+ }
+
+ osx_path = g_strconcat (path, ".dylib", NULL);
+ if (!library_path || g_file_test (osx_path, G_FILE_TEST_EXISTS))
+ {
+ if (!(module = g_module_open (osx_path, G_MODULE_BIND_LAZY)))
+ g_warning ("Failed to load %s: %s", osx_path, g_module_error ());
+ }
+
+ g_free (osx_path);
+ }
+#endif
+
g_free (path);
return module;