Handle both .la and .so names; this works better in the uninstalled
authorColin Walters <walters@verbum.org>
Tue, 26 Aug 2008 20:04:38 +0000 (20:04 +0000)
committerColin Walters <walters@src.gnome.org>
Tue, 26 Aug 2008 20:04:38 +0000 (20:04 +0000)
2008-08-26  Colin Walters  <walters@verbum.org>

* girepository/gtypelib.c (_g_typelib_init): Handle
both .la and .so names; this works better in the
uninstalled library case.

svn path=/trunk/; revision=498

ChangeLog
girepository/gtypelib.c

index f122b3669cd5e1e78834b2073541753945105f78..dc4810a72c0d02e9616ffd6283af8863b910db95 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-26  Colin Walters  <walters@verbum.org>
+
+       * girepository/gtypelib.c (_g_typelib_init): Handle
+       both .la and .so names; this works better in the
+       uninstalled library case.
+
 2008-08-26  Johan Dahlin  <johan@gnome.org>
 
        * gir/Makefile.am:
index 4fd5193cc056db3af79d3e41c09ce300fc58a874..92c3f931f11a5c240432d2676698515cad49e012 100644 (file)
@@ -1937,7 +1937,7 @@ _g_typelib_init (GTypelib *typelib)
      
       if (typelib->module == NULL)
         {
-         gchar *resolved_shlib;
+         GString *shlib_full;
 
           /* Glade's autoconnect feature and OpenGL's extension mechanism
            * as used by Clutter rely on dlopen(NULL) to work as a means of
@@ -1948,13 +1948,23 @@ _g_typelib_init (GTypelib *typelib)
            * load modules globally for now.
            */
 
-         resolved_shlib = g_module_build_path (NULL, shlib);
-          typelib->module = g_module_open (resolved_shlib, G_MODULE_BIND_LAZY);
-          if (typelib->module == NULL)
-            g_warning ("Failed to load shared library referenced by the typelib: %s",
-                       g_module_error ());
+         typelib->module = g_module_open (shlib, G_MODULE_BIND_LAZY);
 
-         g_free (resolved_shlib);
+         if (typelib->module == NULL)
+           {
+             shlib_full = g_string_new (shlib);
+             /* Prefix with "lib", try both .la and .so */
+             if (!g_str_has_prefix (shlib_full->str, "lib"))
+               g_string_prepend (shlib_full, "lib");
+             g_string_append (shlib_full, ".la");
+             typelib->module = g_module_open (shlib_full->str, G_MODULE_BIND_LAZY);
+             if (typelib->module == NULL)
+               g_string_overwrite (shlib_full, strlen (shlib_full->str)-2, "so");
+             typelib->module = g_module_open (shlib_full->str, G_MODULE_BIND_LAZY);
+           }
+         if (typelib->module == NULL)
+            g_warning ("Failed to load shared library '%s' referenced by the typelib: %s",
+                       shlib, g_module_error ());
         }
     }
 }