How the Guidelines (HTML version) are built

Intro
This is a page where I'm going to gather together notes on what I figure out about the Guidelines build process. I'm trying to change the generation of the index.html and index-toc.html pages, replacing the former with a new version of the latter, and the latter with a redirect for people with obsolete bookmarks. To do this I need to understand the build process, which is not uncomplicated, and it may help others to have my notes to start from if they're also working on the same code.

Makefile
The process is triggered by the P5/Makefile, specifically this target chain (AFAICS):


 * teiwebsiteguidelines, which calls
 * html-web, passing all languages as parameters, which calls check.stamp (checking for required tools), then
 * p5.xml, which generates all the schemas and the p5.xml file used as input, then
 * html-web.stamp, which runs a perl process which converts P5/guidelines.xsl.model to guidelines.xsl (don't know what the perl thing does yet), then uses it to generate the HTML version of the Guidelines in a directory called Guidelines-web/[language]/html

The initial teiwebsiteguidelines packages up the result into a zip file.

guidelines.xsl[.model]
The guidelines.xsl file created from the .model file imports a stack of files from the Stylesheets tree, like this:

guidelines.xsl[.model]
 * odds2/guidelines.xsl
 * odds2/odds2.xsl
 * teiodds.xsl
 * ../common2/odds.xsl
 * classatts.xsl
 * ../html5/tei.xsl
 * ../xhtml2/tei.xsl
 * ../common2/tei.xsl
 * tei-param.xsl
 * core.xsl
 * textstructure.xsl
 * header.xsl
 * linking.xsl
 * msdescription.xsl
 * figures.xsl
 * textcrit.xsl
 * i18n.xsl
 * functions.xsl
 * ../common2/verbatim.xsl
 * tei-param.xsl
 * textstructure.xsl
 * ../xhtml2/oddprocessing.xsl

The original HTML version was built using the xhtml2 libraries primarily; the HTML5 version largely imports xhtml2 templates and overrides where necessary.