CONFS = yazserver.xml explain.xml indexfilter.xsl cql2pqf.txt filter_alvis_conf.xml zebra.cfg simplesearch.phtml
DIRS = register shadow lock tmp
FILES = README genYazTest.xsl genZebraExplain.xsl genZebraIndex.xsl \
 identity.xsl zebra.cfg.org explain2cqlpqftxt.xsl genZebraFilterConf.xsl \
 genZebraYazServer.xsl Makefile genUI.xsl
EXAMPLEFILES = ZebraConf.xml.ex testRecord.xml.ex testDoc.xml.ex \
 record2brief.xsl  record2dc.xsl  record2detailed.xsl

all : $(CONFS)

yazserver.xml : genZebraYazServer.xsl ZebraConf.xml
	xsltproc genZebraYazServer.xsl ZebraConf.xml > yazserver.xml

filter_alvis_conf.xml : ZebraConf.xml genZebraFilterConf.xsl
	xsltproc genZebraFilterConf.xsl ZebraConf.xml > filter_alvis_conf.xml

explain.xml : ZebraConf.xml genZebraExplain.xsl
	xsltproc genZebraExplain.xsl ZebraConf.xml > explain.xml

indexfilter.xsl : ZebraConf.xml genZebraIndex.xsl
	xsltproc genZebraIndex.xsl ZebraConf.xml > indexfilter.xsl

cql2pqf.txt : explain.xml explain2cqlpqftxt.xsl
	xsltproc explain2cqlpqftxt.xsl explain.xml > cql2pqf.txt

zebra.cfg : zebra.cfg.org
	cp zebra.cfg.org zebra.cfg

simplesearch.phtml : ZebraConf.xml genUI.xsl
	xsltproc genUI.xsl ZebraConf.xml > simplesearch.phtml

test : testIndex yazTest.txt
	zebrasrv -f yazserver.xml &
	sleep 1
	echo '. yazTest.txt' | yaz-client
	kill `cat lock/zebrasrv.pid`

dist : $(FILES) $(EXAMPLEFILES)
	tar zcf ZebraConf.tgz $(FILES) $(EXAMPLEFILES) docpath

testXSL : indexfilter.xsl testRecord.xml
	xsltproc indexfilter.xsl testRecord.xml

testIndex : setup $(CONFS) testDoc.xml
	zebraidx -c zebra.cfg init
	zebraidx -c zebra.cfg update testDoc.xml
	zebraidx -c zebra.cfg commit

yazTest.txt : ZebraConf.xml genYazTest.xsl
	xsltproc genYazTest.xsl ZebraConf.xml > yazTest.txt

setup : clean
	mkdir $(DIRS)

clean : 
	\rm -rf $(CONFS) $(DIRS) srv.log yazTest.txt ZebraConf.tgz
