From 712fc5794766b1b2327eccf8e51918f6986418fb Mon Sep 17 00:00:00 2001 From: martin-s Date: Sat, 9 Jan 2010 19:51:59 +0000 Subject: [PATCH] Add:Core:Experimental support for win32 plugins|Thanks to gotwo for the work git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2901 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/configure.in | 19 ++++++++++++--- navit/navit/Makefile.am | 12 ++++++---- navit/navit/graphics/win32/Makefile.am | 4 ++-- navit/navit/plugin.c | 42 +++++++++++++++++++++++++++++++++- 4 files changed, 66 insertions(+), 11 deletions(-) diff --git a/navit/configure.in b/navit/configure.in index 81eeb4a..70c2ec6 100644 --- a/navit/configure.in +++ b/navit/configure.in @@ -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 diff --git a/navit/navit/Makefile.am b/navit/navit/Makefile.am index 6907600..4610d77 100644 --- a/navit/navit/Makefile.am +++ b/navit/navit/Makefile.am @@ -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 diff --git a/navit/navit/graphics/win32/Makefile.am b/navit/navit/graphics/win32/Makefile.am index ec3b3ee..7b4de72 100644 --- a/navit/navit/graphics/win32/Makefile.am +++ b/navit/navit/graphics/win32/Makefile.am @@ -1,9 +1,9 @@ include $(top_srcdir)/Makefile.inc AM_CPPFLAGS = @NAVIT_CFLAGS@ @ZLIB_CFLAGS@ -I$(top_srcdir)/navit -DMODULE=graphics_win32 +libgraphics_win32_la_SOURCES = graphics_win32.c xpm2bmp.c +libgraphics_win32_la_LDFLAGS = -module -avoid-version @NAVIT_MODULE_LDFLAGS@ -Wl,-lgdi32 if PLUGINS modulegraphics_LTLIBRARIES = libgraphics_win32.la else noinst_LTLIBRARIES = libgraphics_win32.la endif -libgraphics_win32_la_SOURCES = graphics_win32.c xpm2bmp.c -libgraphics_win32_la_LDFLAGS = -module -avoid-version diff --git a/navit/navit/plugin.c b/navit/navit/plugin.c index 991eb50..cc7011b 100644 --- a/navit/navit/plugin.c +++ b/navit/navit/plugin.c @@ -24,9 +24,13 @@ #ifdef HAVE_GMODULE #include #else +#ifdef HAVE_API_WIN32_BASE +#include +#else #include #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 -- 2.7.4