From 71f146a414be1f13d4bfd74b1aa1b8a8ba15ca85 Mon Sep 17 00:00:00 2001 From: martin-s Date: Sun, 8 Jul 2007 16:42:16 +0000 Subject: [PATCH] More modularization git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@279 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/Makefile.inc | 1 + navit/configure.in | 60 +++++++++-------- navit/src/Makefile.am | 6 +- navit/src/binding/Makefile.am | 3 + navit/src/binding/python/Makefile.am | 4 ++ .../{python.c => binding/python/binding_python.c} | 8 +-- navit/src/main.c | 6 -- navit/src/phrase.c | 2 + navit/src/python.h | 2 - navit/src/speech.c | 77 ---------------------- navit/src/speech.h | 2 + .../speech_dispatcher/speech_speech_dispatcher.c | 61 +++++++++++++++++ 12 files changed, 112 insertions(+), 120 deletions(-) create mode 100644 navit/src/binding/python/Makefile.am rename navit/src/{python.c => binding/python/binding_python.c} (98%) delete mode 100644 navit/src/python.h diff --git a/navit/Makefile.inc b/navit/Makefile.inc index cc07c83..9d3a269 100644 --- a/navit/Makefile.inc +++ b/navit/Makefile.inc @@ -1,3 +1,4 @@ +modulebindingdir=$(pkglibdir)/binding moduledatadir=$(pkglibdir)/data modulegraphicsdir=$(pkglibdir)/graphics moduleguidir=$(pkglibdir)/gui diff --git a/navit/configure.in b/navit/configure.in index 58b5ccc..4e6e2ba 100644 --- a/navit/configure.in +++ b/navit/configure.in @@ -69,14 +69,15 @@ fi AC_SUBST(IMLIB2_CFLAGS) AC_SUBST(IMLIB2_LIBS) + +AC_ARG_ENABLE(MODULE_GUI_SDL, [ --disable-speech-speechd don't create speech speechd ], MODULE_SPEECH_SPEECHD=$enableval, MODULE_SPEECH_SPEECHD=yes) AC_CHECK_HEADER(libspeechd.h, AC_DEFINE([HAVE_LIBSPEECHD],[],Define to 1 if you have the header file.) SPEECHD_LIBS="-lspeechd" speechd=yes, AC_MSG_WARN([*** no libspeechd.h -- Speech output disabled])) AC_SUBST(SPEECHD_CFLAGS) AC_SUBST(SPEECHD_LIBS) AM_CONDITIONAL(SPEECH_SPEECH_DISPATCHER, [test "x$speechd" = "xyes"]) -AC_ARG_ENABLE(MODULE_GUI_SDL, [ --disable-gui-sdl don't create gui sdl ], -MODULE_GUI_SDL=$enableval, MODULE_GUI_SDL=yes) +AC_ARG_ENABLE(MODULE_GUI_SDL, [ --disable-gui-sdl don't create gui sdl ], MODULE_GUI_SDL=$enableval, MODULE_GUI_SDL=yes) if test "x$MODULE_GUI_GTK" = "xyes"; then AC_CHECK_HEADER( SDL/SDL.h, @@ -134,38 +135,40 @@ AC_SUBST(GPSD_CFLAGS) AC_SUBST(GPSD_LIBS) AM_CONDITIONAL(VEHICLE_GPSD, [test "x$gpsd" = "xyes"]) -PYTHON_LIB="" -PYTHON_INC="" +AC_ARG_ENABLE(MODULE_BINDING_PYTHON, [ --disable-binding-python don't create binding python ], MODULE_BINDING_PYTHON=$enableval, MODULE_BINDING_PYTHON=yes) if test "$cross_compiling" = no; then - AC_PATH_PROG(_PATH_PYTHON,[python]) - dnl Libraries and flags for embedded Python. - dnl FIXME: I wish there was a less icky way to get this. - if test x"$_PATH_PYTHON" != x ; then - AC_MSG_CHECKING(for Python linkage) - py_prefix=`$_PATH_PYTHON -c 'import sys; print sys.prefix'` - py_ver=`$_PATH_PYTHON -c 'import sys; print sys.version[[:3]]'` - py_libdir="${py_prefix}/lib/python${py_ver}" - PYTHON_INC="-I${py_prefix}/include/python${py_ver}" - if test -f $py_libdir/config/Makefile ; then - py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` - py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` - py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` - py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` - py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` - PYTHON_LIB="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod" - PYTHON_LIB=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'` - CFLAGS="$CFLAGS $PYTHON_INC" - LIBS="$LIBS $PYTHON_LIB" - AC_MSG_RESULT($py_libdir) - else - AC_MSG_WARN([$py_libdir/config/Makefile missing, support for python disabled]) + if test "x$MODULE_BINDING_PYTHON" = "xyes"; then + AC_PATH_PROG(_PATH_PYTHON,[python]) + dnl Libraries and flags for embedded Python. + dnl FIXME: I wish there was a less icky way to get this. + if test x"$_PATH_PYTHON" != x ; then + AC_MSG_CHECKING(for Python linkage) + py_prefix=`$_PATH_PYTHON -c 'import sys; print sys.prefix'` + py_ver=`$_PATH_PYTHON -c 'import sys; print sys.version[[:3]]'` + py_libdir="${py_prefix}/lib/python${py_ver}" + PYTHON_CFLAGS="-I${py_prefix}/include/python${py_ver}" + if test -f $py_libdir/config/Makefile ; then + py_libs=`grep '^LIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` + py_libc=`grep '^LIBC=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` + py_libm=`grep '^LIBM=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` + py_liblocalmod=`grep '^LOCALMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` + py_libbasemod=`grep '^BASEMODLIBS=' $py_libdir/config/Makefile | sed -e 's/^.*=//'` + PYTHON_LIBS="-L$py_libdir/config $py_libs $py_libc $py_libm -lpython$py_ver $py_liblocalmod $py_libbasemod" + PYTHON_LIBS=`echo $PYTHON_LIB | sed -e 's/[ \\t]*/ /g'` + AC_DEFINE(HAVE_PYTHON, 1, [Define to 1 if you have python]) + python=yes + AC_MSG_RESULT($py_libdir) + else + AC_MSG_WARN([$py_libdir/config/Makefile missing, support for python disabled]) + fi fi fi else AC_MSG_WARN([*** cross compiling, support for python disabled]) fi -AC_SUBST(PYTHON_LIB) -AC_SUBST(PYTHON_INC) +AC_SUBST(PYTHON_CFLAGS) +AC_SUBST(PYTHON_LIBS) +AM_CONDITIONAL(BINDING_PYTHON, [test "x$python" = "xyes"]) LIBS="$LIBS -lm -rdynamic" @@ -173,6 +176,7 @@ AC_OUTPUT([ Makefile src/Makefile src/binding/Makefile +src/binding/python/Makefile src/data/Makefile src/data/mg/Makefile src/data/textfile/Makefile diff --git a/navit/src/Makefile.am b/navit/src/Makefile.am index d33db0f..9225c3e 100644 --- a/navit/src/Makefile.am +++ b/navit/src/Makefile.am @@ -1,7 +1,7 @@ include $(top_srcdir)/Makefile.inc SUBDIRS=binding data fib-1.1 gui graphics osd speech vehicle xpm -AM_CPPFLAGS = -I$(top_srcdir)/src/fib-1.1 @NAVIT_CFLAGS@ @SPEECHD_CFLAGS@ -DMODULE=\"navit\" +AM_CPPFLAGS = -I$(top_srcdir)/src/fib-1.1 @NAVIT_CFLAGS@ -DMODULE=\"navit\" bin_PROGRAMS = navit @@ -12,7 +12,7 @@ EXTRA_DIST = navit.xml navit_SOURCES = attr.c callback.c compass.c coord.c country.c cursor.c data_window.c debug.c \ file.c graphics.c gui.c item.c layout.c log.c main.c map.c \ mapset.c maptype.c menu.c navit.c navigation.c param.c phrase.c plugin.c popup.c \ - profile.c python.c route.c search.c speech.c transform.c track.c \ + profile.c route.c search.c speech.c transform.c track.c \ util.c vehicle.c xmlconfig.c attr.h attr_def.h callback.h color.h compass.h coord.h country.h \ cursor.h data.h data_window.h data_window_int.h debug.h destination.h draw_info.h \ file.h graphics.h gtkext.h gui.h item.h item_def.h log.h layer.h layout.h map-share.h map.h\ @@ -20,5 +20,5 @@ navit_SOURCES = attr.c callback.c compass.c coord.c country.c cursor.c data_wind param.h phrase.h plugin.h point.h plugin_def.h projection.h popup.h route.h profile.h search.h speech.h statusbar.h \ transform.h track.h util.h vehicle.h xmlconfig.h -navit_LDADD = @NAVIT_LIBS@ @GPSD_LIBS@ @SPEECHD_LIBS@ -Lfib-1.1 -lfib +navit_LDADD = @NAVIT_LIBS@ @GPSD_LIBS@ -Lfib-1.1 -lfib diff --git a/navit/src/binding/Makefile.am b/navit/src/binding/Makefile.am index e2baa04..80e20cc 100644 --- a/navit/src/binding/Makefile.am +++ b/navit/src/binding/Makefile.am @@ -1 +1,4 @@ SUBDIRS= +if BINDING_PYTHON + SUBDIRS+=python +endif diff --git a/navit/src/binding/python/Makefile.am b/navit/src/binding/python/Makefile.am new file mode 100644 index 0000000..27dd68d --- /dev/null +++ b/navit/src/binding/python/Makefile.am @@ -0,0 +1,4 @@ +include $(top_srcdir)/Makefile.inc +AM_CPPFLAGS = @NAVIT_CFLAGS@ @PYTHON_CFLAGS@ -I$(top_srcdir)/src -DMODULE=\"binding_python\" +modulebinding_LTLIBRARIES = libbinding_python.la +libbinding_python_la_SOURCES = binding_python.c diff --git a/navit/src/python.c b/navit/src/binding/python/binding_python.c similarity index 98% rename from navit/src/python.c rename to navit/src/binding/python/binding_python.c index 4b85beb..fc84146 100644 --- a/navit/src/python.c +++ b/navit/src/binding/python/binding_python.c @@ -1,10 +1,10 @@ #include "config.h" -#ifdef HAVE_PYTHON #include #include #include "coord.h" #include "map.h" #include "mapset.h" +#include "plugin.h" #if defined(MS_WINDOWS) || defined(__CYGWIN__) #define Obj_HEAD PyObject_HEAD_INIT(NULL); @@ -137,7 +137,7 @@ map_rect_new_py(mapObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "O!:navit.map_rect_rect",&coord_rect_Type,&r)) return NULL; ret=PyObject_NEW(map_rectObject, &map_rect_Type); - ret->mr=map_rect_new(self->m, r->r, NULL, 0); + ret->mr=map_rect_new(self->m, NULL); return (PyObject *)ret; } @@ -257,7 +257,8 @@ static PyMethodDef navitMethods[]={ }; -void python_init(void) +void +plugin_init(void) { int fd,size; char buffer[65536]; @@ -278,4 +279,3 @@ void python_init(void) Py_Finalize(); exit(0); } -#endif diff --git a/navit/src/main.c b/navit/src/main.c index 464a70e..c2279a9 100644 --- a/navit/src/main.c +++ b/navit/src/main.c @@ -11,9 +11,6 @@ #include "debug.h" #include "navit.h" #include "gui.h" -#ifdef HAVE_PYTHON -#include "python.h" -#endif #include "plugin.h" #include "xmlconfig.h" @@ -70,9 +67,6 @@ int main(int argc, char **argv) gdk_rgb_init(); #endif -#ifdef HAVE_PYTHON - python_init(); -#endif if (argc > 1) config_file=argv[1]; else { diff --git a/navit/src/phrase.c b/navit/src/phrase.c index b3fef2a..bbaadc0 100644 --- a/navit/src/phrase.c +++ b/navit/src/phrase.c @@ -8,9 +8,11 @@ void phrase_route_calc(void *speech) { +#if 0 if (! speech) return; speech_say(speech,"Die Route wird berechnet\n"); +#endif } void diff --git a/navit/src/python.h b/navit/src/python.h deleted file mode 100644 index 9829b13..0000000 --- a/navit/src/python.h +++ /dev/null @@ -1,2 +0,0 @@ -void python_init(void); - diff --git a/navit/src/speech.c b/navit/src/speech.c index fa9ab33..7c32862 100644 --- a/navit/src/speech.c +++ b/navit/src/speech.c @@ -1,78 +1 @@ -/* speechd simple client program - * CVS revision: $Id: speech.c,v 1.4 2006-01-03 21:37:48 martin-s Exp $ - * Author: Tomas Cerha */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "config.h" -#ifdef HAVE_LIBSPEECHD -#include -#endif #include "speech.h" - -struct speech { -#ifdef HAVE_LIBSPEECHD - SPDConnection *conn; -#endif -}; - -struct speech * -speech_new(void) { -#ifdef HAVE_LIBSPEECHD - struct speech *this; - SPDConnection *conn; - - conn = spd_open("navit","main",NULL,SPD_MODE_SINGLE); - if (! conn) - return NULL; - this=g_new(struct speech,1); - if (this) { - this->conn=conn; - spd_set_punctuation(conn, SPD_PUNCT_NONE); - } - return this; -#else - return NULL; -#endif -} - -int -speech_say(struct speech *this, char *text) { -#ifdef HAVE_LIBSPEECHD - int err; - - err = spd_sayf(this->conn, SPD_MESSAGE, text); - if (err != 1) - return 1; -#endif - return 0; -} - -int -speech_sayf(struct speech *this, char *format, ...) { -#ifdef HAVE_LIBSPEECHD - char buffer[8192]; - va_list ap; - va_start(ap,format); - vsnprintf(buffer, 8192, format, ap); - return speech_say(this, buffer); -#else - return 0; -#endif -} - -int -speech_destroy(struct speech *this) { -#ifdef HAVE_LIBSPEECHD - spd_close(this->conn); - g_free(this); -#endif - return 0; -} diff --git a/navit/src/speech.h b/navit/src/speech.h index a4038e0..09217c6 100644 --- a/navit/src/speech.h +++ b/navit/src/speech.h @@ -1,5 +1,7 @@ +#if 0 struct speech; struct speech *speech_new(void); int speech_say(struct speech *this, char *text); int speech_sayf(struct speech *this, char *format, ...); int speech_destroy(struct speech *this); +#endif diff --git a/navit/src/speech/speech_dispatcher/speech_speech_dispatcher.c b/navit/src/speech/speech_dispatcher/speech_speech_dispatcher.c index 32be387..4c4ebed 100644 --- a/navit/src/speech/speech_dispatcher/speech_speech_dispatcher.c +++ b/navit/src/speech/speech_dispatcher/speech_speech_dispatcher.c @@ -1,5 +1,66 @@ + +/* speechd simple client program + * CVS revision: $Id: speech_speech_dispatcher.c,v 1.2 2007-07-08 16:42:16 martin-s Exp $ + * Author: Tomas Cerha */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" +#include #include "plugin.h" +#include "speech.h" + +struct speech { + SPDConnection *conn; +}; + +struct speech * +speech_new(void) { + struct speech *this; + SPDConnection *conn; + + conn = spd_open("navit","main",NULL,SPD_MODE_SINGLE); + if (! conn) + return NULL; + this=g_new(struct speech,1); + if (this) { + this->conn=conn; + spd_set_punctuation(conn, SPD_PUNCT_NONE); + } + return this; +} +static int +speech_say(struct speech *this, char *text) { + int err; + + err = spd_sayf(this->conn, SPD_MESSAGE, text); + if (err != 1) + return 1; + return 0; +} + +static int +speech_sayf(struct speech *this, char *format, ...) { + char buffer[8192]; + va_list ap; + va_start(ap,format); + vsnprintf(buffer, 8192, format, ap); + return speech_say(this, buffer); +} + +static void +speech_destroy(struct speech *this) { + spd_close(this->conn); + g_free(this); +} void plugin_init(void) { -- 2.7.4