BINDIR = bin TMPDIR = tmp DOCDIR = doc HOLIDAYS = $(basename $(notdir $(wildcard $(DOCDIR)/*.xls))) CSV2XXX_CMD = csv2xxx INSTALLABLE_ITINERARYS = romantischestrasse han-use-ber cz-sk-hu cz-sk-hu-at seven-countries elbe-reloaded bodensee elbe-unczeched PATH := $(PATH):$(BINDIR) # There are a couple of commands in this makefile that are so long that they # make it difficult to see any warnings. Therefore I suppress make's displaying # of the command by use of '@' but get the recipe to echo a *shortened* version # of the command that ran. All good so far. However, sometimes I run 'make -s' # because I don't even want to see make displaying even *short* commands, but # then those commands that had shortened versions of the commands echoed *don't* # get suppressed. To fix this, the recipe itself checks whether '-s' is in # $(MAKEFLAGS) or not and echos or not accordingly. This is done a few times # in this makefile. $(TMPDIR)/installed.timestamp: $(TMPDIR)/compiled.timestamp $(patsubst %, $(TMPDIR)/%.installed, $(INSTALLABLE_ITINERARYS)) @touch $@ $(TMPDIR)/%.installed: $(TMPDIR)/%.csv $(TMPDIR)/%.html $(TMPDIR)/crosschecked.timestamp @B=$(patsubst $(TMPDIR)/%.installed,%,$@); \ for YYYYWW_HOLIDAY in ../holidays/20????-$$B; do \ [ "$(findstring s,$(MAKEFLAGS))" ] || echo "cp $(TMPDIR)/$$B.html $$YYYYWW_HOLIDAY/html/camps.html"; \ cp $(TMPDIR)/$$B.html $$YYYYWW_HOLIDAY/html/camps.html; \ chmod 644 $$YYYYWW_HOLIDAY/html/camps.html; \ [ "$(findstring s,$(MAKEFLAGS))" ] || echo "$(CSV2XXX_CMD) --output-format=gpx $(TMPDIR)/$$B.csv > $$YYYYWW_HOLIDAY/waypoints/$$B-waypoints-camps.gpx"; \ $(CSV2XXX_CMD) --output-format=gpx $(TMPDIR)/$$B.csv > $$YYYYWW_HOLIDAY/waypoints/$$B-waypoints-camps.gpx; \ done @touch $@ $(TMPDIR)/crosschecked.timestamp: $(TMPDIR)/compiled.timestamp @$(CSV2XXX_CMD) --output-format=csv $(addprefix $(TMPDIR)/,$(addsuffix .csv, $(HOLIDAYS))) > /dev/null @touch $@ $(TMPDIR)/compiled.timestamp: $(addprefix $(TMPDIR)/,$(addsuffix .html, $(HOLIDAYS))) $(addprefix $(TMPDIR)/,$(addsuffix .csv, $(HOLIDAYS))) touch $@ # See https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options, # especially the examples right at the end of the page. The important bits here are # '76' meaning UTF, 'true' meaning 'quote all text fields' $(TMPDIR)/%.csv: $(DOCDIR)/%.xls @[ "$(findstring s,$(MAKEFLAGS))" ] || echo "libreoffice ... --convert-to csv ... $<" @libreoffice -env:UserInstallation=file:///home/$$USER/.libreoffice-alt --headless --convert-to "csv:Text - txt - csv (StarCalc):44,34,76,1,1/1,,true" --outdir $(TMPDIR) $< > /dev/null $(TMPDIR)/%.html: $(TMPDIR)/%.csv $(CSV2XXX_CMD) --output-format=html $^ > $@ clean: rm -f $(TMPDIR)/*