# $Id: Makefile,v 1.2 2005/03/14 20:25:39 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
BSL=$(W)/2004/10dc-bsl
HEL=$(W)/2005/01dc-hel
YOW=$(W)/2004/08dc-yow

####
# expense reporting

BUD=$(W)/2003/05dc-bud
SAN=$(W)/2004/07dc-san

bos-expenses.qif: $(BUD)/qifReport.n3 bos-expenses.q3
	$(PYTHON) $(CWM) bos-expenses.q3 $(BUD)/qifReport.n3 \
		--think --strings >$@
	$(PERL) -ne 'if(/^T(\S+)/){$$tot += $$1; print $$tot, "\n";}' bos-expenses.qif

bos-expenses.q3: $(SAN)/dngr2qif.n3 bos-events.rdf
	$(PYTHON) $(CWM) bos-events.rdf $(SAN)/dngr2qif.n3 \
		--think >$@

PDADATA=/home/connolly/majo-data
bos-events.rdf: $(PDADATA)/event.rdf $(HEL)/eventFilter.xsl
	$(XSLTPROC) --output $@ --novalid \
		--stringparam TripStart 20050226 \
		$(HEL)/eventFilter.xsl $(PDADATA)/event.rdf



#######
# evaluating itin

ITIN=bos-tp-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).nt $(BOS)/weekDays.n3 $(PIM)/itin2ical.n3 $(PIM)/cityLookup.n3 $(BSL)/withZoneInfo.n3
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) $(ITIN).nt $(BOS)/weekDays.n3 \
		$(PIM)/itin2ical.n3 $(PIM)/cityLookup.n3 $(BSL)/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 >$@

####
# scrape from travelreq
$(ITIN).nt: $(ITIN).msg
	$(PERL) $(SWAP)/pim/grokTravItin.pl $(ITIN).msg >$@

clean:
	$(RM) $(ITIN).nt $(ITIN).rdf $(ITIN)b.txt


# $Log: Makefile,v $
# Revision 1.2  2005/03/14 20:25:39  connolly
# 1st estimate of expenses: 1202.33
#
# Revision 1.1  2005/01/31 22:12:14  connolly
# itinerary proposed by Josh Mon, 31 Jan 2005 13:20:44 -0500
#
# Revision 1.3  2005/01/27 05:45:14  connolly
# found other itin
#
# Revision 1.2  2005/01/27 05:15:15  connolly
# generate image
#
# Revision 1.1  2005/01/27 05:05:00  connolly
# works for making .txt, .ics
#
# Revision 1.2  2004/12/23 16:17:23  connolly
# generated map
#
# Revision 1.1  2004/12/23 16:00:20  connolly
# evaluating itin
#
