From: martin-s Date: Fri, 24 Oct 2008 15:20:41 +0000 (+0000) Subject: Add:Core:Use dl functions if g_module is not available X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=b6916e4d301f15abd3b5d7f95ede5b726d72c818;p=navit-package Add:Core:Use dl functions if g_module is not available git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@1550 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- diff --git a/configure.in b/configure.in index 8baffde..3b0dc61 100644 --- a/configure.in +++ b/configure.in @@ -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 "" diff --git a/navit/plugin.c b/navit/plugin.c index d3fdf44..4e4aa6c 100644 --- a/navit/plugin.c +++ b/navit/plugin.c @@ -21,7 +21,11 @@ #include #include "config.h" #ifdef USE_PLUGINS +#ifdef HAVE_GMODULE #include +#else +#include +#endif #endif #include "plugin.h" #include "file.h" @@ -30,6 +34,45 @@ #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;