c3d2-web/Makefile
astro 0e35242611 Here come the Datenspuren
git-svn-id: svn://svn.c3d2.de/c3d2-web/trunk@94 31f61c52-7bfb-0310-b897-fc00f8a278f0
2006-01-03 23:53:02 +00:00

132 lines
3.5 KiB
Makefile

### Programme ###
# XSLT-Prozessor:
PROCESSOR=xsltproc
PFLAGS=--path $(PWD)/dtd
# XML-Validator
VALIDATOR=xmllint
VFLAGS=--noout --path $(PWD)
# Downloadmanager (Alternativ: curl, fetch):
WGET=wget --timestamping
# rsync
RSYNC=rsync
RSYNC_FLAGS=--verbose --recursive --delete --delete-after --delete-excluded --checksum
# rsync
RSYNC=rsync
RSYNC_FLAGS=--verbose --recursive --delete --delete-after --delete-excluded --checksum
# Editor
EDITOR?=vim
# Browser
BROWSER?=links
# Verzeichnis, in das exportiert werden soll
DESTDIR?=www-export
### Ressourcen ###
# XSLT-Stylesheets:
STYLE=xsl/xhtml.xsl
DS_STYLE=xsl/datenspuren/xhtml.xsl
STYLE_RSS=xsl/rss.xsl
# Navigationsleiste:
NAVIGATION=content/navigation.xml
# XML-Skeletons
SKELETONS:=$(wildcard content/skel-*.xml)
SKEL:=empty
# Zu verwendendes Skeleton
SKELFILE=content/skel-$(SKEL).xml
# Dateinamen der Inhalte:
CONTENT=$(PAGES) $(DS_PAGES) www/news.html #www/news-rss.xml
PAGES:=$(patsubst content/%.xml, www/%.html, $(filter-out $(NAVIGATION) $(SKELETONS), $(wildcard content/*.xml)))
DS_PAGES:=$(patsubst content/datenspuren/%.xml, www/datenspuren/%.html, $(wildcard content/datenspuren/*.xml))
NEWSITEMS:=$(wildcard content/news/*.xml)
DTD:=$(wildcard dtd/*.dtd)
XHTML_DTD_FILES:=xhtml1-strict.dtd xhtml-lat1.ent xhtml-symbol.ent xhtml-special.ent
XHTML_DTD_BASEURL:=http://www.w3.org/TR/xhtml1/DTD
CLEAN=$(CONTENT) www/news.html www/news-rss.xml
### Defaults ###
.PHONY: export contents clean mrproper all install check
.PRECIOUS: content/%.xml content/datenspuren/%.xml www/%.html www/datenspuren/%.html
.SILENT: check
all: contents
install: export
contents: $(CONTENT) www/dtd
export: contents
$(RSYNC) $(RSYNC_FLAGS) --exclude=".svn/" www/ $(DESTDIR)/
www/dtd: $(DTD)
rm -rf $@
$(RSYNC) $(RSYNC_FLAGS) --include="*.dtd" --exclude="*" dtd/ www/dtd/
$(XHTML_DTD_FILES):
$(WGET) $(XHTML_DTD_BASEURL)/$@
check: $(PAGES) $(XHTML_DTD_FILES)
ln -sfn .. www/DTD
for page in $(PAGES) ; do \
echo "Checking $${page}..." ; \
$(VALIDATOR) $(VFLAGS) --valid $${page} ; \
done
rm -f www/DTD
### Regeln für den XSLT-Prozess ###
www/news.html: $(STYLE)
www/news-rss.xml: $(STYLE_RSS)
www/news.html www/news-rss.xml: $(NEWSITEMS) $(NAVIGATION)
{ echo '<?xml version="1.0" encoding="UTF-8"?>' ; \
echo "<page>"; \
echo " <news>"; \
for item in $(NEWSITEMS) ; do \
echo " <newsfile>$${item}</newsfile>"; \
done; \
echo " </news>"; \
echo "</page>"; } | \
$(PROCESSOR) $(PFLAGS) -o $@ $(filter-out $(NEWSITEMS) $(NAVIGATION),$^) -
### Datenspuren ###
www/datenspuren/%.html: content/datenspuren/%.xml $(DS_STYLE)
$(VALIDATOR) $(VFLAGS) --dtdvalid dtd/page.dtd $<
$(PROCESSOR) $(PFLAGS) -o $@ $(DS_STYLE) $<
www/%.html: content/%.xml $(STYLE) $(NAVIGATION) chaosupdates.rdf
$(VALIDATOR) $(VFLAGS) --dtdvalid dtd/page.dtd $<
$(PROCESSOR) $(PFLAGS) -o $@ $(STYLE) $<
### Hilfsregeln zum Editieren ###
edit/%:
@if [ ! -e content/$(@F).xml ] ; then \
cp $(SKELFILE) content/$(@F).xml ;\
fi
@$(EDITOR) content/$(@F).xml
@if diff -q $(SKELFILE) content/$(@F).xml >/dev/null ; then \
echo "Warning: content/$(@F).xml does not differ from the skeleton $(SKELFILE)" ;\
rm -i content/$(@F).xml ;\
fi
view/%: www/%.html
@$(BROWSER) $<
content/%.xml:
$(MAKE) edit/$(patsubst content/%.xml,%,$@)
### Die neuesten Chaosupdates holen ###
chaosupdates.rdf:
$(WGET) http://www.ccc.de/updates/chaosupdates.rdf || \
cp chaosupdates-2006-01-02.rdf $@
### Mr. Propper ###
clean:
rm -f $(CLEAN)
rm -rf www/dtd
mrproper: clean
rm -f chaosupdates.rdf
rm -f $(XHTML_DTD_FILES)
rm -rf www-export