"Initial commit to Gerrit"
[profile/ivi/gpsd.git] / Makefile.am
1 # Automake description for gpsd
2 #
3 # This file is Copyright (c) 2010 by the GPSD project
4 # BSD terms apply: see the file COPYING in the distribution root for details.
5 #
6
7 CLEANFILES =
8
9 # For a detailed explanation of what this ugly code is doing, see
10 # http://www.gnu.org/software/automake/manual/automake.html#Multiple-Outputs
11 MULTIOUT_RECOVER_DELETED = \
12         if test -f '$@'; then :; else \
13           trap "rm -rf '$$WITNESS.lock' '$$WITNESS'" HUP INT PIPE TERM; \
14           if mkdir "$$WITNESS.lock" 2>/dev/null; then \
15             rm -f "$$WITNESS"; \
16             $(MAKE) $(AM_MAKEFLAGS) "$$WITNESS"; \
17             result=$$?; rm -rf "$$WITNESS.lock"; exit $$result; \
18           else \
19             while test -d "$$WITNESS.lock"; do sleep 1; done; \
20             test -f "$$WITNESS"; \
21           fi; \
22         fi
23
24 #SUBDIRS = contrib
25
26 XMLTO = xmlto
27
28 #
29 # Conditionally add programs depending on libraries that may or may not be present.
30 #
31 if HAVE_NCURSES
32 CURSESPROGS = cgps gpsmon
33 endif
34
35 # Conditional includes.
36 INCLUDES = $(LIBUSB_CFLAGS)
37 if HAVE_DBUS
38 INCLUDES += $(DBUS_CFLAGS) $(DBUS_GLIB_CFLAGS) -DDBUS_API_SUBJECT_TO_CHANGE=1
39 endif
40 if HAVE_BLUEZ
41 INCLUDES += $(BLUEZ_CFLAGS)
42 endif
43
44 RTCM104PAGES_DIST = gpsdecode.1
45 if HAVE_RTCM104V2
46 if HAVE_RTCM104V3
47 if HAVE_AIVDM
48 RTCM104PROGS = gpsdecode
49 RTCM104PAGES = $(RTCM104PAGES_DIST)
50 endif
51 endif
52 endif
53
54 bin_PROGRAMS = $(XAW_PROGS) $(RTCM104PROGS) $(CURSESPROGS) gpsctl gpspipe gpxlogger lcdgps
55 sbin_PROGRAMS = gpsd
56
57 # \todo Add programs to TESTS if not already. used.
58 check_PROGRAMS = test_float test_trig test_bits test_packet test_mkgmtime test_geoid test_json
59 if LIBGPSMM_ENABLE
60 check_PROGRAMS += test_gpsmm
61 endif
62 if LIB_Q_GPSMM_ENABLE
63 check_PROGRAMS += test_qgpsmm
64 endif
65
66 # List of Python scripts and modules, which are handled by setup.py.
67 # Required to ensure that the extensions/modules/scripts are rebuilt via
68 # setup.py in case they changed.
69 # Also used to specify which files to include during make dist.
70 PYTHONSCRIPTS_DIST = gpscat gpsfake gpsprof xgps xgpsspeed
71 PYTHONMODULES_DIST = gps/__init__.py gps/misc.py gps/fake.py gps/gps.py gps/client.py
72
73 PYTHONPAGES_DIST = gpsprof.1 gpsfake.1 gpscat.1 xgpsspeed.1 xgps.1
74 if HAVE_PYTHON
75 python_PYTHON = gpscap.py
76 PYTHONPAGES = $(PYTHONPAGES_DIST)
77 endif
78
79
80 #
81 # Build cgps
82 #
83 cgps_SOURCES = cgps.c
84 cgps_LDADD = $(LIBM) $(LIBC) $(LIBNSL) $(LIBSOCKET) $(NCURSES_LIBS) libgps.la -lm $(LIBPTHREAD)
85
86 #
87 # Build gpxlogger
88 #
89 gpxlogger_SOURCES = gpxlogger.c
90 gpxlogger_LDADD = $(DBUS_GLIB_LIBS) libgps.la -lm
91
92 #
93 # Build gpsd
94 #
95 gpsd_c_sources = gpsd_dbus.c gpsd.c
96 gpsd_SOURCES = $(gpsd_c_sources) gpsd_dbus.h
97 gpsd_LDADD = $(DBUS_LIBS) $(LIBM) libgpsd.la libgps.la -lm $(LIBPTHREAD) $(LIBUSB_LIBS)
98
99 #
100 # Build gpsctl
101 #
102 gpsctl_SOURCES = gpsctl.c
103 gpsctl_LDADD = $(LIBM) libgpsd.la libgps.la -lm $(LIBPTHREAD) $(LIBUSB_LIBS)
104
105 #
106 # Build gpspipe
107 #
108 gpspipe_SOURCES = gpspipe.c
109 gpspipe_LDADD = $(DBUS_LIBS) $(LIBM) libgps.la -lm
110
111 #
112 # Build lcdgps
113 #
114 lcdgps_SOURCES = lcdgps.c
115 lcdgps_LDADD = $(LIBM) libgps.la -lm
116
117 #
118 # Build gpsmon
119 #
120 gpsmon_SOURCES = gpsmon.c monitor_nmea.c monitor_sirf.c \
121         monitor_italk.c monitor_ubx.c monitor_superstar2.c \
122         monitor_oncore.c monitor_tnt.c
123 gpsmon_LDADD = $(LIBM) $(NCURSES_LIBS) libgpsd.la libgps.la -lm $(LIBPTHREAD)  $(LIBUSB_LIBS)
124
125 #
126 # Build gpsdecode
127 #
128 gpsdecode_SOURCES = gpsdecode.c
129 gpsdecode_LDADD = $(LIBM) libgpsd.la libgps.la -lm $(LIBPTHREAD)  $(LIBUSB_LIBS)
130
131 #
132 # Build shared libraries
133 #
134 # As we need to retrieve the version from qmake to build the Qt library,
135 # we provide targets to print the necessary informations.
136 libgps_VERSION_CURRENT = 19
137 libgps_VERSION__REVISION = 0
138 libgps_VERSION_AGE = 0
139 libgps_VERSION_NUMBER = $(libgps_VERSION_AGE):$(libgps_VERSION__REVISION):$(libgps_VERSION_AGE)
140 libgps_la_LDFLAGS = -version-number $(libgps_VERSION_CURRENT):$(libgps_VERSION__REVISION):$(libgps_VERSION_AGE)
141 lib_LTLIBRARIES = libgps.la libgpsd.la
142
143 libgps_SONAME = $(shell expr $(libgps_VERSION_CURRENT) - $(libgps_VERSION_AGE))
144 libgps_VERSION = $(libgps_SONAME).$(libgps_VERSION_AGE).$(libgps_VERSION__REVISION)
145 print_libgps_VERSION_CURRENT:
146         echo $(libgps_VERSION_CURRENT)
147 print_libgps_VERSION__REVISION:
148         echo $(libgps_VERSION__REVISION)
149 print_libgps_VERSION_AGE:
150         echo $(libgps_VERSION_AGE)
151 print_libgps_SONAME:
152         echo $(libgps_SONAME)
153 print_libgps_VERSION:
154         echo $(libgps_VERSION)
155
156 libgps_c_sources = \
157         ais_json.c \
158         gpsd_report.c \
159         gpsutils.c \
160         geoid.c \
161         gpsdclient.c \
162         gps_maskdump.c \
163         hex.c \
164         json.c \
165         libgps_core.c \
166         libgps_json.c \
167         netlib.c \
168         rtcm2_json.c \
169         shared_json.c \
170         strl.c
171
172 libgpsd_c_sources = \
173         bits.c \
174         bsd-base64.c \
175         crc24q.c \
176         gpsd_json.c \
177         isgps.c \
178         gpsd_maskdump.c \
179         libgpsd_core.c \
180         net_dgpsip.c \
181         net_gnss_dispatch.c \
182         net_ntrip.c \
183         ntpshm.c \
184         packet.c \
185         pseudonmea.c \
186         serial.c \
187         srecord.c \
188         subframe.c \
189         drivers.c \
190         driver_aivdm.c \
191         driver_evermore.c \
192         driver_garmin.c \
193         driver_garmin_txt.c \
194         driver_italk.c \
195         driver_navcom.c \
196         driver_nmea.c \
197         driver_oncore.c \
198         driver_rtcm2.c \
199         driver_rtcm3.c \
200         driver_sirf.c \
201         driver_superstar2.c \
202         driver_tsip.c \
203         driver_ubx.c \
204         driver_zodiac.c
205
206 libgpsd_h_sources = \
207         sockaddr.h \
208         bsd-base64.h \
209         timebase.h \
210         bits.h \
211         crc24q.h
212
213 BUILT_SOURCES = packet_names.h gpsd.h revision.h ais_json.i gps_maskdump.c gpsd_maskdump.c
214
215 packet_names.h: packet_states.h
216         rm -f packet_names.h && \
217         sed -e '/^ *\([A-Z][A-Z0-9_]*\),/s//   "\1",/' -e '/_states/s//_names/' < `test -f 'packet_states.h' || echo '$(srcdir)/'`packet_states.h > packet_names.h && \
218         chmod a-w packet_names.h
219
220 gpsd.h: gpsd.h-head gpsd.h-tail gpsd_config.h
221         rm -f gpsd.h && \
222         echo "/* This file is generated.  Do not hand-hack it! */" >gpsd.h && \
223         cat $(srcdir)/gpsd.h-head >>gpsd.h && \
224         cat $(srcdir)/gpsd_config.h >>gpsd.h && \
225         cat $(srcdir)/gpsd.h-tail >>gpsd.h && \
226         chmod a-w gpsd.h
227
228 ais_json.i: jsongen.py
229         rm -f ais_json.i && \
230         $(PYTHON) jsongen.py --ais --target=parser >ais_json.i && \
231         chmod a-w ais_json.i
232
233 revision.h: Makefile
234         @rm -f revision.h && \
235         echo '#define' REVISION '"'`date -u +%Y-%m-%dT%H:%M:%S`'"' >revision.h && \
236         chmod a-w revision.h
237
238 gps_maskdump.c: gps.h maskaudit.py
239         rm -f gps_maskdump.c && \
240         $(PYTHON) maskaudit.py -c >gps_maskdump.c && \
241         chmod a-w gps_maskdump.c
242
243 gpsd_maskdump.c: gpsd.h maskaudit.py
244         rm -f gpsd_maskdump.c && \
245         $(PYTHON) maskaudit.py -d >gpsd_maskdump.c && \
246         chmod a-w gpsd_maskdump.c
247
248 libgps_la_SOURCES = $(libgps_c_sources)
249
250 libgpsd_la_SOURCES = $(libgpsd_c_sources) $(libgpsd_h_sources) \
251                                 driver_rtcm2.h packet_states.h
252
253 # Warning: This overrides autoconf's normal link-line generation process
254 if LIBGPSMM_ENABLE
255 libgps_la_SOURCES += libgpsmm.cpp
256 libgps_la_LINK = /bin/sh ./libtool --tag=CXX --mode=link g++ $(libgps_la_LDFLAGS) -o $@
257 else
258 libgps_la_LINK = /bin/sh ./libtool --tag=CC --mode=link gcc $(libgps_la_LDFLAGS) -o $@
259 endif
260
261 nodist_libgpsd_la_SOURCES = packet_names.h ais_json.i
262 libgps_la_LIBADD = $(LIBM) $(LIBC) $(LIBNSL) $(LIBSOCKET) $(LIBPTHREAD)
263 libgpsd_la_LIBADD = $(LIBM) $(LIBC) $(LIBNSL) $(LIBSOCKET) $(LIBPTHREAD) $(BLUEZ_LIBS) libgps.la
264
265 noinst_SCRIPTS =
266
267 # Build Python binding
268 #
269 if HAVE_PYTHON
270 PYEXTENSIONS = gpspacket.so gpslib.so
271 noinst_SCRIPTS += stamp-python setup.py
272
273 # Multiple-outputs hack.  See
274 # http://www.gnu.org/software/automake/manual/automake.html#Multiple-Outputs
275 $(PYEXTENSIONS): stamp-python
276         +@WITNESS=stamp-python; $(MULTIOUT_RECOVER_DELETED)
277 # TODO:  Should the dependency on libgps.la be enforced inside
278 # setup.py?  (See the variable 'needed_files' in setup.py.)
279 stamp-python: gpspacket.c gpsclient.c libgps.la setup.py $(PYTHONMODULES_DIST) $(PYTHONSCRIPTS_DIST)
280 # Build Python modules and scripts using distutils via setup.py.
281 # We define build-lib and build-scripts as distutils might have been
282 # configured to use different directories, but we want to use the
283 # produced files within the regress-driver script - therefore we
284 # need to build them in directories we know about.
285 # See configure.ac for the definition of PYTHON_DISTUTILS_LIBDIR
286 # and PYTHON_DISTUTILS_SCRIPTDIR.
287         @rm -f '$@' '$@.tmp'
288         @echo 'timestamp for $@' > '$@.tmp'
289         (cd '$(srcdir)' && \
290         env abs_builddir='$(abs_builddir)' \
291             MAKE='$(MAKE)' \
292                 $(PYTHON) setup.py build \
293                         --build-lib '$(srcdir)/$(PYTHON_DISTUTILS_LIBDIR)' \
294                         --build-scripts '$(srcdir)/$(PYTHON_DISTUTILS_SCRIPTDIR)' \
295                         --mangenerator '$(XMLPROC)') && \
296         (cd '$(srcdir)/gps' && \
297             rm -f *.so && \
298             ln -s ../$(PYTHON_DISTUTILS_LIBDIR)/gps/*.so . ) && \
299         mv -f '$@.tmp' '$@'
300 CLEANFILES += stamp-python stamp-python.tmp
301 endif
302
303 QTLIB_DIST = libQgpsmm/libQgpsmm.pro \
304              libQgpsmm/gpsutils.cpp \
305              libQgpsmm/libgps_core.cpp \
306              libQgpsmm/libQgpsmm_global.h
307
308 QTLIB_DIST_MINGW = libQgpsmm/mingw/gpsd_config.h \
309                    libQgpsmm/mingw/test_qgpsmm.pro
310
311 if LIB_Q_GPSMM_ENABLE
312 noinst_SCRIPTS += stamp-qt
313 QTLIBS = libQgpsmm/binaries/libQgpsmm.so \
314          libQgpsmm/binaries/libQgpsmm.so.$(libgps_SONAME) \
315          libQgpsmm/binaries/libQgpsmm.so.$(libgps_SONAME).$(libgps_VERSION_AGE) \
316          libQgpsmm/binaries/libQgpsmm.so.$(libgps_VERSION)
317
318 QTLIB_sources = gpsutils.c \
319                 libgps_core.c \
320                 libgpsmm.cpp \
321                 libgps_json.c \
322                 hex.c \
323                 gpsd_report.c \
324                 strl.c \
325                 shared_json.c \
326                 rtcm2_json.c \
327                 ais_json.c \
328                 json.c \
329                 gps.h \
330                 libgpsmm.h \
331                 gps_json.h \
332                 json.h \
333                 ais_json.i \
334                 gpsd.h \
335                 $(QTLIB_DIST)
336
337 QMAKE_OPTS = "PREFIX=${prefix}" \
338              "MAKE=$(MAKE)" \
339              "QMAKE_CXX=$(CXX)" \
340              "QMAKE_CC=$(CC)" \
341              "QMAKE_CFLAGS+=$(CFLAGS)" \
342              "QMAKE_LFLAGS+=$(LDFLAGS)" \
343              "VERSION=$(libgps_VERSION)" \
344              "TARGET_LIBDIR=${libdir}" \
345              "TARGET_INCLUDEDIR=${includedir}"
346
347 libQgpsmm/Makefile: libQgpsmm/libQgpsmm.pro gpsd.h ais_json.i
348         cd $(srcdir)/libQgpsmm && $(QMAKE) $(QMAKE_OPTS)
349 # Yet another multiple-outputs hack:
350 $(QTLIBS): stamp-qt
351                 +@WITNESS=stamp-qt; $(MULTIOUT_RECOVER_DELETED)
352 stamp-qt: $(QTLIB_sources) libQgpsmm/Makefile
353         $(MAKE) -C $(srcdir)/libQgpsmm
354         touch $@
355 CLEANFILES += stamp-qt
356 endif
357
358 # Clean up after Python and QT
359 clean-local:
360 if HAVE_PYTHON
361         rm -rf build gps/*.so
362 endif
363 if LIB_Q_GPSMM_ENABLE
364         if test -r $(srcdir)/libQgpsmm/Makefile; then \
365                 $(MAKE) -C $(srcdir)/libQgpsmm distclean || true;  \
366         fi
367         rm -rf $(srcdir)/libQgpsmm/binaries
368         rm -f $(srcdir)/libQgpsmm/*.o $(srcdir)/libQgpsmm/Makefile
369 endif
370
371 # Install Python modules and QT library
372 install-exec-local:
373 if HAVE_PYTHON
374 # Make sure we do not use --root as option to setup.py install
375 # when DESTDIR is not defined as distutils would use the current
376 # working directory as root directory and not install to ${prefix}.
377         if test -z "$(DESTDIR)"; then \
378                 $(PYTHON) setup.py install --prefix=${prefix} ;\
379         else \
380                 $(PYTHON) setup.py install --prefix=${prefix} --root=$(DESTDIR) ;\
381         fi
382 endif
383 if LIB_Q_GPSMM_ENABLE
384         $(MAKE) -C libQgpsmm install INSTALL_ROOT=$(DESTDIR)
385 endif
386
387 #
388 # Build test_float
389 #
390 test_float_SOURCES = test_float.c
391 test_float_LDADD = $(LIBC) -lm
392
393 #
394 # Build test_trig
395 #
396 test_trig_SOURCES = test_trig.c
397 test_trig_LDADD = $(LIBC) -lm
398
399 if LIBGPSMM_ENABLE
400 #
401 # Build test_gpsmm
402 #
403 test_gpsmm_SOURCES = test_gpsmm.cpp
404 test_gpsmm_LDADD = $(LIBC) libgps.la -lm  $(LIBUSB_LIBS)
405 endif
406
407 if LIB_Q_GPSMM_ENABLE
408 #
409 # Build test_qgpsmm
410 #
411 test_qgpsmm_SOURCES = test_gpsmm.cpp
412 test_qgpsmm_LDFLAGS = -Wl,-rpath,$(srcdir)/libQgpsmm/binaries
413 test_qgpsmm_LDADD = $(LIBC) $(LIBUSB) $(QtNetwork_LIBS) -LlibQgpsmm/binaries -lQgpsmm
414 test_qgpsmm_DEPENDENCIES = libQgpsmm/binaries/libQgpsmm.so
415 endif
416
417 #
418 # Build test_bits tester
419 #
420 test_bits_SOURCES = test_bits.c
421 test_bits_LDADD = $(LIBC) libgpsd.la libgps.la  $(LIBUSB_LIBS)
422
423 #
424 # Build packets tester
425 #
426 test_packet_SOURCES = test_packet.c
427 test_packet_LDADD = $(LIBC) libgpsd.la libgps.la -lm  $(LIBUSB_LIBS)
428
429 #
430 # Build geoid model tester
431 #
432 test_geoid_SOURCES = test_geoid.c
433 test_geoid_LDADD = $(LIBC) libgps.la -lm
434
435 #
436 # Build time functions tester
437 #
438 test_mkgmtime_SOURCES = test_mkgmtime.c
439 test_mkgmtime_LDADD = $(LIBC) libgps.la -lm
440
441 #
442 # Build JSON parse tester
443 test_json_SOURCES = test_json.c
444 test_json_LDADD = $(LIBC) libgps.la -lm
445
446 MANPAGES_BASE = \
447         gpsd.8 \
448         gps.1 \
449         cgps.1 \
450         lcdgps.1 \
451         libgps.3 \
452         libgpsmm.3 \
453         libgpsd.3 \
454         gpsmon.1 \
455         gpsctl.1 \
456         gpspipe.1 \
457         rtcm-104.5 \
458         srec.5
459
460 if HAVE_XSLT_PROCESSOR
461 MANPAGES_DIST = \
462         $(MANPAGES_BASE) \
463         $(RTCM104PAGES_DIST) \
464         $(PYTHONPAGES_DIST)
465
466 man_MANS = \
467         $(MANPAGES_BASE) \
468         $(RTCM104PAGES) \
469         $(PYTHONPAGES)
470
471 #
472 # Create Manpages
473 #
474 BUILT_MANPAGES = $(MANPAGES_DIST)
475
476 .xml.1:
477         $(XMLPROC) $(XMLPROCFLAGS) $(MANTARGET) $<
478
479 .xml.3:
480         $(XMLPROC) $(XMLPROCFLAGS) $(MANTARGET) $<
481
482 .xml.5:
483         $(XMLPROC) $(XMLPROCFLAGS) $(MANTARGET) $<
484
485 .xml.8:
486         $(XMLPROC) $(XMLPROCFLAGS) $(MANTARGET) $<
487
488 # Another instance of the multiple-outputs hack.
489 gps.1 xgps.1 xgpsspeed.1 cgps.1 lcdgps.1: stamp-gps-manpages
490         +@WITNESS=stamp-gps-manpages; $(MULTIOUT_RECOVER_DELETED)
491 stamp-gps-manpages: gps.xml
492         @rm -f '$@' '$@.tmp'
493         echo 'timestamp for $@' > '$@.tmp' && \
494         $(XMLPROC) $(XMLPROCFLAGS) $(MANTARGET) '$(srcdir)/gps.xml' && \
495         mv -f '$@.tmp' '$@'
496 CLEANFILES += stamp-gps-manpages stamp-gps-manpages.tmp
497 endif
498
499 noinst_HEADERS = gpsd_config.h \
500         driver_italk.h driver_rtcm2.h driver_superstar2.h \
501         driver_ubx.h gpsmon.h gpsdclient.h json.h gps_json.h \
502         revision.h TachometerP.h Tachometer.h
503 nodist_include_HEADERS = gpsd.h
504
505 if LIBGPSMM_ENABLE
506 include_HEADERS = gps.h libgpsmm.h
507 else
508 include_HEADERS = gps.h
509 endif
510
511 XML = \
512         gpsd.xml \
513         gps.xml \
514         libgps.xml \
515         libgpsmm.xml \
516         libgpsd.xml \
517         gpsmon.xml \
518         gpsdecode.xml \
519         gpsprof.xml \
520         gpsfake.xml \
521         gpsctl.xml \
522         gpscat.xml \
523         gpspipe.xml \
524         rtcm-104.xml \
525         srec.xml
526
527 # Note: packaging/rpm/gpsd.spec is generated, but it needs to be in the
528 # tarball in order for 'make dist-rpm' to work.  The BUILT_SOURCES
529 # files are here in order to minimize build dependencies for package
530 # builders who never alter anything, especially the Python dependency.
531 # Also note that the test and gps directories are here rather than
532 # being the contents of a SUBDIRS variable so that autconf won't 
533 # go looking for makefiles in them.
534 EXTRA_DIST = \
535         revision.h \
536         autogen.sh \
537         README \
538         INSTALL \
539         COPYING \
540         TODO \
541         NEWS \
542         AUTHORS \
543         jsongen.py.in \
544         maskaudit.py.in \
545         dgpsip-servers \
546         test_float.c \
547         test_trig.c \
548         gpsd.php \
549         gpsd.xml \
550         gpsd.h-head \
551         gpsd.h-tail \
552         $(XML) \
553         $(BUILT_SOURCES) \
554         $(MANPAGES_DIST) \
555         gpsd.rules \
556         gpsd.hotplug \
557         gpsd.hotplug.wrapper \
558         gpsd.usermap \
559         valgrind-audit \
560         valgrind-suppressions \
561         gpspacket.c \
562         gpsclient.c \
563         driver_proto.c \
564         monitor_proto.c \
565         setup.py \
566         packet_states.h \
567         libgps.pc.in \
568         libgpsd.pc.in \
569         gpscap.ini \
570         packaging/deb/etc_default_gpsd \
571         packaging/deb/etc_init.d_gpsd \
572         packaging/rpm/gpsd.spec \
573         packaging/rpm/gpsd.init \
574         packaging/rpm/gpsd.sysconfig \
575         packaging/X11/xgps.desktop \
576         packaging/X11/xgpsspeed.desktop \
577         packaging/X11/gpsd-logo.png \
578         do-tests \
579         regress-driver \
580         $(PYTHONSCRIPTS_DIST) \
581         $(PYTHONMODULES_DIST) \
582         $(QTLIB_DIST) \
583         $(QTLIB_DIST_MINGW) \
584         test
585
586
587 # Prepare necessary files to build the mingw-port of libQgpsmm
588 # while creating the dist tarball.
589 dist-hook: ais_json.i gpsd_config.h
590         $(MKDIR_P) '$(distdir)/libQgpsmm/mingw'
591         cp -p ais_json.i $(distdir)/libQgpsmm/mingw
592         grep "#define VERSION" gpsd_config.h > $(distdir)/libQgpsmm/mingw/version.h
593         echo "VERSION=$(libgps_VERSION)" > $(distdir)/libQgpsmm/mingw/version.pri
594 distclean-local:
595         rm -f $(distdir)/libQgpsmm/mingw/version.* $(distdir)/libQgpsmm/mingw/ais_json.i
596
597
598 CLEANFILES += $(BUILT_SOURCES) *.core $(PYEXTENSIONS) $(BUILT_MANPAGES)
599
600 pkgconfig_DATA = libgps.pc libgpsd.pc
601 pkgconfigdir = $(libdir)/pkgconfig
602
603 # These are not distributed
604 libgps: libgps_core.c gps.h .libs/libgps.a
605         $(CC) $(CFLAGS) -o libgps -lm -DTESTMAIN $(LIBPTHREAD) -g libgps_core.c .libs/libgps.a
606
607 # Report splint warnings
608 SPLINTOPTS = -I/usr/include/dbus-1.0/ $(LIBUSB_CFLAGS) +quiet
609 splint: gpsd.h packet_names.h
610         @echo "Running splint on daemon and libraries..."
611         -splint $(SPLINTOPTS) -exportlocal -redef $(gpsd_c_sources) $(libgpsd_c_sources) $(libgps_c_sources)
612         @echo "Running splint on cgps..."
613         -splint $(SPLINTOPTS) -exportlocal $(cgps_SOURCES)
614         @echo "Running splint on gpsctl..."
615         -splint $(SPLINTOPTS) $(gpsctl_SOURCES)
616         @echo "Running splint on gpsmon..."
617         -splint $(SPLINTOPTS) -exportlocal $(gpsmon_SOURCES)
618         @echo "Running splint on gpspipe..."
619         -splint $(SPLINTOPTS) $(gpspipe_SOURCES)
620         @echo "Running splint on gpsdecode..."
621         -splint $(SPLINTOPTS) $(gpsdecode_SOURCES)
622         @echo "Running splint on gpxlogger..."
623         -splint $(SPLINTOPTS) $(gpxlogger_SOURCES)
624         @echo "Running splint on test_bits test harness..."
625         -splint $(SPLINTOPTS) $(test_bits_SOURCES)
626         @echo "Running splint on test_packet test harness..."
627         -splint $(SPLINTOPTS) $(test_packet_SOURCES)
628         @echo "Running splint on test_mkgmtime test harness..."
629         -splint $(SPLINTOPTS) $(test_mkgmtime_SOURCES)
630         @echo "Running splint on test_geoid test harness..."
631         -splint $(SPLINTOPTS) $(test_geoid_SOURCES)
632         @echo "Running splint on test_json test harness..."
633         -splint $(SPLINTOPTS) $(test_json_SOURCES)
634
635 # Report cppcheck warnings.  Requires 1.40 or later.
636 cppcheck: gpsd.h packet_names.h
637         cppcheck --template gcc --all --force .
638
639 # Check the documentation for bogons, too
640 xmllint: $(XML)
641         for xml in $(XML); do xmllint --nonet --noout --valid $$xml; done
642
643 # Re-indent the codebase in a uniform style for readability.
644 INDENT_FILES = $(gpsd_c_sources) $(libgpsd_c_sources) $(libgps_c_sources) \
645         $(cgps_SOURCES) $(gpsmon_SOURCES) $(gpspipe_SOURCES) \
646         $(gpxlogger_SOURCES) $(gpsdecode_SOURCES) \
647         $(test_bits_SOURCES) $(test_packet_SOURCES) \
648         $(test_mkgmtime_SOURCES)  $(test_geoid_SOURCES) $(test_json_SOURCES)
649 INDENT_OPTIONS = --indent-level4 \
650                 --honour-newlines \
651                 --dont-break-procedure-type \
652                 --cuddle-else \
653                 --braces-on-if-line \
654                 --case-brace-indentation0 \
655                 --brace-indent0 \
656                 --no-space-after-casts \
657                 --no-space-after-function-call-names \
658                 --start-left-side-of-comments \
659                 --dont-format-comments
660 indent:
661         chmod u+w *maskdump.c
662         indent $(INDENT_OPTIONS) $(INDENT_FILES)
663         for f in $(INDENT_FILES); \
664                 do \
665                         sed <$${f} >/tmp/reindent$$$$ -e 's/@ \*/@*/' ; \
666                         mv /tmp/reindent$$$$ $${f} ; \
667                 done
668         chmod u-w *maskdump.c
669         @echo "Diff lines:" `git diff | wc -l`
670
671 version:
672         @echo $(VERSION)
673
674 #
675 # Regression tests begin here
676 #
677 # Note that the *-makeregress targets re-create the *.log.chk source
678 # files from the *.log source files.
679 #
680 # These require gcc4; use of the math coprocessor's on-board trig functions
681 # apparently increases the accuracy of computation in a way that affects
682 # the low-order digits of the track field in the O response.
683
684 # Our regression tests are make targets, while automake expects
685 # programs.  Thus, our approach is to construct the test
686 # infrastructure our way, with make targets, and to have one TEST from
687 # automake's viewpoint: a trivial shell script to invoke make with our
688 # top-level regression target.
689
690 # One might think that using TESTS_ENVIRONMENT=$(MAKE) would work
691 # around this, but because the generated rule (check-TESTS) both
692 # depends on each TEST as well as invokes it (with TESTS_ENVIRONMENT)
693 # the entire list of tests is run twice.
694
695 # Use make REGRESSOPTS=-u to force running with UDP rather than pty devices
696
697 run_regress_driver = PYTHON=$(PYTHON) $(srcdir)/regress-driver $(REGRESSOPTS)
698
699 # Regression-test the daemon
700 gps-regress: gpsd stamp-python
701         $(run_regress_driver) $(srcdir)/test/daemon/*.log
702
703 # Test that super-raw mode works. Compare each logfile against itself 
704 # dumped through the daemon running in R=2 mode.  (This test is not
705 # included in the normal regressions.)
706 raw-regress: stamp-python
707         $(run_regress_driver) -r  $(srcdir)/test/daemon/*.log
708
709 # Build the regression tests for the daemon.
710 gps-makeregress: gpsd stamp-python
711         $(run_regress_driver) -b $(srcdir)/test/daemon/*.log
712
713 # To build an individual test for a load named foo.log, put it in
714 # test/daemon and do this:
715 #       regress-driver -b test/daemon/foo.log
716
717 # Regression-test the RTCM decoder.
718 rtcm-regress: gpsdecode
719         @echo "Testing RTCM decoding..."
720         @mkdir -p test
721         @for f in $(srcdir)/test/*.rtcm2; do \
722                 echo "Testing $${f}..."; \
723                 $(srcdir)/gpsdecode <$${f} >/tmp/test-$$$$.chk; \
724                 diff -ub $${f}.chk /tmp/test-$$$$.chk; \
725         done;
726         @echo "Testing idempotency of JSON dump/decode for RTCM2"
727         @$(srcdir)/gpsdecode -e -j <test/synthetic-rtcm2.json >/tmp/test-$$$$.chk; \
728                 grep -v '^#' test/synthetic-rtcm2.json | diff -ub - /tmp/test-$$$$.chk; \
729                 rm /tmp/test-$$$$.chk
730
731 # Rebuild the RTCM regression tests.
732 rtcm-makeregress: gpsdecode
733         @for f in $(srcdir)/test/*.rtcm2; do \
734                 $(srcdir)/gpsdecode -j < $${f} > $${f}.chk; \
735         done
736
737 # Regression-test the AIVDM decoder.
738 aivdm-regress: gpsdecode
739         echo "Testing AIVDM decoding..."
740         @mkdir -p $(srcdir)/test
741         @for f in $(srcdir)/test/*.aivdm; do \
742                 echo "Testing $${f}..."; \
743                 $(srcdir)/gpsdecode -u -c <$${f} >/tmp/test-$$$$.chk; \
744                 diff -ub $${f}.chk /tmp/test-$$$$.chk; \
745         done;
746         @echo "Testing idempotency of JSON dump/decode for AIS"
747         @$(srcdir)/gpsdecode -e -j <$(srcdir)/test/synthetic-ais.json >/tmp/test-$$$$.chk; \
748                 grep -v '^#' $(srcdir)/test/synthetic-ais.json | diff -ub - /tmp/test-$$$$.chk; \
749                 rm /tmp/test-$$$$.chk
750
751 # Rebuild the AIVDM regression tests.
752 aivdm-makeregress: gpsdecode
753         @for f in $(srcdir)/test/*.aivdm; do \
754                 $(srcdir)/gpsdecode -u -c <$${f} > $${f}.chk; \
755         done
756
757 # Regression-test the packet getter.
758 packet-regress: test_packet
759         @echo "Testing detection of invalid packets..."
760         @$(srcdir)/test_packet | diff -u $(srcdir)/test/packet.test.chk -
761
762 # Rebuild the packet-getter regression test
763 packet-makeregress: test_packet
764         @mkdir -p $(srcdir)/test
765         $(srcdir)/test_packet >$(srcdir)/test/packet.test.chk
766
767 # Regression-test the geoid tester.
768 geoid-regress: test_geoid
769         @echo "Testing the geoid model..."
770         @$(srcdir)/test_geoid 37.371192 122.014965 | diff -u $(srcdir)/test/geoid.test.chk -
771
772 # Rebuild the packet-getter regression test
773 geoid-makeregress: test_geoid
774         @mkdir -p $(srcdir)/test
775         $(srcdir)/test_geoid 37.371192 122.014965 >$(srcdir)/test/geoid.test.chk
776
777 # Regression-test the calendar functions
778 time-regress: test_mkgmtime
779         $(srcdir)/test_mkgmtime
780
781 # Regression test the unpacking code in libgps
782 unpack-regress: libgps
783         @echo "Testing the client-library sentence decoder..."
784         $(run_regress_driver) -c $(srcdir)/test/clientlib/*.log
785
786 # Build the regression test for the sentence unpacker
787 unpack-makeregress: libgps
788         @echo "Rebuilding the client sentence-unpacker tests..."
789         $(run_regress_driver) -c -b $(srcdir)/test/clientlib/*.log
790
791 # Unit-test the JSON parsing
792 json-regress: test_json
793         $(srcdir)/test_json
794
795 # Unit-test the bitfield extractor - not in normal tests
796 bits-regress: test_bits
797         $(srcdir)/test_bits
798
799 # Do all normal regression tests.
800 testregress: gps-regress rtcm-regress aivdm-regress packet-regress time-regress unpack-regress json-regress
801         @echo "Regressions complete."
802
803 # do-tests is a shell script that invokes make with target testregress.
804 # This works around automake's lack of support for make targets as tests.
805 TESTS_ENVIRONMENT = MAKE=$(MAKE) PYTHON=$(PYTHON)
806 TESTS = do-tests
807
808 # The website directory
809 #
810 # None of these productions are fired by 'make all'.
811
812 if XMLTOSTDOUT
813 www/%.html: %.xml
814         $(XMLPROC) $(XMLPROCFLAGS) $(HTMLTARGET) $< >$(<:.xml=.html) ; cp $(<:.xml=.html) $@
815 else
816 www/%.html: %.xml
817         $(XMLPROC) $(XMLPROCFLAGS) $(HTMLTARGET) $<; cp $(<:.xml=.html) $@
818 endif
819
820 website: www/gpscat.html www/gpsctl.html www/gpsdecode.html \
821                 www/gpsd.html www/gpsfake.html www/gpsmon.html \
822                 www/gpspipe.html www/gpsprof.html www/gps.html \
823                 www/libgpsd.html www/libgpsmm.html www/libgps.html \
824                 www/rtcm-104.html www/srec.html \
825                 www/AIVDM.html www/NMEA.html \
826                 www/protocol-evolution.html www/protocol-transition.html \
827                 www/client-howto.html www/writing-a-driver.html \
828                 www/index.html www/hardware.html \
829                 www/performance/performance.html \
830                 www/internals.html
831
832 www/AIVDM.html: www/AIVDM.txt
833         asciidoc -a toc -o www/AIVDM.html www/AIVDM.txt
834
835 www/NMEA.html: www/NMEA.txt
836         asciidoc -a toc -o www/NMEA.html www/NMEA.txt
837
838 www/protocol-evolution.html: www/protocol-evolution.txt
839         asciidoc -a toc -o www/protocol-evolution.html www/protocol-evolution.txt
840
841 www/protocol-transition.html: www/protocol-transition.txt
842         asciidoc -a toc -o www/protocol-transition.html www/protocol-transition.txt
843
844 www/client-howto.html: www/client-howto.txt
845         asciidoc -a toc -o www/client-howto.html www/client-howto.txt
846
847 www/writing-a-driver.html: www/writing-a-driver.xml
848         xmlto xhtml-nochunks www/writing-a-driver.xml; mv writing-a-driver.html www
849
850 www/index.html: www/index.html.in
851         sed -e "/@DATE@/s//`date '+%B %d, %Y'`/" <www/index.html.in >www/index.html
852
853 www/hardware.html: www/hardware-head.html gpscap.ini www/hardware-tail.html
854         (cat www/hardware-head.html; python gpscap.py; cat www/hardware-tail.html) >www/hardware.html
855
856 www/performance/performance.html: www/performance/performance.xml
857         (cd www/performance; xmlto xhtml-nochunks performance.xml)
858
859 www/internals.html: $(shell ls doc/*.xml)
860         cd doc; xmlto xhtml-nochunks explanation.xml; cp explanation.html ../www/internals.html
861
862 if HAVE_PYTHON
863 # Experimenting with pydoc.  Not yet fired by any other productions.
864
865 pydoc: www/pydoc/index.html
866
867 # We need to run epydoc with the Python version we built the modules for.
868 # So we define our on epydoc instead of using /usr/bin/epydoc
869 EPYDOC = $(PYTHON) -c 'from epydoc.cli import cli; cli()'
870
871 # We have pre-compiled python scripts in the script directory, so we exclude
872 # all files ending on c here. Needs a better solution as soon as we have a
873 # script ending with c.
874 EPYDOCSCRIPTS = $(shell find $(PYTHON_DISTUTILS_SCRIPTDIR) -name '*c' -o -type f -print)
875 EPYDOCMODULES = $(PYTHON_DISTUTILS_LIBDIR)/gps
876
877 www/pydoc/index.html: gps gpsfake gpscat gpsprof stamp-python
878         mkdir -p www/pydoc
879         $(EPYDOC) -v --html --graph all -n GPSD $(EPYDOCSCRIPTS) $(EPYDOCMODULES) -o www/pydoc
880
881 endif
882
883 # Productions for setting up and performing udev tests.
884 #
885 # Requires root. Do "udev-install", then "tail -f /var/run/syslog" in
886 # another window, then run 'make udev-test', then plug and unplug the
887 # GPS ad libitum.  All is well when you get fix reports each time a GPS
888 # is plugged in.
889
890 udev-install:
891         cp $(srcdir)/gpsd.rules /lib/udev/rules.d/025_gpsd.rules
892         cp $(srcdir)/gpsd.hotplug $(srcdir)/gpsd.hotplug.wrapper /lib/udev/
893         chmod a+x /lib/udev/gpsd.hotplug /lib/udev/gpsd.hotplug.wrapper
894
895 udev-uninstall:
896         rm -f /lib/udev/{gpsd.hotplug,gpsd.hotplug.wrapper}
897         rm -f /lib/udev/rules.d/025_gpsd.rules
898
899 udev-test:
900         $(srcdir)/gpsd -N -F /var/run/gpsd.sock -D 4
901
902 # Release machinery begins here
903 #
904
905 # Make RPM from the specfile in packaging
906 dist-rpm: distdir
907         tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
908         rpmbuild -ta $(distdir).tar.gz
909         $(am__remove_distdir)
910
911 # This is how to ship a release to Berlios incoming.
912 # It requires developer access verified via ssh.
913 #
914 upload-ftp: dist
915         shasum gpsd-$(VERSION).tar.gz >gpsd.sum
916         lftp -c "open ftp://ftp.berlios.de/incoming; mput gpsd-$(VERSION).tar.gz gpsd.sum"
917
918 #
919 # This is how to tag a release.
920 # It requires developer access verified via ssh.
921 #
922 release-tag:
923         git tag -s -m "Tagged for external release $(VERSION)" release-$(VERSION)
924         git push --tags
925
926 #
927 # Ship a release, providing all regression tests pass.
928 # The clean is necessary so that dist will remake revision.h
929 # with the current revision level in it.
930 #
931 ship: testregress clean dist upload-ftp release-tag
932
933
934 .PHONY: print_libgps_VERSION_CURRENT \
935         print_libgps_VERSION__REVISION \
936         print_libgps_VERSION_AGE \
937         print_libgps_SONAME \
938         print_libgps_VERSION \
939         pydoc