Add:Core:Experimental support for win32 plugins|Thanks to gotwo for the work
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sat, 9 Jan 2010 19:51:59 +0000 (19:51 +0000)
committerHenning Heinold <heinold@inf.fu-berlin.de>
Thu, 4 Feb 2010 23:44:44 +0000 (00:44 +0100)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit@2901 ffa7fe5e-494d-0410-b361-a75ebd5db220

configure.in
navit/Makefile.am
navit/plugin.c

index 81eeb4a..70c2ec6 100644 (file)
@@ -65,6 +65,9 @@ vehicle_iphone=no; vehicle_iphone_reason=default
 vehicle_android=no; vehicle_android_reason=default
 graphics_android=no; graphics_android_reason=default
 
+shared_libnavit=no
+bin_navit=yes
+
 AC_CANONICAL_HOST
 win32=no
 win32ce=no
@@ -88,10 +91,12 @@ mingw32)
        graphics_win32=yes; graphics_win32_reason="host_os is mingw32"
        speech_espeak=yes; speech_espeak_reason="host_os is mingw32"
        support_libpng=yes
-       LIBS="$LIBS -lwinmm"
+       MODULE_LIBADD="-Wl,-lwinmm"
        ;;
 linux*_android)
        android=yes
+       shared_libnavit=yes
+       bin_navit=no
        AC_DEFINE(HAVE_API_ANDROID, 1, [Have Android API])
        echo "void dl_unwind_find_exidx(void) {}" >crt0.c
        $CC -c crt0.c
@@ -99,7 +104,8 @@ linux*_android)
        vehicle_android=yes; vehicle_android_reason="host_os is android"
        graphics_android=yes; graphics_android_reason="host_os is android"
        speech_android=yes; speech_android_reason="host_os is android"
-       MODULE_LDFLAGS="-Xcompiler -nostdlib"
+       MODULE_LDFLAGS="-module -Xcompiler -nostdlib"
+       MODULE_LIBADD="-llog"
        NAVIT_MODULE_LDFLAGS="$MODULE_LDFLAGS -L\$(top_builddir)/navit -lnavit"
        ;;
 esac
@@ -122,6 +128,7 @@ fi
 AM_CONDITIONAL(SUPPORT_LIBPNG, [test "x$support_libpng" = "xyes"])
 
 AC_SUBST(MODULE_LDFLAGS)
+AC_SUBST(MODULE_LIBADD)
 AC_SUBST(NAVIT_MODULE_LDFLAGS)
 
 LIBS="$LIBS -lm"
@@ -261,11 +268,17 @@ if test "x${plugins}" = "xyes"; then
                [],
                Define to 1 if you have plugins.
        )
+       if test "x${win32}" = "xyes"; then
+               shared_libnavit=yes
+               NAVIT_MODULE_LDFLAGS="-no-undefined -L\$(top_builddir)/navit -lnavit -L\$(top_builddir)/intl -lintl"
+       fi
 else
        AC_DISABLE_SHARED
        AC_ENABLE_STATIC
 fi
 AM_CONDITIONAL(PLUGINS, [test "x$plugins" = "xyes"])
+AM_CONDITIONAL(SHARED_LIBNAVIT, [test "x$shared_libnavit" = "xyes"])
+AM_CONDITIONAL(BIN_NAVIT, [test "x$bin_navit" = "xyes"])
 AC_PROG_LIBTOOL
 
 AM_CONDITIONAL(EVENT_GLIB, [test "x$glib" = "xyes"])
@@ -637,7 +650,7 @@ AC_SUBST(MOFILES)
 AC_SUBST(POFILES)
 AC_SUBST(POIFILES)
 AM_GNU_GETTEXT_VERSION
-AM_GNU_GETTEXT(no-libtool, need-ngettext, \$(top_builddir)/intl/)
+AM_GNU_GETTEXT(use-libtool, need-ngettext, \$(top_builddir)/intl/)
 AC_SUBST(LIBINTL)
 AC_SUBST(LTLIBINTL)
 if test x"$LIBINTL" != "x" ;then
index 6907600..4610d77 100644 (file)
@@ -24,13 +24,15 @@ endif
 AM_CPPFLAGS = -I$(top_srcdir)/navit/fib-1.1 @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -DPREFIX=\"@prefix@\" -DLIBDIR=\"@libdir@\" -DMODULE=navit
 BUILT_SOURCES = version.h navit_config.h
 
-if SUPPORT_ANDROID
-  lib_LTLIBRARIES        = libnavit.la
-  libnavit_la_LDFLAGS = -module -avoid-version @MODULE_LDFLAGS@ -Wl,--no-undefined
-  libnavit_la_LIBADD = @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib -llog
+if BIN_NAVIT
+  bin_PROGRAMS = navit
+endif
 
+if SHARED_LIBNAVIT
+  lib_LTLIBRARIES        = libnavit.la
+  libnavit_la_LDFLAGS = -avoid-version @MODULE_LDFLAGS@ -no-undefined -Wl,--no-undefined
+  libnavit_la_LIBADD = @NAVIT_LIBS@ @WORDEXP_LIBS@ @ZLIB_LIBS@ @INTLLIBS@ -Lfib-1.1 -lfib @MODULE_LIBADD@
 else
-  bin_PROGRAMS = navit
   noinst_LTLIBRARIES        = libnavit.la
 endif
 
index 991eb50..cc7011b 100644 (file)
 #ifdef HAVE_GMODULE
 #include <gmodule.h>
 #else
+#ifdef HAVE_API_WIN32_BASE
+#include <windows.h>
+#else
 #include <dlfcn.h>
 #endif
 #endif
+#endif
 #include "plugin.h"
 #include "file.h"
 #define PLUGIN_C
@@ -45,6 +49,42 @@ g_module_supported(void)
        return 1;
 }
 
+#ifdef HAVE_API_WIN32_BASE
+
+static void *
+g_module_open(char *name, int flags)
+{
+       HINSTANCE handle;
+       int len=MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, 0, 0);
+       wchar_t filename[len];
+       MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, filename, len) ;
+
+       dbg(0,"%s\n",name);
+       handle = LoadLibraryW (filename);
+       dbg(0,"handle=%p\n",handle);
+       dbg(0,"%d\n",GetLastError ());
+       return handle;
+}
+
+static char *
+g_module_error(void)
+{
+       return NULL;
+}
+
+static int
+g_module_symbol(GModule *handle, char *symbol, gpointer *addr)
+{
+       *addr=GetProcAddress ((HANDLE)handle, symbol);
+       return (*addr != NULL);
+}
+
+static void
+g_module_close(GModule *handle)
+{
+}
+
+#else
 static void *
 g_module_open(char *name, int flags)
 {
@@ -71,7 +111,7 @@ g_module_close(GModule *handle)
 {
        dlclose(handle);
 }
-
+#endif
 #endif
 #endif