CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
dropbear: moved from core collection
[attic/ports/opt-cross.git] / navit / navit-0.1.1.gps_fix.patch
CommitLineData
b15f30ad
JB
1To cope both with libgps18 and libgps19
2Index: navit/configure.in
3===================================================================
4--- navit.orig/configure.in 2010-01-06 00:08:44.000000000 +0100
5+++ navit/configure.in 2010-01-06 00:08:44.000000000 +0100
6@@ -773,7 +773,17 @@
7 AC_ARG_ENABLE(vehicle-gpsd, [ --disable-vehicle-gpsd disable vehicle type gpsd], vehicle_gpsd=$enableval;vehicle_gpsd_reason="configure parameter")
8 if test "x${vehicle_gpsd}" = xyes
9 then
10- 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" )
11+ PKG_CHECK_MODULES([GPSD], [libgps], have_libgps="yes", have_libgps="no")
12+ if test "x$have_libgps" = "xyes"; then
13+ AC_DEFINE([HAVE_LIBGPS],[],Define to 1 if you have libgps.)
14+ PKG_CHECK_MODULES([LIBGPS19], [libgps >= 2.90], have_libgps19="yes", have_libgps19="no")
15+ if test "x$have_libgps19" = "xyes"; then
16+ AC_DEFINE([HAVE_LIBGPS19],[],Define to 1 if you have libgps19.)
17+ fi
18+ else
19+ vehicle_gpsd=no; vehicle_gpsd_reason="no libgps"
20+ fi
21+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" )
22 fi
23 AC_SUBST(GPSD_CFLAGS)
24 AC_SUBST(GPSD_LIBS)
25Index: navit/navit/attr_def.h
26===================================================================
27--- navit.orig/navit/attr_def.h 2010-01-06 00:06:16.000000000 +0100
28+++ navit/navit/attr_def.h 2010-01-06 00:08:44.000000000 +0100
29@@ -226,7 +226,9 @@
30 ATTR(gc_type)
31 ATTR(layout)
32 ATTR(position_nmea)
33+#ifndef HAVE_LIBGPS19
34 ATTR(gpsd_query)
35+#endif
36 ATTR(on_eof)
37 ATTR(command)
38 ATTR(src)
39Index: navit/navit/vehicle/gpsd/vehicle_gpsd.c
40===================================================================
41--- navit.orig/navit/vehicle/gpsd/vehicle_gpsd.c 2010-01-06 00:06:16.000000000 +0100
42+++ navit/navit/vehicle/gpsd/vehicle_gpsd.c 2010-01-06 00:08:44.000000000 +0100
43@@ -36,7 +36,9 @@
44
45 static struct vehicle_priv {
46 char *source;
47+#ifndef HAVE_LIBGPS19
48 char *gpsd_query;
49+#endif
50 struct callback_list *cbl;
51 struct callback *cb;
52 struct event_watch *evwatch;
53@@ -69,8 +71,12 @@
54 static void vehicle_gpsd_io(struct vehicle_priv *priv);
55
56 static void
57+#ifdef HAVE_LIBGPS19
58+vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len)
59+#else
60 vehicle_gpsd_callback(struct gps_data_t *data, char *buf, size_t len,
61 int level)
62+#endif
63 {
64 char *pos,*nmea_data_buf;
65 int i=0,sats_signal=0;
66@@ -108,16 +114,32 @@
67 data->set &= ~ALTITUDE_SET;
68 }
69 if (data->set & SATELLITE_SET) {
70+#ifdef HAVE_LIBGPS19
71+ if(data->satellites_visible > 0) {
72+#else
73 if(data->satellites > 0) {
74+#endif
75 sats_signal=0;
76+#ifdef HAVE_LIBGPS19
77+ for( i=0;i<data->satellites_visible;i++) {
78+#else
79 for( i=0;i<data->satellites;i++) {
80+#endif
81 if (data->ss[i] > 0)
82 sats_signal++;
83 }
84 }
85+#ifdef HAVE_LIBGPS19
86+ if (priv->sats_used != data->satellites_used || priv->sats != data->satellites_visible || priv->sats_signal != sats_signal ) {
87+#else
88 if (priv->sats_used != data->satellites_used || priv->sats != data->satellites || priv->sats_signal != sats_signal ) {
89+#endif
90 priv->sats_used = data->satellites_used;
91+#ifdef HAVE_LIBGPS19
92+ priv->sats = data->satellites_visible;
93+#else
94 priv->sats = data->satellites;
95+#endif
96 priv->sats_signal = sats_signal;
97 callback_list_call_attr_0(priv->cbl, attr_position_sats);
98 }
99@@ -135,10 +157,17 @@
100 priv->fix_time = data->fix.time;
101 data->set &= ~TIME_SET;
102 }
103+#ifdef HAVE_LIBGPS19
104+ if (data->set & DOP_SET) {
105+ dbg(1, "pdop : %g\n", data->dop.pdop);
106+ priv->hdop = data->dop.pdop;
107+ data->set &= ~DOP_SET;
108+#else
109 if (data->set & PDOP_SET) {
110 dbg(1, "pdop : %g\n", data->pdop);
111 priv->hdop = data->hdop;
112 data->set &= ~PDOP_SET;
113+#endif
114 }
115 if (data->set & LATLON_SET) {
116 priv->geo.lat = data->fix.latitude;
117@@ -180,7 +209,11 @@
118 dbg(0,"gps_open failed for '%s'. Retrying in %d seconds. Have you started gpsd?\n", priv->source, priv->retry_interval);
119 return TRUE;
120 }
121+#ifdef HAVE_LIBGPS19
122+ gps_stream(priv->gps, WATCH_ENABLE, NULL);
123+#else
124 gps_query(priv->gps, priv->gpsd_query);
125+#endif
126 gps_set_raw_hook(priv->gps, vehicle_gpsd_callback);
127 priv->cb = callback_new_1(callback_cast(vehicle_gpsd_io), priv);
128 priv->evwatch = event_add_watch((void *)priv->gps->gps_fd, event_watch_cond_read, priv->cb);
129@@ -268,8 +301,10 @@
130 vehicle_gpsd_close(priv);
131 if (priv->source)
132 g_free(priv->source);
133+#ifndef HAVE_LIBGPS19
134 if (priv->gpsd_query)
135 g_free(priv->gpsd_query);
136+#endif
137 g_free(priv);
138 }
139
140@@ -350,12 +385,17 @@
141 *cbl, struct attr **attrs)
142 {
143 struct vehicle_priv *ret;
144+#ifdef HAVE_LIBGPS19
145+ struct attr *source, *retry_int;
146+#else
147 struct attr *source, *query, *retry_int;
148+#endif
149
150 dbg(1, "enter\n");
151 source = attr_search(attrs, NULL, attr_source);
152 ret = g_new0(struct vehicle_priv, 1);
153 ret->source = g_strdup(source->u.str);
154+#ifndef HAVE_LIBGPS19
155 query = attr_search(attrs, NULL, attr_gpsd_query);
156 if (query) {
157 ret->gpsd_query = g_strconcat(query->u.str, "\n", NULL);
158@@ -363,6 +403,7 @@
159 ret->gpsd_query = g_strdup("w+x\n");
160 }
161 dbg(1,"Format string for gpsd_query: %s\n",ret->gpsd_query);
162+#endif
163 retry_int = attr_search(attrs, NULL, attr_retry_interval);
164 if (retry_int) {
165 ret->retry_interval = retry_int->u.num;
166Index: navit/navit/attr.h
167===================================================================
168--- navit.orig/navit/attr.h 2010-01-06 00:06:16.000000000 +0100
169+++ navit/navit/attr.h 2010-01-06 00:08:44.000000000 +0100
170@@ -25,6 +25,7 @@
171 #endif
172
173 #include "projection.h"
174+#include "config.h"
175
176 enum item_type;
177
178Index: navit/navit/map/garmin/Makefile.am
179===================================================================
180--- navit.orig/navit/map/garmin/Makefile.am 2010-01-06 00:09:00.000000000 +0100
181+++ navit/navit/map/garmin/Makefile.am 2010-01-06 00:09:09.000000000 +0100
182@@ -20,7 +20,7 @@
183 gentypes_SOURCES=gentypes.c
184
185 gentypes.$(OBJEXT): gentypes.c
186- $(CC_FOR_BUILD) -I$(top_srcdir)/navit -c -o $@ $<
187+ $(CC_FOR_BUILD) -I$(top_srcdir)/navit -I$(top_srcdir) -c -o $@ $<
188
189 gentypes$(EXEEXT): $(gentypes_OBJECTS) $(gentypes_DEPENDENCIES)
190 @rm -f gentypes$(EXEEXT)