# ----------------------------------------------------------------------------- # Makefile for FSFE website build, phase 1 # ----------------------------------------------------------------------------- # 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. # ----------------------------------------------------------------------------- .PHONY: all .FORCE .FORCE: # ----------------------------------------------------------------------------- # Dive into subdirectories # ----------------------------------------------------------------------------- SUBDIRS := $(shell find */* -name "Makefile" | xargs dirname) all: $(SUBDIRS) $(SUBDIRS): .FORCE @echo "* Preparing subdirectory $*" @$(MAKE) -j -k -C $@ # ----------------------------------------------------------------------------- # Handle local menus # ----------------------------------------------------------------------------- MENUSOURCES := $(shell find -name '*.xhtml' | xargs grep -l '' ) all: localmenuinfo.en.xml localmenuinfo.en.xml: ./tools/buildmenu.xsl $(MENUSOURCES) { printf ''; \ grep -E '' $^ \ | sed -r 's;(.*/)?(.+)\.([a-z][a-z])\.xhtml:(.+);\ /\1\2.html\4;'; \ printf ''; \ } | xsltproc -o $@ $< - # ----------------------------------------------------------------------------- # Timestamp files for regular jobs and XML inclusion in various places # ----------------------------------------------------------------------------- YEAR := MONTH := DAY := all: d_year.en.xml d_month.en.xml d_day.en.xml 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)' >$@ # ----------------------------------------------------------------------------- # Create XML symlinks # ----------------------------------------------------------------------------- # After this step, the following symlinks will exist: # * tools/.texts-.xml for each language # * ./fundraising..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 @if [ -f tools/texts-$*.xml ]; then \ 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 @if [ -f fundraising.$*.xml ]; then \ 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. XHTML_DIRS := $(patsubst %/,%,$(sort $(dir $(shell find -name '*.??.xhtml')))) .PHONY: default_xsl all: default_xsl default_xsl: @for directory in $(XHTML_DIRS); do \ 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 # ----------------------------------------------------------------------------- # Generate XML filelists # ----------------------------------------------------------------------------- # After this step, the following files will be up to date: # * tags/tagged-.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. # * /..xmllist for each /.sources as well as for each # tags/tagged-.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. .PHONY: xmllists all: xmllists xmllists: $(SUBDIRS) @build/make_xmllists.sh