# $Id: Makefile,v 1.15 2003/07/30 22:25:35 connolly Exp $

MKDIR=mkdir #posix

RSYNC=rsync #@@cite source

#@@TODO: don't forget to add a test for nextId bug fix and
# check it in

PERL=perl
PYTHON=python

XPLANET=xplanet # http://xplanet.sourceforge.net/

W=../../..
SWAP=$(W)/2000/10/swap
CWM=$(SWAP)/cwm.py
VOCABEVOLUTION=$(W)/2001/05ve
ROADMAP=$(W)/2001/04/roadmap

SCRAPE=$(W)/2002/10/scrape

XSLTPROC=xsltproc
# tested configuration, on a debian linux box:
# $ type xsltproc
# xsltproc is hashed (/usr/bin/xsltproc)
# $ dpkg -s xsltproc
# Package: xsltproc
# Maintainer: Nicolás Lichtmaier <nick@debian.org>
# Source: libxslt
# Version: 1.0.6-1
# Description: XSLT command line processor
#  This is a command line tool that allows to transform XML files into other
#  XML files (or HTML, text, ...) using the standard XSLT stylesheet
# transformation mechanism.
# http://packages.debian.org/unstable/text/xsltproc.html
# libxslt_1.0.6.orig.tar.gz 19-Nov-2001 00:18   1.9M  
# libxslt-1.0.6.tar.gz 1936 KB   10/30/01  14:52:00
# http://xmlsoft.org/XSLT/
# Daniel Veillard


#an older XSLT configuration that depended on java:
#PD=$(W)/2001/02pd
#include $(PD)/XSLT.mak
#JAVA=java

.SUFFIXES: .n3 .nt .rdf

.nt.n3:
	$(PYTHON) $(SWAP)/cwm.py $< >$@
.nt.rdf:
	$(PYTHON) $(SWAP)/cwm.py $< --rdf >$@
.n3.rdf:
	$(PYTHON) $(SWAP)/cwm.py $< --rdf >$@



# wg family names

all: webont-world.png webont-roll.rdf
debug: webont-roll-all.n3

#all: webont-nom.rdf webont-membership.n3 webont-nom.n3 missing-ipr.n3

missing-stuff.n3: webont-mem-pub.rdf missing-mem.n3 webont-charter.n3 webont-roll.rdf
	echo "be prepared to enter credentials to access DB stuff"
	$(PYTHON) $(SWAP)/cwm.py --chatty=20 webont-charter.n3 missing-mem.n3 --think >$@

webont-mem-pub.rdf: Overview.html mem-scrape.xsl
	$(XSLTPROC) --novalid  --param Charter '"http://www.w3.org/2001/sw/WebOnt/charter"' mem-scrape.xsl Overview.html >$@

#these look good; figured them out with tkxplanet
XPLANETOPTS=-projection orthographic -body Earth -grid -latitude 44 -longitude -49
webont-world.png: webont-markers
	$(XPLANET) $(XPLANETOPTS) -markerfile webont-markers -output $@


webont-markers: webont-map.nt $(SWAP)/n-triples2xplanet.pl
	$(PERL) $(SWAP)/n-triples2xplanet.pl webont-map.nt >$@

webont-map.nt: webont-airports.rdf mapStyle.n3 xplanet-filter.n3
	$(PYTHON) $(SWAP)/cwm.py --rdf webont-airports.rdf --n3 mapStyle.n3 --think --filter=xplanet-filter.n3 --ntriples >$@

webont-map.n3: webont-airports.rdf mapStyle.n3
	$(PYTHON) $(SWAP)/cwm.py --rdf webont-airports.rdf --n3 mapStyle.n3 --think --filter=xplanet.n3 --n3 >$@

webont-airports.rdf: webont-roll.rdf intro-geo2.n3 $(SWAP)/pim/contact.n3 wg-mem.n3 $(SWAP)/test/sameThing.n3 $(SWAP)/test/forgetDups.n3 intro-geo.rdf stefan-apt.rdf
	$(PYTHON) $(SWAP)/cwm.py --chatty=10 --rdf webont-roll.rdf intro-geo.rdf stefan-apt.rdf --n3 intro-geo2.n3 $(SWAP)/pim/contact.n3  $(SWAP)/test/sameThing.n3 --think --apply=$(SWAP)/test/forgetDups.n3 --filter=wg-mem.n3 --rdf >$@


ROLLKBFILES=webont-nom.nt webont-charter.n3 wg-mem.n3 $(VOCABEVOLUTION)/rdfs.n3 $(ROADMAP)/org.n3
# wg membership by org
webont-roll.rdf: $(ROLLKBFILES) webont-nom.rdf
	$(PYTHON) $(SWAP)/cwm.py --chatty=10 $(ROLLKBFILES) --think --filter=wg-mem.n3 --rdf >$@

webont-roll-all.n3: $(ROLLKBFILES)
	$(PYTHON) $(SWAP)/cwm.py --chatty=10 $(ROLLKBFILES) --think --n3 >$@



missing-ipr.n3: webont-noipr.n3 webont-nom.nt
	$(PYTHON) $(SWAP)/cwm.py webont-noipr.n3 --think >$@

#@@todo: patch bugs in nom mail: obrst, firstname/lastname mixups
webont-nom.nt: nom-scrape.pl nom-mail
	$(PERL) nom-scrape.pl nom-mail/* >$@

nom-mail:
	$(MKDIR) nom-mail
	$(RSYNC) -av -e ssh connolly@lists.w3.org:/home/lists/w3t-semweb-review/archive/latest/ nom-mail # args thanks to ted in &sysreq

CHATTY=15

lc-status-report.html: lc-status-report-f.n3
	$(PYTHON) $(SWAP)/cwm.py lc-status-report-f.n3 --strings | $(PERL) -pe 's/&/&amp;/' >$@

lc-status-report-f.n3: lc-status-report-rules.n3 lc-threads.rdf lc-tel12Jun.n3
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) lc-status-report-rules.n3 --rdf lc-threads.rdf --n3 --think --purge-rules >$@

lc-status.n3: lc-threads.rdf lc-audit.n3
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) lc-audit.n3 --think --purge-rules >$@

lc-threads.rdf: lc-comment-rules.n3 webont-lc-comments.rdf
	$(PYTHON) $(SWAP)/cwm.py --chatty=$(CHATTY) lc-comment-rules.n3 --rdf webont-lc-comments.rdf --think --purge-rules --ugly >$@

webont-lc-comments.rdf: webont-comments.timestamp $(W)/2000/04/maillog2rdf/aboutMsg.py
	PYTHONPATH=$(SWAP) $(PYTHON) $(W)/2000/04/maillog2rdf/aboutMsg.py --since 2003-04-01 --mh webont-comments >$@


webont-comments.timestamp:
	$(MKDIR) -p webont-comments
	$(RSYNC) -av -e ssh connolly@lists.w3.org:/home/lists/public-webont-comments/archive/latest/ webont-comments
	@touch webont-comments.timestamp

webont-nom.rdf: webont-nom.nt

webont-nom.n3: webont-nom.nt

webont-byOrg.n3: byOrgReport.n3 webont-mem-pub.rdf webont-nom.n3
	$(PYTHON) $(SWAP)/cwm.py byOrgReport.n3 --think --purge-rules --with webont-mem-pub.rdf webont-nom.n3 >$@

THISWEEK=20020613
MR=$(W)/2000/11/mr76

agenda: wowg$(THISWEEK)Agn.txt wowg$(THISWEEK)Agn.rdf
#@@ reduce this week stuff to RDF/xml; factor out rules.
wowg$(THISWEEK)Agn.txt: wowg$(THISWEEK).n3 $(MR)/w3cStyle.n3
	$(PYTHON) $(CWM) wowg$(THISWEEK).n3 --n3 $(MR)/w3cStyle.n3 --think --strings >$@

wowg$(THISWEEK)Agn.rdf: wowg$(THISWEEK).n3 $(MR)/w3cStyle.n3 $(MR)/forgetRules.n3
	$(PYTHON) $(CWM) wowg$(THISWEEK).n3 --n3 $(MR)/w3cStyle.n3 --think $(MR)/forgetRules.n3 --purge --rdf >$@



scrapedOverview.rdf: Overview.html $(SCRAPE)/WGscrape.xsl
	$(XSLTPROC) --param baseURI \"http://www.w3.org/2001/sw/WebOnt/\" $(SCRAPE)/WGscrape.xsl Overview.html >$@


clean:
	$(RM) webont-nom2.n3 webont-nom.n3 webont-nom.nt missing-ipr.n3 webont-map.rdf webont-roll.rdf webont-airports.rdf webont-map.n3 webont-map.nt
