# $HeadURL$ $LastChangedRevision$ # # This makefile will turn a single file called training-route-gpswandern.gpx that contains # *multiple* routes with names like '01 - Ammersee loop (126km)' into a single file called # training-route-combined.gpx that contains multiple routes with names like '01.00', '01.01', # '01.02', '02', '03', where each such route is either a chunk of or the whole of the # corresponding original route. # # Alexis's workflow is as follows: # # - visit http://www.gpswandern.de/gorp/gorp.shtml # - load the training-route-gpswandern.gpx route file # - add new training routes, edit old ones, etc # - decide which training route I will do next time, just noting the number at the beginning # of the name, e.g. 01. # - save the new routes back to the same file # - run 'make' with this Makefile in the same directory as the GPX file # - copy training-route-combined.gpx to the GPS # - on training day navigate route 01.00, then 01.01, then 01.02, etc. GPXSPLIT_CHUNK_CMD = gpxsplit-chunk GPXSPLIT_UNBUNDLE = gpxsplit-unbundle CHUNK_SIZE = 250 STEM = training-route default: $(STEM)-combined.gpx $(STEM)-combined.gpx: gpxsplitted.timestamp eval "gpsbabel -r -i gpx $$(for F in .gpxsplitted/[0-9]*.gpx; do echo -n "-f $$F "; done) -o gpx -F $@" gpxsplitted.timestamp: choppedup.timestamp rm -fr .gpxsplitted mkdir .gpxsplitted cd .gpxsplitted && $(GPXSPLIT_CHUNK_CMD) --count=$(CHUNK_SIZE) ../.choppedup/*.gpx touch $@ choppedup.timestamp: .$(STEM)-unixified.gpx rm -fr .choppedup mkdir .choppedup cd .choppedup && $(GPXSPLIT_UNBUNDLE) $(patsubst %.gpx, ../%.gpx, $^) touch $@ # Geo::Gpx doesn't like DOS line endings *in some situations*. The error I was seeing was: # # gpxsplit: INFO: ../choppedup/05-in2reg.gpx: processing file ... # # not well-formed (invalid token) at line 317, column 1, byte 8682 at /usr/share/perl5/XML/TokeParser.pm line 353. # Makefile:8: recipe for target 'gpxsplitted' failed # make: *** [gpxsplitted] Error 255 # # So Unixify the file before we start. .$(STEM)-unixified.gpx: $(STEM)-gpswandern.gpx cat $^ | dos2unix > $@ clean: rm -fr .gpxsplitted .choppedup .$(STEM)-unixified.gpx *.timestamp $(STEM)-combined.gpx