# $Id: Makefile,v 1.2 2005/04/22 15:56:01 connolly Exp $

PERL=perl
PYTHON=python
XSLTPROC=xsltproc
TIDY=tidy

W=../..
CAL=$(W)/2002/12/cal
SWAP=$(W)/2000/10/swap
PIM=$(SWAP)/pim
CWM=$(SWAP)/cwm.py

BOS=$(W)/2003/09dc-bos
HEL=$(W)/2005/01dc-hel
YOW=$(W)/2004/08dc-yow

#######
# evaluating itin

ITIN=itin-dca-aa

all: $(ITIN)-cal.ics $(ITIN)b.txt

####
# map

map: $(ITIN)-img.png

XPLANET=xplanet
XPLANETOPTS=-num_times 1 -gmtlabel -labelpos +15+15 -label_string "trip to Boston for Policy-aware Web Research meeting"

$(ITIN)-img.png: $(ITIN)-arcs $(ITIN)-markers xplanet_opts origin
	$(XPLANET) $(XPLANETOPTS) -config xplanet_opts \
		-origin earth -origin_file origin -output $@
CHATTY=20
$(ITIN)-markers: $(ITIN).rdf $(PIM)/itinMarks.n3
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) $(ITIN).rdf --n3 $(PIM)/itinMarks.n3 --think --strings >$@
$(ITIN)-arcs: $(ITIN).rdf $(PIM)/itinArcs.n3
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) $(ITIN).rdf --n3 $(PIM)/itinArcs.n3 --think --strings >$@


####
# ics version

$(ITIN)-cal.ics: $(ITIN).rdf $(SWAP)/pim/toIcal.py
	PYTHONPATH=$(SWAP):$(CAL) $(PYTHON)  \
		$(SWAP)/pim/toIcal.py $(ITIN).rdf >$@

####
# brief text version

$(ITIN)b.txt: $(ITIN).rdf $(HEL)/itinBrief.n3
	$(PYTHON) $(SWAP)/cwm.py $(HEL)/itinBrief.n3 $(ITIN).rdf \
		--think --strings >$@
#####
# look up days of week, lat/long, map to iCalendar

$(ITIN).rdf: $(ITIN)-raw.rdf $(BOS)/weekDays.n3 $(PIM)/itin2ical.n3 $(PIM)/cityLookup.n3 withZoneInfo.n3
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) $(ITIN)-raw.rdf $(BOS)/weekDays.n3 \
		$(PIM)/itin2ical.n3 $(PIM)/cityLookup.n3 withZoneInfo.n3 \
		--think --data --rdf >$@

####
# scrape from aa.com print-out

$(ITIN)-raw.rdf: res-t.html $(YOW)/grokItinTable.xsl
	$(XSLTPROC) --novalid --output $@ $(YOW)/grokItinTable.xsl res-t.html


res-t.html: res.htm
	$(TIDY) -q -n -i -ascii -asxml res.htm >$@

