Add:Core:Use dl functions if g_module is not available
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 24 Oct 2008 15:20:41 +0000 (15:20 +0000)
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Fri, 24 Oct 2008 15:20:41 +0000 (15:20 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1550 ffa7fe5e-494d-0410-b361-a75ebd5db220

configure.in
navit/plugin.c

index 8baffde..3b0dc61 100644 (file)
@@ -111,7 +111,10 @@ PKG_CHECK_MODULES(GMODULE, [gmodule-2.0], [gmodule=yes], [gmodule=no])
 if test "x${gmodule}" = "xyes"; then
        AC_DEFINE(HAVE_GMODULE, 1, [Define to 1 if you have gmodule])
 else
-       plugins="no"; plugins_reason="package gmodule missing"
+       AC_CHECK_LIB(dl, dlopen,
+               [plugins_reason="default, via dlopen";GMODULE_LIBS="-ldl";AC_DEFINE(HAVE_DLOPEN, 1, [Define to 1 if you have dlopen])],          
+               [plugins="no"; plugins_reason="package gmodule and dlopen missing"]
+       )
 fi
 # plugins
 AC_ARG_ENABLE(plugins,         [  --disable-plugins          disable plugins], [ plugins=$enableval;plugin_reason="configure parameter" ])
@@ -833,7 +836,7 @@ echo "  file:              $vehicle_file ($vehicle_file_reason)"
 echo "  gpsd:              $vehicle_gpsd ($vehicle_gpsd_reason)"
 echo "  gypsy:             $vehicle_gypsy ($vehicle_gypsy_reason)"
 
-if  [ test x"$gtk2_pkgconfig" != xyes ] && [ test x"$sdl" != xyes ] && [ test x"$directfb_pkgconfig" != xyes ] && [ test x"$gui_win32" != xyes ]
+if  test "x${gtk2_pkgconfig}" != "xyes" -a "x${sdl}" != "xyes" -a "x${directfb_pkgconfig}" != "xyes" -a "x${gui_win32}" != "xyes" -a "x${gui_internal}" != "xyes"
        then
        echo ""
        echo "" 
index d3fdf44..4e4aa6c 100644 (file)
 #include <glib.h>
 #include "config.h"
 #ifdef USE_PLUGINS
+#ifdef HAVE_GMODULE
 #include <gmodule.h>
+#else
+#include <dlfcn.h>
+#endif
 #endif
 #include "plugin.h"
 #include "file.h"
 #include "item.h"
 #include "debug.h"
 
+#ifndef HAVE_GMODULE
+typedef void * GModule;
+#define G_MODULE_BIND_LOCAL 1
+#define G_MODULE_BIND_LAZY 2
+static int
+g_module_supported(void)
+{
+       return 1;
+}
+
+static void *
+g_module_open(char *name, int flags)
+{
+       return dlopen(name,
+               (flags & G_MODULE_BIND_LAZY ? RTLD_LAZY : RTLD_NOW) |
+               (flags & G_MODULE_BIND_LOCAL ? RTLD_LOCAL : RTLD_GLOBAL));
+}
+
+static char *
+g_module_error(void)
+{
+       return dlerror();
+}
+
+static int
+g_module_symbol(GModule *handle, char *symbol, gpointer *addr)
+{
+       *addr=dlsym(handle, symbol);
+       return (*addr != NULL);
+}
+
+static void
+g_module_close(GModule *handle)
+{
+       dlclose(handle);
+}
+
+#endif
+
 struct plugin {
        int active;
        int lazy;