all:	format regression

XML= rfc2616.xml rfc3470.xml rfc3986.xml rfc5234.xml rfc5322.xml \
	sample.ipr.id.noDerivativesTrust200902.200909.xml \
	sample.ipr.id.noModificationTrust200902.200909.xml \
	sample.ipr.id.pre5378Trust200902.200909.xml \
	sample.ipr.id.pre5378Trust200902.200912.xml \
	sample.ipr.id.pre5378Trust200902.201011.xml \
	sample.ipr.id.trust200902.200909.xml \
	sample.ipr.id.trust200902.200911.xml \
	sample.ipr.id.trust200902.200912.xml \
	sample.ipr.id.trust200902.201006.iab.xml \
	sample.ipr.id.trust200902.201006.ietf.xml \
	sample.ipr.id.trust200902.201006.ind.xml \
	sample.ipr.id.trust200902.201006.irtf.xml \
	sample.ipr.id.trust200902.201006.xml \
	sample.ipr.rfc.200201.xml \
	sample.ipr.rfc.200609.xml \
	sample.ipr.rfc.200808.xml \
	sample.ipr.rfc.200812.xml \
	sample.ipr.rfc.200906.xml \
	sample.ipr.rfc.200907.xml \
	sample.ipr.rfc.200909.xml \
	sample.ipr.rfc.200912.xml \
	sample.ipr.rfc.201001.iab.exp.xml \
	sample.ipr.rfc.201001.iab.hist.xml \
	sample.ipr.rfc.201001.iab.inf.xml \
	sample.ipr.rfc.201001.ietf.bcp.c.xml \
	sample.ipr.rfc.201001.ietf.exp.c.xml \
	sample.ipr.rfc.201001.ietf.exp.nc.xml \
	sample.ipr.rfc.201001.ietf.hist.c.xml \
	sample.ipr.rfc.201001.ietf.hist.nc.xml \
	sample.ipr.rfc.201001.ietf.inf.c.xml \
	sample.ipr.rfc.201001.ietf.inf.nc.xml \
	sample.ipr.rfc.201001.ietf.std.c.xml \
	sample.ipr.rfc.201001.ind.exp.xml \
	sample.ipr.rfc.201001.ind.hist.xml \
	sample.ipr.rfc.201001.ind.inf.xml \
	sample.ipr.rfc.201001.irtf.exp.c.xml \
	sample.ipr.rfc.201001.irtf.exp.nc.xml \
	sample.ipr.rfc.201001.irtf.exp.norg.xml \
	sample.ipr.rfc.201001.irtf.hist.c.xml \
	sample.ipr.rfc.201001.irtf.hist.nc.xml \
	sample.ipr.rfc.201001.irtf.hist.norg.xml \
	sample.ipr.rfc.201001.irtf.inf.c.xml \
	sample.ipr.rfc.201001.irtf.inf.nc.xml \
	sample.ipr.rfc.201001.irtf.inf.norg.xml \
	sample.ipr.rfc.pre5378Trust200902.200912.xml \
	sample.ref.annotation.xml \
	sample.nested.xml \
	sample.basic.xml

# test files for which NROFF generation currently fails
XMLNONROFF= sample.ipr.id.noModification3978.200606.xml

TXT= $(XML:.xml=.txt) $(XMLNONROFF:.xml=.txt)
HTML= $(XML:.xml=.xml2rfc.html) $(XMLNONROFF:.xml=.xml2rfc.html)
NR= $(XML:.xml=.nr)

format:	$(TXT) $(HTML) $(NR)
format-txt: $(TXT)
format-html: $(HTML)
format-nr: $(NR)

bps: $(BP:.xml=.txt)

%.txt:	%.xml ../xml2rfc.tcl
	tclsh ../xml2rfc.tcl xml2rfc $< $@

# when generating nroff, drop the version & date comment line
%.nr:	%.xml ../xml2rfc.tcl
	tclsh ../xml2rfc.tcl xml2rfc $< tmp.$@
	@tr -d "\015" < tmp.$@ | fgrep -v "automatically generated by xml2rfc" > $@
	@rm -f tmp.$@

%.xml2rfc.html:	%.xml ../xml2rfc.tcl
	tclsh ../xml2rfc.tcl xml2rfc $< tmp.$@
	@tr -d "\015" < tmp.$@ | fgrep -v '<meta name="generator" content="xml2rfc' > $@
	@rm -f tmp.$@

regression:	format
	svn diff > tmp.$$$$ ; \
	[ -s tmp.$$$$ ] && ( echo ; echo ; echo "There are regressions in the generated sample files, please check:" ; echo ; cat tmp.$$$$ ) ; \
	rm -f tmp.$$$$