3 # $Date: 2007-03-04 22:28:18 -0800 (Sun, 04 Mar 2007) $
7 # -----------------------------------------------------------------
8 # ** Makefile.combine -- combine source files **
9 # -----------------------------------------------------------------
11 # This file is part of the DocBook Project XSL Stylesheet
14 # See http://docbook.sourceforge.net/release/xsl/current/
15 # for copyright and other information.
17 # This makefile creates "wrapper" files that combine sets of
18 # individual DocBook source files. The purpose of combining the
19 # files is to speed up processing time. By default it puts 20
20 # files into each wrapper. Use CHUNKSIZE to configure the number
21 # of files per wrapper.
23 # Currently, this makefile has only a "man" target and is mainly
24 # intended to speed up processing of large numbers of individual
27 # What file extension do you use for DocBook source files?
28 DOCBOOK_FILE_EXTENSION = .xml
29 SOURCE_FILES_DBK = $(wildcard *$(DOCBOOK_FILE_EXTENSION))
31 MAKEFILE_DOCBOOK = Makefile.DocBook
41 WRAPPER_ELEMENT = reference
42 WRAPPER_TITLE=Combined contents
44 COMBINE_XSL = <?xml version="1.0"?> \
45 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" \
46 xmlns:exsl="http://exslt.org/common" \
47 xmlns:xi="http://www.w3.org/2001/XInclude" \
48 exclude-result-prefixes="exsl xi" \
49 extension-element-prefixes="exsl" \
51 <xsl:param name="files"/> \
52 <xsl:param name="chunk.size"/> \
53 <xsl:template match="/"> \
54 <xsl:call-template name="make.file"/> \
57 <xsl:template name="make.file"> \
58 <xsl:param name="count" select="1"/> \
59 <xsl:param name="current.files" select="concat(normalize-space($$files), ^^ ^^)"/> \
60 <xsl:param name="more.files" \
61 select="concat(normalize-space(substring-after($$current.files, ^^ ^^)),^^ ^^)"/> \
62 <xsl:param name="file.number" select="1"/> \
63 <xsl:param name="filename" select="concat(^^./build/^^,$$file.number,^^.xml^^)"/> \
66 <xsl:when test="$$more.files = ^^ ^^"/> \
67 <xsl:when test="$$count mod $$chunk.size = 0"> \
68 <xsl:variable name="fileset" select="concat($$current.files, ^^ ^^, \
69 substring-before($$more.files, ^^ ^^))"/> \
70 <exsl:document href="{$$filename}" \
74 omit-xml-declaration="yes" \
77 <$(WRAPPER_ELEMENT)> \
78 <title>$(WRAPPER_TITLE)</title> \
79 <xsl:call-template name="make.xinclude"> \
80 <xsl:with-param name="file"> \
82 <xsl:when test="contains($$fileset, ^^ ^^)"> \
84 select="normalize-space(substring-before($$fileset, ^^ ^^))"/> \
87 <xsl:value-of select="$$fileset"/> \
92 name="remaining.files" \
93 select="concat(normalize-space(substring-after($$fileset, ^^ ^^)),^^ ^^)"/> \
94 </xsl:call-template> \
95 </$(WRAPPER_ELEMENT)> \
97 <xsl:call-template name="make.file"> \
98 <xsl:with-param name="count" select="1"/> \
99 <xsl:with-param name="current.files" \
100 select="$$more.files"/> \
101 <xsl:with-param name="file.number" select="number($$file.number) + 1"/> \
102 <xsl:with-param name="filename" select="concat(^^./build/^^,$$file.number,^^.xml^^)"/> \
103 </xsl:call-template> \
106 <xsl:call-template name="make.file"> \
107 <xsl:with-param name="count" select="$$count + 1"/> \
108 <xsl:with-param name="current.files"> \
110 <xsl:when test="$$count = 1 and $$file.number = 1"> \
112 select="concat(substring-before($$current.files, ^^ ^^), \
114 substring-before($$more.files, ^^ ^^))"/> \
116 <xsl:when test="$$count = 1"> \
118 select="substring-before($$more.files, ^^ ^^)"/> \
122 select="concat($$current.files, ^^ ^^, \
123 substring-before($$more.files, ^^ ^^))"/> \
127 <xsl:with-param name="more.files" \
128 select="substring-after($$more.files, ^^ ^^)"/> \
129 <xsl:with-param name="file.number" select="$$file.number"/> \
130 </xsl:call-template> \
135 <xsl:template name="make.xinclude"> \
136 <xsl:param name="file"/> \
137 <xsl:param name="remaining.files"/> \
138 <xsl:param name="count" select="1"/> \
139 <xsl:if test="not($$file = ^^^^)"> \
140 <xi:include href="../{$$file}"/> \
141 <xsl:call-template name="make.xinclude"> \
144 select="substring-before($$remaining.files, ^^ ^^)"/> \
146 name="remaining.files" \
147 select="substring-after($$remaining.files, ^^ ^^)"/> \
148 <xsl:with-param name="count" select="$$count + 1"/> \
149 </xsl:call-template> \
160 if [ ! -d build ]; then mkdir build; fi
161 cp $(MAKEFILE_DOCBOOK) $@
163 combine.xsl: Makefile
164 @echo '$(COMBINE_XSL)' > $@
165 $(SED) $(SED_FLAGS) "s/\^\^/'/g" $@
167 build/1.xml: combine.xsl
168 $(XSLTPROC) $(XSLTPROC_FLAGS) \
169 --stringparam files "$(SOURCE_FILES_DBK)" \
170 --stringparam chunk.size $(CHUNKSIZE) \
173 build/man: build/Makefile build/1.xml
174 time $(MAKE) -C build man \
175 MAN_PARAMS="--stringparam man.output.quietly 1 \
176 --stringparam refentry.meta.get.quietly 1 \
177 --stringparam man.charmap.enabled 0"