c3d2-web/Makefile

109 lines
3.8 KiB
Makefile

PROCESSOR=xsltproc
PFLAGS=--novalid
# The root directory of every transformation
# used in the following makefile
TRANSFORMATION_ROOT=transformation
# TODO: Define a transformation procedure for each transformation
# within $(TRANSFORMATION_ROOT) and its subdirectories.
HTML_OUTPUT=output/html
PAGE_OUTPUT=output/page
NEWS_OUTPUT=output/news
#
# Predefined functions
#
# calendar2page (target, pathinclude) where
# "target" - the path of the xml file to be transformed
# "pathinclude" - additional paths (separated by whitespace) for inclusion of news items
calendar2page = $(PROCESSOR) $(PFLAGS) --path "$(PAGE_OUTPUT) $(2)" $(TRANSFORMATION_ROOT)/calendar2page/calendar2page.xsl $(1)
# news2page (target, pathinclude) where
# "target" - the path of the xml file to be transformed
# "pathinclude" - additional paths (separated by whitespace) for inclusion of news items
news2page = $(PROCESSOR) $(PFLAGS) --path "$(NEWS_OUTPUT) $(2)" $(TRANSFORMATION_ROOT)/news2page/news2page.xsl $(1)
# page2html (target, pathinclude) where
# "target" - the path of the xml file to be transformed
# "pathinclude" - additional paths (separated by whitespace) for inclusion of news items
page2html = $(PROCESSOR) $(PFLAGS) --path "$(PAGE_OUTPUT) $(TRANSFORMATION_ROOT)/page2html $(2)" html.xsl $(1)
#
# Locations of the files to be generated
#
PAGES_DIR=content/c3d2/pages
STATIC_PAGES:=$(patsubst $(PAGES_DIR)/%.xml, $(HTML_OUTPUT)/%.html, $(wildcard $(PAGES_DIR)/*.xml))
ITEMS_DIR=content/c3d2/items
NEWS_ITEMS:=$(patsubst $(ITEMS_DIR)/%.xml, $(HTML_OUTPUT)/news/%.html, $(wildcard $(ITEMS_DIR)/*.xml))
#
# The main recipe
#
all: prepare_output $(HTML_OUTPUT)/kalender.html $(HTML_OUTPUT)/news.html $(NEWS_ITEMS) $(STATIC_PAGES)
prepare_output:
mkdir -p $(HTML_OUTPUT) $(PAGE_OUTPUT) $(NEWS_OUTPUT)
cp -rf content/c3d2/static/* $(HTML_OUTPUT)
#
# Generic rule for the static pages
# listed in STATIC_PAGES
#
$(HTML_OUTPUT)/%.html: $(PAGES_DIR)/%.xml
$(call page2html, $<, content/c3d2 content/c3d2/templates content/c3d2/pages) > $@
#
# CALENDAR
#
$(HTML_OUTPUT)/kalender.html: $(PAGE_OUTPUT)/kalender.xml
$(call page2html, $(PAGE_OUTPUT)/kalender.xml, content/c3d2 content/c3d2/templates content/c3d2/pages) > $@
$(PAGE_OUTPUT)/kalender.xml: $(PAGE_OUTPUT)/news.xml
# First tranformation to unite calendar-only events and news items
# TODO: May be handled by different stylesheets.
$(call calendar2page, content/c3d2/calendar.xml, $(NEWS_OUTPUT) $(ITEMS_DIR)) > $(PAGE_OUTPUT)/calendar-summary.xml
# The actual calendar2page-transformation
$(call calendar2page, $(PAGE_OUTPUT)/calendar-summary.xml, $(NEWS_OUTPUT) $(ITEMS_DIR)) > $@
#
# NEWS
#
# Points to a script or executable, which takes
# the directory containing the newsitems in xml-format
# as parameter and passes a corresponding list in xml-format
# to STDOUT
LIST_GENERATOR=scripts/generate-news-list.sh
# Transform all items into pages
$(PAGE_OUTPUT)/items/%.xml: $(ITEMS_DIR)/%.xml
mkdir -p $(PAGE_OUTPUT)/items/
$(call news2page, $<) > $@
# Transform the pages representing news items into HTML
$(HTML_OUTPUT)/news/%.html: $(PAGE_OUTPUT)/items/%.xml
mkdir -p $(HTML_OUTPUT)/news/
$(call page2html, $<, content/c3d2 content/c3d2/templates content/c3d2/pages) > $@
# Generate a list of all news items
# stored within $(ITEMS_DIR).
$(NEWS_OUTPUT)/news-list.xml:
$(LIST_GENERATOR) $(ITEMS_DIR) > $(NEWS_OUTPUT)/news-list.xml
# Transform the news.xml-file into a page
$(PAGE_OUTPUT)/news.xml: $(NEWS_OUTPUT)/news-list.xml
$(call news2page, content/c3d2/news/overview.xml, content/c3d2/items) > $(PAGE_OUTPUT)/news.xml
# Transform the news page into HTML
$(HTML_OUTPUT)/news.html: $(PAGE_OUTPUT)/news.xml
$(call page2html, output/page/news.xml , $(PAGE_OUTPUT) content/c3d2 content/c3d2/templates content/c3d2/pages) > $(HTML_OUTPUT)/news.html
clean:
rm -rf $(NEWS_OUTPUT)/* $(PAGE_OUTPUT)/* $(HTML_OUTPUT)/*