c3d2-web/Makefile

122 lines
3.0 KiB
Makefile
Raw Normal View History

### 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
# Editor
EDITOR?=vim
# Browser
BROWSER?=links
# Verzeichnis, in das exportiert werden soll
DESTDIR?=www-export
### Ressourcen ###
# XSLT-Stylesheets:
STYLE=xsl/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) www/news.html www/news-rss.xml
PAGES:=$(patsubst content/%.xml, www/%.html, $(filter-out $(NAVIGATION) $(SKELETONS), $(wildcard content/*.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 www/%.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),$^) -
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