#
# Makefile of dbis/public.html/Publics
#
.IGNORE:

DIRECTORIES := $(shell ls -d ??)
DIRS := $(patsubst %, %.year, $(DIRECTORIES))
XMLS := $(shell ls */*.xml)
FILES := $(patsubst %.xml, %.coll, $(XMLS))

stylesheets = /afs/informatik.uni-goettingen.de/service/web/dbis/Stylesheets/

all: open collectByFiles close distribute publist

#  $@: filename on the left of the rule (*.xml)
#  $<: filename on the right in the first line of the rule (*.html)

open: 
	echo '<?xml version="1.0" encoding="iso-8859-1"?>' > all_publications.xml
	echo '<!DOCTYPE publications SYSTEM "publication.dtd">'  >> all_publications.xml
	echo '<publications>' >> all_publications.xml
	echo '<title>DBIS: Publikationen</title>' >> all_publications.xml

close: 
	echo '</publications>' >> all_publications.xml


###  collect all <publication> entries in all_publications.xml
collectByDirs: $(DIRS)  
%.year: 
	cd %; $(MAKE) -f Makefile all

collectByFiles: $(FILES)  
%.coll: %.xml
	xsltproc $(stylesheets)/dbis-collect-publication.xsl $< >> all_publications.xml

###  take <publication> entries in all_publications.xml and create html pages
distribute:
	xsltproc $(stylesheets)/dbis-publication.xsl all_publications.xml 
	chmod -R 664 *.html
publist:
	xsltproc $(stylesheets)/dbis-publist.xsl all_publications.xml > index.html
	chmod 664 index.html