Sophie

Sophie

distrib > Mandriva > 2010.2 > x86_64 > by-pkgid > 8f6eb777990b061e7b3c9aecdd73a1d2 > files > 3

navit-0.1.1-1mdv2010.1.src.rpm

To cope both with libgps18 and libgps19
Index: navit/configure.in
===================================================================
--- navit.orig/configure.in	2010-01-06 00:08:44.000000000 +0100
+++ navit/configure.in	2010-01-06 00:08:44.000000000 +0100
@@ -773,7 +773,17 @@
 AC_ARG_ENABLE(vehicle-gpsd, [  --disable-vehicle-gpsd              disable vehicle type gpsd], vehicle_gpsd=$enableval;vehicle_gpsd_reason="configure parameter")
 if test "x${vehicle_gpsd}" = xyes
 then
-	AC_CHECK_HEADER(gps.h, AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have the <gps.h> header file.) GPSD_LIBS="-lgps", vehicle_gpsd=no; vehicle_gpsd_reason="no gps.h" )
+	PKG_CHECK_MODULES([GPSD], [libgps], have_libgps="yes", have_libgps="no")
+	if test "x$have_libgps" = "xyes"; then
+		AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have libgps.)
+		PKG_CHECK_MODULES([LIBGPS19], [libgps >= 2.90], have_libgps19="yes", have_libgps19="no")
+		if test "x$have_libgps19" = "xyes"; then
+			AC_DEFINE([HAVE_LIBGPS19],[],Define to 1 if you have libgps19.)
+		fi
+	else
+		vehicle_gpsd=no; vehicle_gpsd_reason="no libgps"
+	fi
+dnl	AC_CHECK_HEADER(gps.h, AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have the <gps.h> header file.) GPSD_LIBS="-lgps", vehicle_gpsd=no; vehicle_gpsd_reason="no gps.h" )
 fi
 AC_SUBST(GPSD_CFLAGS)
 AC_SUBST(GPSD_LIBS)
Index: navit/navit/attr_def.h
===================================================================
--- navit.orig/navit/attr_def.h	2010-01-06 00:06:16.000000000 +0100
+++ navit/navit/attr_def.h	2010-01-06 00:08:44.000000000 +0100
@@ -226,7 +226,9 @@
 ATTR(gc_type)
 ATTR(layout)
 ATTR(position_nmea)
+#ifndef HAVE_LIBGPS19
 ATTR(gpsd_query)
+#endif
 ATTR(on_eof)
 ATTR(command)
 ATTR(src)
Index: navit/navit/vehicle/gpsd/vehicle_gpsd.c
===================================================================
--- navit.orig/navit/vehicle/gpsd/vehicle_gpsd.c	2010-01-06 00:06:16.000000000 +0100
+++ navit/navit/vehicle/gpsd/vehicle_gpsd.c	2010-01-06 00:08:44.000000000 +0100
@@ -36,7 +36,9 @@
 
 static struct vehicle_priv {
 	char *source;
+#ifndef HAVE_LIBGPS19
 	char *gpsd_query;
+#endif
 	struct callback_list *cbl;
 	struct callback *cb;
 	struct event_watch *evwatch;
@@ -69,8 +71,12 @@
 static void vehicle_gpsd_io(struct vehicle_priv *priv);
 
 static void
+#ifdef HAVE_LIBGPS19
+vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len)
+#else
 vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
 		      int level)
+#endif
 {
 	char *pos,*nmea_data_buf;
         int i=0,sats_signal=0;
@@ -108,16 +114,32 @@
 		data->set &= ~ALTITUDE_SET;
 	}
 	if (data->set & SATELLITE_SET) {
+#ifdef HAVE_LIBGPS19
+                if(data->satellites_visible > 0) {
+#else
                 if(data->satellites > 0) {
+#endif
                         sats_signal=0;
+#ifdef HAVE_LIBGPS19
+                        for( i=0;i<data->satellites_visible;i++) {
+#else
                         for( i=0;i<data->satellites;i++) {
+#endif
                                if (data->ss[i] > 0)
                                         sats_signal++;
                         }
                 }
+#ifdef HAVE_LIBGPS19
+		if (priv->sats_used != data->satellites_used || priv->sats != data->satellites_visible || priv->sats_signal != sats_signal ) {
+#else
 		if (priv->sats_used != data->satellites_used || priv->sats != data->satellites || priv->sats_signal != sats_signal ) {
+#endif
 			priv->sats_used = data->satellites_used;
+#ifdef HAVE_LIBGPS19
+			priv->sats = data->satellites_visible;
+#else
 			priv->sats = data->satellites;
+#endif
                         priv->sats_signal = sats_signal;
 			callback_list_call_attr_0(priv->cbl, attr_position_sats);
 		}
@@ -135,10 +157,17 @@
 		priv->fix_time = data->fix.time;
 		data->set &= ~TIME_SET;
 	}
+#ifdef HAVE_LIBGPS19
+	if (data->set & DOP_SET) {
+		dbg(1, "pdop : %g\n", data->dop.pdop);
+		priv->hdop = data->dop.pdop;
+		data->set &= ~DOP_SET;
+#else
 	if (data->set & PDOP_SET) {
 		dbg(1, "pdop : %g\n", data->pdop);
 		priv->hdop = data->hdop;
 		data->set &= ~PDOP_SET;
+#endif
 	}
 	if (data->set & LATLON_SET) {
 		priv->geo.lat = data->fix.latitude;
@@ -180,7 +209,11 @@
 		dbg(0,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?\n", priv->source, priv->retry_interval);
 		return TRUE;
 	}
+#ifdef HAVE_LIBGPS19
+	gps_stream(priv->gps, WATCH_ENABLE, NULL);
+#else
 	gps_query(priv->gps, priv->gpsd_query);
+#endif
 	gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
 	priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
 	priv->evwatch = event_add_watch((void *)priv->gps->gps_fd, event_watch_cond_read, priv->cb);
@@ -268,8 +301,10 @@
 	vehicle_gpsd_close(priv);
 	if (priv->source)
 		g_free(priv->source);
+#ifndef HAVE_LIBGPS19
 	if (priv->gpsd_query)
 		g_free(priv->gpsd_query);
+#endif
 	g_free(priv);
 }
 
@@ -350,12 +385,17 @@
 		      *cbl, struct attr **attrs)
 {
 	struct vehicle_priv *ret;
+#ifdef HAVE_LIBGPS19
+	struct attr *source, *retry_int;
+#else
 	struct attr *source, *query, *retry_int;
+#endif
 
 	dbg(1, "enter\n");
 	source = attr_search(attrs, NULL, attr_source);
 	ret = g_new0(struct vehicle_priv, 1);
 	ret->source = g_strdup(source->u.str);
+#ifndef HAVE_LIBGPS19
 	query = attr_search(attrs, NULL, attr_gpsd_query);
 	if (query) {
 		ret->gpsd_query = g_strconcat(query->u.str, "\n", NULL);
@@ -363,6 +403,7 @@
 		ret->gpsd_query = g_strdup("w+x\n");
 	}
 	dbg(1,"Format string for gpsd_query: %s\n",ret->gpsd_query);
+#endif
 	retry_int = attr_search(attrs, NULL, attr_retry_interval);
 	if (retry_int) {
 		ret->retry_interval = retry_int->u.num;
Index: navit/navit/attr.h
===================================================================
--- navit.orig/navit/attr.h.libgpsd-fix	2009-06-21 22:59:34.000000000 +0200
+++ navit/navit/attr.h	2010-01-19 22:22:12.000000000 +0100
@@ -27,6 +27,7 @@
 #define ATTR_H
 
 #include "projection.h"
+#include "config.h"
 
 enum item_type;

 
Index: navit/navit/map/garmin/Makefile.am
===================================================================
--- navit.orig/navit/map/garmin/Makefile.am	2010-01-06 00:09:00.000000000 +0100
+++ navit/navit/map/garmin/Makefile.am	2010-01-06 00:09:09.000000000 +0100
@@ -20,7 +20,7 @@
 gentypes_SOURCES=gentypes.c
 
 gentypes.$(OBJEXT): gentypes.c
-	$(CC_FOR_BUILD) -I$(top_srcdir)/navit -c -o $@ $<
+	$(CC_FOR_BUILD) -I$(top_srcdir)/navit -I$(top_srcdir) -c -o $@ $<
 
 gentypes$(EXEEXT): $(gentypes_OBJECTS) $(gentypes_DEPENDENCIES) 
 	@rm -f gentypes$(EXEEXT)