BIBL=$(wildcard ../bibl/*.xml)
TOOLS=../tools
BIBSORT=$(TOOLS)/bibsort.xsl
FIXSTYLE=$(TOOLS)/fix-style.xsl
XMLSPEC=$(TOOLS)/xmlspec.xsl
DTOOLS=$(TOOLS)/diffmk

targetName=Overview


all: $(targetName).html

# Add --param show.ednote 0 when producing an "official" version.

$(targetName).html: $(targetName).xml $(FIXSTYLE) $(XMLSPEC) $(BIBSORT) $(BIBL)
	rm -f $(targetName).html
	xsltproc --xinclude $(BIBSORT) $(targetName).xml | \
	xsltproc --nonet $(XMLSPEC) - | \
		xsltproc --nonet $(FIXSTYLE) - \
		 > $(targetName).html
	-tidy -utf8 -asxhtml -i -m $(targetName).html
	-chmod -w $(targetName).html

# for diff
previousVersion=1.12

# order of JARS matters
JARS="$(DTOOLS)/DiffMk.properties:$(DTOOLS)/resolver.jar:$(DTOOLS)/diffmk.jar:"
DIFFMK=com.sun.xtc.diffmk.DiffMk
previousVersionXML=$(targetName)$(previousVersion).xml
latestVersionXML=$(targetName).xml
rawdiffXML=$(targetName)-rawDiff.xml
diffXML=$(targetName)-diff.xml
diffHTML=$(targetName)-diff.html

diff: $(targetName).html  $(previousVersionXML) $(latestVersionXML) xmlspec.dtd
	@echo Generating diff
	java -cp $(JARS) $(DIFFMK) -doctype xmlspec \
		-diff both -words $(previousVersionXML) $(latestVersionXML) \
		$(rawdiffXML)
	java -cp ~/bin/saxon6-5-5/saxon.jar:~/bin/saxon6-5-5/saxon-xml-apis.jar com.icl.saxon.StyleSheet \
			$(rawdiffXML) $(TOOLS)/diff-postprocess.xsl > $(diffXML) 
	java -cp \
	~/bin/saxon6-5-5/saxon.jar:~/bin/saxon6-5-5/saxon-xml-apis.jar \
	com.icl.saxon.StyleSheet $(diffXML) $(TOOLS)/diffspec.xsl > $(diffHTML) 

xmlspec.dtd:
	ln -s ../tools/xmlspec.dtd .

$(previousVersionXML):
	cvs co -p -r $(previousVersion) `cat CVS/Repository`/$(latestVersionXML) > $(previousVersionXML)

realclean: clean
	rm -f $(previousVersionXML) $(targetName).html

clean:
	rm -f  $(rawdiffXML) $(diffXML) $(diffHTML) 

cvslog:
	cvs log $(targetName).xml
