| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 | # $Source$# $Author$# $Date$# $Revision: 6666 $# vim: number## -----------------------------------------------------------------#  ** Makefile.combine -- combine source files **# -----------------------------------------------------------------##   This file is part of the DocBook Project XSL Stylesheet#   distribution.##   See http://docbook.sourceforge.net/release/xsl/current/#   for copyright and other information.## This makefile creates "wrapper" files that combine sets of# individual DocBook source files. The purpose of combining the# files is to speed up processing time. By default it puts 20# files into each wrapper. Use CHUNKSIZE to configure the number# of files per wrapper.## Currently, this makefile has only a "man" target and is mainly# intended to speed up processing of large numbers of individual# refentry instances.# What file extension do you use for DocBook source files?DOCBOOK_FILE_EXTENSION = .xmlSOURCE_FILES_DBK = $(wildcard *$(DOCBOOK_FILE_EXTENSION))MAKEFILE_DOCBOOK = Makefile.DocBookXSLTPROC=xsltprocXSLTPROC_FLAGS=SED=sedSED_FLAGS=-iCHUNKSIZE ?= 20WRAPPER_ELEMENT = referenceWRAPPER_TITLE=Combined contentsCOMBINE_XSL = <?xml version="1.0"?> \<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \                xmlns:exsl="http://exslt.org/common" \                xmlns:xi="http://www.w3.org/2001/XInclude" \                exclude-result-prefixes="exsl xi" \                extension-element-prefixes="exsl" \                version="1.0"> \  <xsl:param name="files"/> \  <xsl:param name="chunk.size"/> \  <xsl:template match="/"> \    <xsl:call-template name="make.file"/> \  </xsl:template> \ \  <xsl:template name="make.file"> \    <xsl:param name="count" select="1"/> \    <xsl:param name="current.files" select="concat(normalize-space($$files), ^^ ^^)"/> \    <xsl:param name="more.files" \               select="concat(normalize-space(substring-after($$current.files, ^^ ^^)),^^ ^^)"/> \    <xsl:param name="file.number" select="1"/> \    <xsl:param name="filename" select="concat(^^./build/^^,$$file.number,^^.xml^^)"/> \ \    <xsl:choose> \      <xsl:when test="$$more.files = ^^ ^^"/> \      <xsl:when test="$$count mod $$chunk.size = 0"> \        <xsl:variable name="fileset" select="concat($$current.files, ^^ ^^, \          substring-before($$more.files, ^^ ^^))"/> \        <exsl:document href="{$$filename}" \                       method="xml" \                       encoding="UTF-8" \                       indent="yes" \                       omit-xml-declaration="yes" \                       media-type="" \                       standalone="no"> \          <$(WRAPPER_ELEMENT)> \            <title>$(WRAPPER_TITLE)</title> \            <xsl:call-template name="make.xinclude"> \              <xsl:with-param name="file"> \                <xsl:choose> \                  <xsl:when test="contains($$fileset, ^^ ^^)"> \                    <xsl:value-of \                        select="normalize-space(substring-before($$fileset, ^^ ^^))"/> \                  </xsl:when> \                  <xsl:otherwise> \                    <xsl:value-of select="$$fileset"/> \                  </xsl:otherwise> \                </xsl:choose> \              </xsl:with-param> \              <xsl:with-param \                  name="remaining.files" \                  select="concat(normalize-space(substring-after($$fileset, ^^ ^^)),^^ ^^)"/> \            </xsl:call-template> \          </$(WRAPPER_ELEMENT)> \        </exsl:document> \        <xsl:call-template name="make.file"> \          <xsl:with-param name="count" select="1"/> \          <xsl:with-param name="current.files"  \                          select="$$more.files"/> \          <xsl:with-param name="file.number" select="number($$file.number) + 1"/> \          <xsl:with-param name="filename" select="concat(^^./build/^^,$$file.number,^^.xml^^)"/> \        </xsl:call-template> \      </xsl:when> \      <xsl:otherwise> \        <xsl:call-template name="make.file"> \          <xsl:with-param name="count" select="$$count + 1"/> \          <xsl:with-param name="current.files"> \            <xsl:choose> \              <xsl:when test="$$count = 1 and $$file.number = 1"> \                <xsl:value-of  \                    select="concat(substring-before($$current.files, ^^ ^^), \                            ^^ ^^, \                            substring-before($$more.files, ^^ ^^))"/> \              </xsl:when> \              <xsl:when test="$$count = 1"> \                <xsl:value-of  \                    select="substring-before($$more.files, ^^ ^^)"/> \              </xsl:when> \              <xsl:otherwise> \                <xsl:value-of  \                    select="concat($$current.files, ^^ ^^, \                            substring-before($$more.files, ^^ ^^))"/> \              </xsl:otherwise> \            </xsl:choose> \          </xsl:with-param> \          <xsl:with-param name="more.files" \                          select="substring-after($$more.files, ^^ ^^)"/> \          <xsl:with-param name="file.number" select="$$file.number"/> \        </xsl:call-template> \      </xsl:otherwise> \    </xsl:choose> \  </xsl:template> \ \  <xsl:template name="make.xinclude"> \    <xsl:param name="file"/> \    <xsl:param name="remaining.files"/> \    <xsl:param name="count" select="1"/> \    <xsl:if test="not($$file = ^^^^)"> \      <xi:include href="../{$$file}"/> \      <xsl:call-template name="make.xinclude"> \        <xsl:with-param \            name="file" \            select="substring-before($$remaining.files, ^^ ^^)"/> \        <xsl:with-param \            name="remaining.files" \            select="substring-after($$remaining.files, ^^ ^^)"/> \        <xsl:with-param name="count" select="$$count + 1"/> \      </xsl:call-template> \    </xsl:if> \  </xsl:template> \ \</xsl:stylesheet>all: manman: build/manbuild/Makefile:	if [ ! -d build ]; then mkdir build; fi	cp $(MAKEFILE_DOCBOOK) $@combine.xsl: Makefile	@echo '$(COMBINE_XSL)' > $@	$(SED) $(SED_FLAGS) "s/\^\^/'/g" $@build/1.xml: combine.xsl	$(XSLTPROC) $(XSLTPROC_FLAGS) \	--stringparam files "$(SOURCE_FILES_DBK)" \	--stringparam chunk.size $(CHUNKSIZE) \	$< $<build/man: build/Makefile build/1.xml	time $(MAKE) -C build man \		MAN_PARAMS="--stringparam man.output.quietly 1 \		   --stringparam refentry.meta.get.quietly 1 \		   --stringparam man.charmap.enabled 0"debug:clean:	$(RM) -r build
 |