2019-03-07 22:34:10 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2019-03-11 11:26:55 +00:00
|
|
|
# Makefile for FSFE website build, phase 1
|
2019-03-07 22:34:10 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2019-03-11 11:26:55 +00:00
|
|
|
# This Makefile is executed in the root of the source directory tree, and
|
|
|
|
# creates some .xml and xhtml files as well as some symlinks, all of which
|
|
|
|
# serve as input files in phase 2. The whole phase 1 runs within the source
|
|
|
|
# directory tree and does not touch the target directory tree at all.
|
2019-03-07 22:34:10 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2017-03-06 17:59:11 +00:00
|
|
|
.PHONY: all .FORCE
|
|
|
|
.FORCE:
|
2008-12-07 01:49:05 +00:00
|
|
|
|
2008-12-08 17:54:36 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Dive into subdirectories
|
|
|
|
# -----------------------------------------------------------------------------
|
2008-03-20 23:01:31 +00:00
|
|
|
|
2017-02-15 17:30:31 +00:00
|
|
|
SUBDIRS := $(shell find */* -name "Makefile" | xargs dirname)
|
2008-03-20 23:01:31 +00:00
|
|
|
|
2019-03-10 15:18:02 +00:00
|
|
|
all: $(SUBDIRS)
|
2017-03-06 17:59:11 +00:00
|
|
|
$(SUBDIRS): .FORCE
|
2019-03-12 15:42:34 +00:00
|
|
|
echo "* Preparing subdirectory $@"
|
|
|
|
$(MAKE) --silent --directory=$@
|
2008-12-08 17:54:36 +00:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Handle local menus
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
2019-03-14 10:43:54 +00:00
|
|
|
# FIXME: This runs when the makefile is parsed, before maybe new *.xhtml files
|
|
|
|
# are created in the news/<year>/ and events/<year>/ directories. It would be
|
|
|
|
# better to move this into a separate script tools/update-localmenus.sh. It
|
|
|
|
# would also be better if there was a separate .localmenu.en.xml file for each
|
|
|
|
# directory.
|
2019-03-12 10:31:39 +00:00
|
|
|
MENUSOURCES := $(shell find -name '*.xhtml' -not -name "*-template.*" | xargs grep -l '<localmenu.*</localmenu>' | sort)
|
2008-12-08 17:54:36 +00:00
|
|
|
|
2019-03-10 15:18:02 +00:00
|
|
|
all: localmenuinfo.en.xml
|
2017-03-06 17:59:11 +00:00
|
|
|
localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES)
|
|
|
|
{ printf '<localmenuset>'; \
|
|
|
|
grep -E '<localmenu.*</localmenu>' $^ \
|
|
|
|
| sed -r 's;(.*/)?(.+)\.([a-z][a-z])\.xhtml:(.+);\
|
|
|
|
<menuitem language="\3"><dir>/\1</dir><link>\2.html</link>\4</menuitem>;'; \
|
|
|
|
printf '</localmenuset>'; \
|
|
|
|
} | xsltproc -o $@ $< -
|
2008-12-08 17:54:36 +00:00
|
|
|
|
2017-03-06 17:59:11 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Timestamp files for regular jobs and XML inclusion in various places
|
|
|
|
# -----------------------------------------------------------------------------
|
2016-03-24 16:13:18 +00:00
|
|
|
|
2017-03-06 17:59:11 +00:00
|
|
|
YEAR := <?xml version="1.0" encoding="utf-8"?><dateset><date year="$(shell date +%Y)" /></dateset>
|
2016-03-24 16:13:18 +00:00
|
|
|
MONTH := <?xml version="1.0" encoding="utf-8"?><dateset><date month="$(shell date +%Y-%m)" /></dateset>
|
2017-03-06 17:59:11 +00:00
|
|
|
DAY := <?xml version="1.0" encoding="utf-8"?><dateset><date day="$(shell date +%Y-%m-%d)" /></dateset>
|
2016-03-24 16:13:18 +00:00
|
|
|
|
2019-03-10 15:18:02 +00:00
|
|
|
all: d_year.en.xml d_month.en.xml d_day.en.xml
|
2017-03-06 17:59:11 +00:00
|
|
|
d_day.en.xml: $(if $(findstring $(DAY),$(shell cat d_day.en.xml)),,.FORCE)
|
|
|
|
printf %s\\n '$(DAY)' >$@
|
|
|
|
d_month.en.xml: $(if $(findstring $(MONTH),$(shell cat d_month.en.xml)),,.FORCE)
|
|
|
|
printf %s\\n '$(MONTH)' >$@
|
|
|
|
d_year.en.xml: $(if $(findstring $(YEAR),$(shell cat d_year.en.xml)),,.FORCE)
|
|
|
|
printf %s\\n '$(YEAR)' >$@
|
2016-03-24 16:13:18 +00:00
|
|
|
|
2019-03-11 11:26:55 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Create XML symlinks
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# After this step, the following symlinks will exist:
|
|
|
|
# * tools/.texts-<lang>.xml for each language
|
|
|
|
# * ./fundraising.<lang>.xml for each language
|
|
|
|
# Each of these symlinks will point to the corresponding file without a dot at
|
|
|
|
# the beginning of the filename, if present, and to the English version
|
|
|
|
# otherwise. This symlinks make sure that phase 2 can easily use the right file
|
|
|
|
# for each language, also as a prerequisite in the Makefile.
|
|
|
|
|
|
|
|
LANGUAGES := $(shell . build/languages.sh && get_languages)
|
|
|
|
|
|
|
|
TEXTS_LINKS := $(foreach lang,$(LANGUAGES),tools/.texts-$(lang).xml)
|
|
|
|
|
|
|
|
all: $(TEXTS_LINKS)
|
|
|
|
tools/.texts-%.xml: .FORCE
|
2019-03-12 15:42:34 +00:00
|
|
|
if [ -f tools/texts-$*.xml ]; then \
|
2019-03-11 11:26:55 +00:00
|
|
|
ln -sf texts-$*.xml $@; \
|
|
|
|
else \
|
|
|
|
ln -sf texts-en.xml $@; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
FUNDRAISING_LINKS := $(foreach lang,$(LANGUAGES),.fundraising.$(lang).xml)
|
|
|
|
|
|
|
|
all: $(FUNDRAISING_LINKS)
|
|
|
|
.fundraising.%.xml: .FORCE
|
2019-03-12 15:42:34 +00:00
|
|
|
if [ -f fundraising.$*.xml ]; then \
|
2019-03-11 11:26:55 +00:00
|
|
|
ln -sf fundraising.$*.xml $@; \
|
|
|
|
else \
|
|
|
|
ln -sf fundraising.en.xml $@; \
|
|
|
|
fi
|
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Create XSL symlinks
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# After this step, each directory with source files for HTML pages contains a
|
|
|
|
# symlink named .default.xsl and pointing to the default.xsl "responsible" for
|
|
|
|
# this directory. These symlinks make it easier for the phase 2 Makefile to
|
|
|
|
# determine which XSL script should be used to build a HTML page from a source
|
|
|
|
# file.
|
|
|
|
|
|
|
|
# All directories containing source files for HTML pages.
|
2019-03-14 10:43:54 +00:00
|
|
|
# FIXME: This runs when the makefile is parsed, before maybe new *.xhtml files
|
|
|
|
# are created in the news/<year>/ and events/<year>/ directories.
|
2019-03-11 11:26:55 +00:00
|
|
|
XHTML_DIRS := $(patsubst %/,%,$(sort $(dir $(shell find -name '*.??.xhtml'))))
|
|
|
|
|
|
|
|
.PHONY: default_xsl
|
|
|
|
all: default_xsl
|
|
|
|
default_xsl:
|
2019-03-12 15:42:34 +00:00
|
|
|
for directory in $(XHTML_DIRS); do \
|
2019-03-11 11:26:55 +00:00
|
|
|
dir="$${directory}"; \
|
|
|
|
prefix=""; \
|
|
|
|
until [ -f "$${dir}/default.xsl" -o "$${dir}" = "." ]; do \
|
|
|
|
dir="$${dir%/*}"; \
|
|
|
|
prefix="$${prefix}../"; \
|
|
|
|
done; \
|
|
|
|
ln -sf "$${prefix}default.xsl" "$${directory}/.default.xsl"; \
|
|
|
|
done
|
|
|
|
|
2017-03-06 17:59:11 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2019-03-12 15:34:02 +00:00
|
|
|
# Update XML filelists
|
2017-03-06 17:59:11 +00:00
|
|
|
# -----------------------------------------------------------------------------
|
2017-02-16 16:18:57 +00:00
|
|
|
|
2019-03-11 11:26:55 +00:00
|
|
|
# After this step, the following files will be up to date:
|
|
|
|
# * tags/tagged-<tags>.en.xhtml for each tag used. Apart from being
|
|
|
|
# automatically created, these are regular source files for HTML pages, and
|
|
|
|
# in phase 2 are built into pages listing all news items and events for a
|
|
|
|
# tag.
|
2019-03-14 01:25:37 +00:00
|
|
|
# * tags/.tags.??.xml with a list of the tags useed.
|
2019-03-11 11:26:55 +00:00
|
|
|
# * <dir>/.<base>.xmllist for each <dir>/<base>.sources as well as for each
|
|
|
|
# tags/tagged-<tags>.en.xhtml. These files are used in phase 2 to include the
|
|
|
|
# correct XML files when generating the HTML pages. It is taken care that
|
|
|
|
# these files are only updated whenever their content actually changes, so
|
|
|
|
# they can serve as a prerequisite in the phase 2 Makefile.
|
|
|
|
# This step is handled in an external script, because the list of files to
|
|
|
|
# generate is not known when the Makefile starts - some new tags might be
|
|
|
|
# introduced when generating the .xml files in the news/* subdirectories.
|
2017-03-06 17:59:11 +00:00
|
|
|
|
2019-03-11 01:35:51 +00:00
|
|
|
.PHONY: xmllists
|
|
|
|
all: xmllists
|
|
|
|
xmllists: $(SUBDIRS)
|
2019-03-12 15:42:34 +00:00
|
|
|
tools/update_xmllists.sh
|
2019-03-12 15:34:02 +00:00
|
|
|
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
# Update XSL stylesheets
|
|
|
|
# -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# This step updates (actually: just touches) all XSL files which depend on
|
|
|
|
# another XSL file that has changed since the last build run. The phase 2
|
|
|
|
# Makefile then only has to consider the directly used stylesheet as a
|
|
|
|
# prerequisite for building each file and doesn't have to worry about other
|
|
|
|
# stylesheets imported into that one.
|
|
|
|
|
|
|
|
.PHONY: stylesheets
|
|
|
|
all: stylesheets
|
|
|
|
stylesheets: $(SUBDIRS)
|
2019-03-12 15:42:34 +00:00
|
|
|
tools/update_stylesheets.sh
|