]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/tools/boostbook.jam
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / tools / build / src / tools / boostbook.jam
CommitLineData
7c673cae
FG
1# Copyright 2003, 2004, 2005 Dave Abrahams
2# Copyright 2003, 2004, 2005 Douglas Gregor
3# Copyright 2005, 2006, 2007 Rene Rivera
4# Copyright 2003, 2004, 2005 Vladimir Prus
5# Distributed under the Boost Software License, Version 1.0.
6# (See accompanying file LICENSE_1_0.txt or copy at
7# http://www.boost.org/LICENSE_1_0.txt)
8
9# This module defines rules to handle generation of documentation from BoostBook
10# sources.
11#
12# The type of output is controlled by the <format> feature which can have the
13# following values:
14# * html: Generates html documentation. This is the default.
15# * xhtml: Generates xhtml documentation.
16# * htmlhelp: Generates html help output.
17# * onehtml: Generates a single html page.
18# * man: Generates man pages.
19# * pdf: Generates pdf documentation.
20# * ps: Generates postscript output.
21# * docbook: Generates docbook XML.
92f5a8d4 22# * fo: Generates XSL formatting objects.
7c673cae
FG
23# * tests: Extracts test cases from the boostbook XML.
24#
25# <format> is an implicit feature, so for example, typing pdf on the command
26# line is a short-cut for format=pdf.
27
28import build-system ;
29import "class" : new ;
30import common ;
31import feature ;
32import generators ;
33import make ;
34import modules ;
35import os ;
11fdf7f2 36import param ;
7c673cae
FG
37import path ;
38import print ;
39import project ;
40import property ;
41import property-set ;
42import regex ;
43import scanner ;
44import sequence ;
45import targets ;
46import type ;
47import virtual-target ;
48import xsltproc ;
49
50# Make this module into a project.
51project.initialize $(__name__) ;
52project boostbook ;
53
54.debug-configuration = [ MATCH ^(--debug-configuration)$ : [ modules.peek : ARGV
55 ] ] ;
56
57feature.feature format
58 : html xhtml htmlhelp onehtml man pdf ps docbook fo tests none
59 : implicit composite propagated ;
60
61type.register DTDXML : dtdxml ;
7c673cae 62type.register BOOSTBOOK : boostbook : XML ;
7c673cae 63type.register FO : fo : XML ;
7c673cae 64type.register PS : ps ;
b32b8144 65type.register XSLT : xsl xslt : XML ;
7c673cae
FG
66type.register HTMLDIR ;
67type.register XHTMLDIR ;
68type.register HTMLHELP ;
69type.register MANPAGES ;
70type.register TESTS : tests ;
71
72
73# Initialize BoostBook support.
74#
75rule init (
76 docbook-xsl-dir ? # The DocBook XSL stylesheet directory. If not provided,
77 # we use DOCBOOK_XSL_DIR from the environment (if
78 # available) or look in standard locations. Otherwise,
79 # we let the XML processor load the stylesheets
80 # remotely.
81
82 : docbook-dtd-dir ? # The DocBook DTD directory. If not provided, we use
83 # DOCBOOK_DTD_DIR From the environment (if available) or
84 # look in standard locations. Otherwise, we let the XML
85 # processor load the DTD remotely.
86
87 : boostbook-dir ? # The BoostBook directory with the DTD and XSL subdirs.
88)
89{
90 if ! $(.initialized)
91 {
92 .initialized = true ;
93
94 check-boostbook-dir $(boostbook-dir) ;
95 find-tools $(docbook-xsl-dir) : $(docbook-dtd-dir) : $(boostbook-dir) ;
96
97 # Register generators only if we were called via "using boostbook ;"
11fdf7f2 98 local reg-gen = generators.register-xslt ;
7c673cae
FG
99 $(reg-gen) boostbook.dtdxml-to-boostbook : DTDXML : XML ;
100 $(reg-gen) boostbook.boostbook-to-docbook : XML : DOCBOOK ;
101 $(reg-gen) boostbook.boostbook-to-tests : XML : TESTS ;
102 $(reg-gen) boostbook.docbook-to-onehtml : DOCBOOK : HTML ;
103 $(reg-gen) boostbook.docbook-to-htmldir : DOCBOOK : HTMLDIR ;
104 $(reg-gen) boostbook.docbook-to-xhtmldir : DOCBOOK : XHTMLDIR ;
105 $(reg-gen) boostbook.docbook-to-htmlhelp : DOCBOOK : HTMLHELP ;
106 $(reg-gen) boostbook.docbook-to-manpages : DOCBOOK : MANPAGES ;
107 $(reg-gen) boostbook.docbook-to-fo : DOCBOOK : FO ;
108
109 # The same about Jamfile main target rules.
110 IMPORT $(__name__) : boostbook : : boostbook ;
111 }
112 else
113 {
114 if $(docbook-xsl-dir)
115 {
116 modify-config ;
117 .docbook-xsl-dir = [ path.make $(docbook-xsl-dir) ] ;
118 check-docbook-xsl-dir ;
119 }
120 if $(docbook-dtd-dir)
121 {
122 modify-config ;
123 .docbook-dtd-dir = [ path.make $(docbook-dtd-dir) ] ;
124 check-docbook-dtd-dir ;
125 }
126 if $(boostbook-dir)
127 {
128 modify-config ;
129 check-boostbook-dir $(boostbook-dir) ;
130 local boostbook-xsl-dir = [ path.glob $(boostbook-dir) : xsl ] ;
131 local boostbook-dtd-dir = [ path.glob $(boostbook-dir) : dtd ] ;
132 .boostbook-xsl-dir = $(boostbook-xsl-dir[1]) ;
133 .boostbook-dtd-dir = $(boostbook-dtd-dir[1]) ;
134 check-boostbook-xsl-dir ;
135 check-boostbook-dtd-dir ;
136 }
137 }
138}
139
140
141local rule lock-config ( )
142{
143 if ! $(.initialized)
144 {
145 import errors ;
146 errors.user-error BoostBook has not been configured. ;
147 }
148 if ! $(.config-locked)
149 {
150 .config-locked = true ;
151
152 if $(.error-message)
153 {
154 print-error $(.error-message) ;
155 }
156 }
157}
158
159
160local rule modify-config ( )
161{
162 if $(.config-locked)
163 {
164 import errors ;
165 errors.user-error BoostBook configuration cannot be changed after it has
166 been used. ;
167 }
168}
169
170rule print-error ( location message * )
171{
11fdf7f2
TL
172 ECHO "error:" at $(location) ;
173 ECHO "error:" $(message) ;
7c673cae
FG
174 EXIT ;
175}
176
177rule make-error ( message * )
178{
179 import errors ;
180 return [ errors.nearest-user-location ] $(message) ;
181}
182
183
184rule find-boost-in-registry ( keys * )
185{
186 local boost-root ;
187 for local R in $(keys)
188 {
189 local installed-boost = [ W32_GETREG
190 "HKEY_LOCAL_MACHINE\\SOFTWARE\\$(R)" : "InstallRoot" ] ;
191 if $(installed-boost)
192 {
193 boost-root += [ path.make $(installed-boost) ] ;
194 }
195 }
196 return $(boost-root) ;
197}
198
199
200rule check-docbook-xsl-dir ( )
201{
202 if $(.docbook-xsl-dir)
203 {
204 if ! [ path.glob $(.docbook-xsl-dir) : common/common.xsl ]
205 {
11fdf7f2
TL
206 .error-message = [ make-error "BoostBook:" could not find docbook XSL stylesheets
207 "in:" [ path.native $(.docbook-xsl-dir) ] ] ;
7c673cae
FG
208 }
209 else if $(.debug-configuration)
210 {
11fdf7f2 211 ECHO "notice:" "BoostBook:" found docbook XSL stylesheets "in:" [
7c673cae
FG
212 path.native $(.docbook-xsl-dir) ] ;
213 }
214 }
215}
216
217
218rule check-docbook-dtd-dir ( )
219{
220 if $(.docbook-dtd-dir)
221 {
222 if ! [ path.glob $(.docbook-dtd-dir) : docbookx.dtd ]
223 {
11fdf7f2 224 .error-message = [ make-error "BoostBook:" could not find docbook DTD "in:" [
7c673cae
FG
225 path.native $(.docbook-dtd-dir) ] ] ;
226 }
227 else if $(.debug-configuration)
228 {
11fdf7f2 229 ECHO "notice:" "BoostBook:" found docbook DTD "in:" [ path.native
7c673cae
FG
230 $(.docbook-dtd-dir) ] ;
231 }
232 }
233}
234
235
236rule check-boostbook-xsl-dir ( )
237{
238 if ! $(.boostbook-xsl-dir)
239 {
11fdf7f2 240 .error-message = [ make-error "BoostBook:" could not find boostbook XSL "stylesheets." ] ;
7c673cae
FG
241 }
242 else if ! [ path.glob $(.boostbook-xsl-dir) : docbook.xsl ]
243 {
11fdf7f2 244 .error-message = [ make-error "BoostBook:" could not find docbook XSL stylesheets "in:"
7c673cae
FG
245 [ path.native $(.boostbook-xsl-dir) ] ] ;
246 }
247 else if $(.debug-configuration)
248 {
11fdf7f2 249 ECHO "notice:" "BoostBook:" found boostbook XSL stylesheets "in:" [
7c673cae
FG
250 path.native $(.boostbook-xsl-dir) ] ;
251 }
252}
253
254
255rule check-boostbook-dtd-dir ( )
256{
257 if ! $(.boostbook-dtd-dir)
258 {
11fdf7f2 259 .error-message = [ make-error "BoostBook:" could not find boostbook DTD. ] ;
7c673cae
FG
260 }
261 else if ! [ path.glob $(.boostbook-dtd-dir) : boostbook.dtd ]
262 {
11fdf7f2 263 .error-message = [ make-error "BoostBook:" could not find boostbook DTD "in:" [
7c673cae
FG
264 path.native $(.boostbook-dtd-dir) ] ] ;
265 }
266 else if $(.debug-configuration)
267 {
11fdf7f2 268 ECHO "notice:" "BoostBook:" found boostbook DTD "in:" [ path.native
7c673cae
FG
269 $(.boostbook-dtd-dir) ] ;
270 }
271}
272
273
274rule check-boostbook-dir ( boostbook-dir ? )
275{
276 if $(boostbook-dir) && ! [ path.glob $(boostbook-dir) : xsl ]
277 {
11fdf7f2 278 .error-message = [ make-error "BoostBook:" could not find boostbook "in:" [ path.native
7c673cae
FG
279 $(boostbook-dir) ] ] ;
280 }
281}
282
283
284rule find-tools ( docbook-xsl-dir ? : docbook-dtd-dir ? : boostbook-dir ? )
285{
286 docbook-xsl-dir ?= [ modules.peek : DOCBOOK_XSL_DIR ] ;
287 docbook-dtd-dir ?= [ modules.peek : DOCBOOK_DTD_DIR ] ;
288 boostbook-dir ?= [ modules.peek : BOOSTBOOK_DIR ] ;
289
290 # Look for the boostbook stylesheets relative to BOOST_ROOT and Boost.Build.
291 local boost-build-root = [ path.make [ build-system.location ] ] ;
292 local boostbook-search-dirs = [ path.join $(boost-build-root) .. .. ] ;
293
294 local boost-root = [ modules.peek : BOOST_ROOT ] ;
295 if $(boost-root)
296 {
297 boostbook-search-dirs += [ path.join [ path.make $(boost-root) ] tools ]
298 ;
299 }
300 boostbook-dir ?= [ path.glob $(boostbook-search-dirs) : boostbook* ] ;
301
302 # Try to find the tools in platform specific locations.
303 if [ os.name ] = NT
304 {
305 # If installed by the Boost installer.
306 local boost-root = ;
307
308 local boost-installer-versions = snapshot cvs 1.33.0 ;
309 local boost-consulting-installer-versions = 1.33.1 1.34.0 1.34.1 ;
310 local boostpro-installer-versions =
311 1.35.0 1.36.0 1.37.0 1.38.0 1.39.0 1.40.0 1.41.0 1.42.0
312 1.43.0 1.44.0 1.45.0 1.46.0 1.47.0 1.48.0 1.49.0 1.50.0 ;
313
314 local old-installer-root = [ find-boost-in-registry
315 Boost.org\\$(boost-installer-versions) ] ;
316
317 # Make sure that the most recent version is searched for first.
318 boost-root += [ sequence.reverse [ find-boost-in-registry
319 Boost-Consulting.com\\$(boost-consulting-installer-versions)
320 boostpro.com\\$(boostpro-installer-versions) ] ] ;
321
322 # Plausible locations.
323 local root = [ PWD ] ;
324 while $(root) != $(root:D) { root = $(root:D) ; }
325 root = [ path.make $(root) ] ;
326 local search-dirs ;
327 local docbook-search-dirs ;
328 for local p in $(boost-root)
329 {
330 search-dirs += [ path.join $(p) tools ] ;
331 }
332 for local p in $(old-installer-root)
333 {
334 search-dirs += [ path.join $(p) share ] ;
335 docbook-search-dirs += [ path.join $(p) share ] ;
336 }
337 search-dirs += [ path.join $(root) Boost tools ] ;
338 search-dirs += [ path.join $(root) Boost share ] ;
339 docbook-search-dirs += [ path.join $(root) Boost share ] ;
340
341 docbook-xsl-dir ?= [ path.glob $(docbook-search-dirs) : docbook-xsl* ] ;
342 docbook-dtd-dir ?= [ path.glob $(docbook-search-dirs) : docbook-xml* ] ;
343 boostbook-dir ?= [ path.glob $(search-dirs) : boostbook* ] ;
344 }
345 else
346 {
347 # Plausible locations.
348
349 local share = /usr/local/share /usr/share /opt/share /opt/local/share ;
350 local dtd-versions = 4.2 ;
351
352 docbook-xsl-dir ?= [ path.glob $(share) : docbook-xsl* ] ;
353 docbook-xsl-dir ?= [ path.glob $(share)/sgml/docbook : xsl-stylesheets ]
354 ;
355 docbook-xsl-dir ?= [ path.glob $(share)/xsl : docbook* ] ;
356
357 docbook-dtd-dir ?= [ path.glob $(share) : docbook-xml* ] ;
358 docbook-dtd-dir ?= [ path.glob $(share)/sgml/docbook :
359 xml-dtd-$(dtd-versions)* ] ;
360 docbook-dtd-dir ?= [ path.glob $(share)/xml/docbook : $(dtd-versions) ]
361 ;
362
363 boostbook-dir ?= [ path.glob $(share) : boostbook* ] ;
364
365 # Ubuntu Linux.
366 docbook-xsl-dir ?= [ path.glob /usr/share/xml/docbook/stylesheet :
367 nwalsh ] ;
368 docbook-dtd-dir ?= [ path.glob /usr/share/xml/docbook/schema/dtd :
369 $(dtd-versions) ] ;
370
371 # SUSE.
372 docbook-xsl-dir ?= [ path.glob /usr/share/xml/docbook/stylesheet/nwalsh
373 : current ] ;
374 }
375
376 if $(docbook-xsl-dir)
377 {
378 .docbook-xsl-dir = [ path.make $(docbook-xsl-dir[1]) ] ;
379 }
380 if $(docbook-dtd-dir)
381 {
382 .docbook-dtd-dir = [ path.make $(docbook-dtd-dir[1]) ] ;
383 }
384
385 if $(.debug-configuration)
386 {
11fdf7f2
TL
387 ECHO "notice:" "Boost.Book:" searching XSL/DTD "in" ;
388 ECHO "notice:" [ sequence.transform path.native : $(boostbook-dir) ] ;
7c673cae
FG
389 }
390 local boostbook-xsl-dir ;
391 for local dir in $(boostbook-dir)
392 {
393 boostbook-xsl-dir += [ path.glob $(dir) : xsl ] ;
394 }
395 local boostbook-dtd-dir ;
396 for local dir in $(boostbook-dir)
397 {
398 boostbook-dtd-dir += [ path.glob $(dir) : dtd ] ;
399 }
400 .boostbook-xsl-dir = $(boostbook-xsl-dir[1]) ;
401 .boostbook-dtd-dir = $(boostbook-dtd-dir[1]) ;
402
403 check-docbook-xsl-dir ;
404 check-docbook-dtd-dir ;
405 check-boostbook-xsl-dir ;
406 check-boostbook-dtd-dir ;
407}
408
409
410rule xsl-dir
411{
412 lock-config ;
413 return $(.boostbook-xsl-dir) ;
414}
415
416
417rule dtd-dir
418{
419 lock-config ;
420 return $(.boostbook-dtd-dir) ;
421}
422
423
424rule docbook-xsl-dir
425{
426 lock-config ;
427 return $(.docbook-xsl-dir) ;
428}
429
430
431rule docbook-dtd-dir
432{
433 lock-config ;
434 return $(.docbook-dtd-dir) ;
435}
436
437
438rule dtdxml-to-boostbook ( target : source : properties * )
439{
440 lock-config ;
92f5a8d4
TL
441 local stylesheet = [ path.native $(.boostbook-xsl-dir)/dtd/dtd2boostbook.xsl ] ;
442 xsltproc.xslt $(target) : $(source) $(stylesheet) : $(properties) ;
7c673cae
FG
443}
444
445
446rule boostbook-to-docbook ( target : source : properties * )
447{
448 lock-config ;
449 local stylesheet = [ path.native $(.boostbook-xsl-dir)/docbook.xsl ] ;
450 xsltproc.xslt $(target) : $(source) $(stylesheet) : $(properties) ;
451}
452
453
454rule docbook-to-onehtml ( target : source : properties * )
455{
456 lock-config ;
457 local stylesheet = [ path.native $(.boostbook-xsl-dir)/html-single.xsl ] ;
458 xsltproc.xslt $(target) : $(source) $(stylesheet) : $(properties) ;
459}
460
461
462rule docbook-to-htmldir ( target : source : properties * )
463{
464 lock-config ;
465 local stylesheet = [ path.native $(.boostbook-xsl-dir)/html.xsl ] ;
466 xsltproc.xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : html
467 ;
468}
469
470
471rule docbook-to-xhtmldir ( target : source : properties * )
472{
473 lock-config ;
474 local stylesheet = [ path.native $(.boostbook-xsl-dir)/xhtml.xsl ] ;
475 xsltproc.xslt-dir $(target) : $(source) $(stylesheet) : $(properties) :
476 xhtml ;
477}
478
479
480rule docbook-to-htmlhelp ( target : source : properties * )
481{
482 lock-config ;
483 local stylesheet = [ path.native $(.boostbook-xsl-dir)/html-help.xsl ] ;
484 xsltproc.xslt-dir $(target) : $(source) $(stylesheet) : $(properties) :
485 htmlhelp ;
486}
487
488
489rule docbook-to-manpages ( target : source : properties * )
490{
491 lock-config ;
492 local stylesheet = [ path.native $(.boostbook-xsl-dir)/manpages.xsl ] ;
493 xsltproc.xslt-dir $(target) : $(source) $(stylesheet) : $(properties) : man
494 ;
495}
496
497
498rule docbook-to-fo ( target : source : properties * )
499{
500 lock-config ;
501 local stylesheet = [ path.native $(.boostbook-xsl-dir)/fo.xsl ] ;
502 xsltproc.xslt $(target) : $(source) $(stylesheet) : $(properties) ;
503}
504
505
506rule format-catalog-path ( path )
507{
508 local result = $(path) ;
509 if [ xsltproc.is-cygwin ]
510 {
511 if [ os.name ] = NT
512 {
11fdf7f2 513 drive = [ MATCH "^/(.):(.*)$" : $(path) ] ;
7c673cae
FG
514 result = /cygdrive/$(drive[1])$(drive[2]) ;
515 }
516 }
517 else
518 {
519 if [ os.name ] = CYGWIN
520 {
521 local native-path = [ path.native $(path) ] ;
522 result = [ path.make $(native-path:W) ] ;
523 }
524 }
525 return [ regex.replace $(result) " " "%20" ] ;
526}
527
528
529rule generate-xml-catalog ( target : sources * : properties * )
530{
531 print.output $(target) ;
532
533 # BoostBook DTD catalog entry.
534 local boostbook-dtd-dir = [ boostbook.dtd-dir ] ;
535 if $(boostbook-dtd-dir)
536 {
537 boostbook-dtd-dir = [ format-catalog-path $(boostbook-dtd-dir) ] ;
538 }
539
540 print.text
541 "<?xml version=\"1.0\"?>"
542 "<!DOCTYPE catalog "
543 " PUBLIC \"-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN\""
544 " \"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd\">"
545 "<catalog xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">"
546 " <rewriteURI uriStartString=\"http://www.boost.org/tools/boostbook/dtd/\" rewritePrefix=\"file://$(boostbook-dtd-dir)/\"/>"
547 : true ;
548
549 local docbook-xsl-dir = [ boostbook.docbook-xsl-dir ] ;
550 if ! $(docbook-xsl-dir)
551 {
552 ECHO "BoostBook warning: no DocBook XSL directory specified." ;
553 ECHO " If you have the DocBook XSL stylesheets installed, please " ;
554 ECHO " set DOCBOOK_XSL_DIR to the stylesheet directory on either " ;
555 ECHO " the command line (via -sDOCBOOK_XSL_DIR=...) or in a " ;
556 ECHO " Boost.Jam configuration file. The DocBook XSL stylesheets " ;
557 ECHO " are available here: http://docbook.sourceforge.net/ " ;
558 ECHO " Stylesheets will be downloaded on-the-fly (very slow!) " ;
559 }
560 else
561 {
562 docbook-xsl-dir = [ format-catalog-path $(docbook-xsl-dir) ] ;
563 print.text " <rewriteURI uriStartString=\"http://docbook.sourceforge.net/release/xsl/current/\" rewritePrefix=\"file://$(docbook-xsl-dir)/\"/>" ;
564 }
565
566 local docbook-dtd-dir = [ boostbook.docbook-dtd-dir ] ;
567 if ! $(docbook-dtd-dir)
568 {
569 ECHO "BoostBook warning: no DocBook DTD directory specified." ;
570 ECHO " If you have the DocBook DTD installed, please set " ;
571 ECHO " DOCBOOK_DTD_DIR to the DTD directory on either " ;
572 ECHO " the command line (via -sDOCBOOK_DTD_DIR=...) or in a " ;
573 ECHO " Boost.Jam configuration file. The DocBook DTD is available " ;
574 ECHO " here: http://www.oasis-open.org/docbook/xml/4.2/index.shtml" ;
575 ECHO " The DTD will be downloaded on-the-fly (very slow!) " ;
576 }
577 else
578 {
579 docbook-dtd-dir = [ format-catalog-path $(docbook-dtd-dir) ] ;
580 print.text " <rewriteURI uriStartString=\"http://www.oasis-open.org/docbook/xml/4.2/\" rewritePrefix=\"file://$(docbook-dtd-dir)/\"/>" ;
581 }
582
583 print.text "</catalog>" ;
584}
585
586
587# Returns information about the global XML catalog target, creating it lazily if
588# needed. To get the global catalog generated only once we do not create it in
589# every project that requests it but instead only create it based on the first
590# project requesting it and then reuse it from there for any later requests.
591#
592# To get 'as close as possible' to having the global catalog stored in the same
593# location independent of which folder our build was run from, we assign its
594# target to the given project's base Jamroot project. This works correctly as
595# long as we know the passed project is not standalone or one of Boost Build's
596# configuration module projects, as those to not have a Jamroot project in their
597# parent chain. Note also that we can still get our targets generated in
598# different folders in case when one build project references a target from
599# another build project with its own separate Jamroot.
600#
601# FIXME: Ideally the catalog target should be created as part of the boostbook
602# project and stored in some central location for all used standalone pojects,
603# shared between all builds made on that system. This however would require much
604# more though to add the necessary changes to Boost Build's internal design.
605#
606local rule xml-catalog ( project )
607{
608 if ! $(.xml-catalog)
609 {
610 local project-module = [ $(project).project-module ] ;
611 local root-module = [ project.get-jamroot-module $(project-module) ] ;
612 if ! $(root-module)
613 {
614 import errors ;
615 if [ project.is-config-module $(project-module) ]
616 {
617 errors.user-error boostbook targets can not be declared in Boost
618 Build's configuration modules. ;
619 }
620 else
621 {
622 errors.user-error boostbook targets can not be declared in
623 standalone projects. : use a Jamfile/Jamroot project
624 instead. ;
625 }
626 }
627 local root-project = [ project.target $(root-module) ] ;
628
629 .xml-catalog = [ virtual-target.register [ new file-target
630 boostbook_catalog : XML : $(root-project) : [ new action :
631 boostbook.generate-xml-catalog ] ] ] ;
632 .xml-catalog-file = [ $(.xml-catalog).path ] [ $(.xml-catalog).name ] ;
633 .xml-catalog-file = $(.xml-catalog-file:J=/) ;
634 }
635 return $(.xml-catalog) $(.xml-catalog-file) ;
636}
637
638
639class boostbook-target-class : basic-target
640{
641 import generators ;
642 import property-set ;
643 import virtual-target ;
644 import path ;
645
646 rule construct ( name : sources * : property-set )
647 {
648 # Generate the catalog, but only once.
649 IMPORT boostbook : xml-catalog : $(__name__) : boostbook.xml-catalog ;
650 local global-catalog = [ boostbook.xml-catalog [ project ] ] ;
651 local catalog = $(global-catalog[1]) ;
652 local catalog-file = $(global-catalog[2]) ;
653 local targets ;
654
655 # Add the catalog to the property set.
656 property-set = [ $(property-set).add-raw <catalog>$(catalog-file) ] ;
657
658 local type = none ;
659 local manifest ;
660 local format = [ $(property-set).get <format> ] ;
661 switch $(format)
662 {
663 case html : type = HTMLDIR ; manifest = HTML.manifest ;
664 case xhtml : type = XHTMLDIR ; manifest = HTML.manifest ;
665 case htmlhelp : type = HTMLHELP ; manifest = HTML.manifest ;
666 case onehtml : type = HTML ;
667 case man : type = MANPAGES ; manifest = man.manifest ;
668 case docbook : type = DOCBOOK ;
669 case fo : type = FO ;
670 case pdf : type = PDF ;
671 case ps : type = PS ;
672 case tests : type = TESTS ;
673 }
674
675 local target ;
676 if $(manifest)
677 {
678 # Sources --> DOCBOOK.
679 local docbook-target = [ generators.construct [ project ] : DOCBOOK
680 : $(property-set) : $(sources) ] ;
681 docbook-target = $(docbook-target[2]) ;
682 $(docbook-target).depends $(catalog) ;
683
684 # DOCBOOK --> type.
685 target = [ generators.construct [ project ] $(name)_$(manifest) :
686 $(type) : [ $(property-set).add-raw
687 <xsl:param>manifest=$(name)_$(manifest) ] : $(docbook-target) ]
688 ;
689 target = $(target[2]) ;
690 local name = [ $(property-set).get <name> ] ;
691 name ?= $(format) ;
692 if ! [ path.is-rooted $(name) ]
693 {
694 local p = [ project ] ;
695 name = [ path.join [ $(p).location ] $(name) ] ;
696 }
697 $(target).set-path $(name) ;
698 }
699 else
700 {
701 # Sources --> type.
702 target = [ generators.construct [ project ] : $(type) :
703 $(property-set) : $(sources) ] ;
704 target = $(target[2]) ;
705 if ! $(target)
706 {
707 import errors ;
708 errors.error Cannot build documentation type '$(format)'. ;
709 }
710 }
711 $(target).depends $(catalog) ;
712
713 return [ property-set.empty ] $(target) ;
714 }
715}
716
717
718# Declare a boostbook target.
719#
11fdf7f2
TL
720rule boostbook ( target-name : sources * : requirements * : default-build * :
721 usage-requirements * )
7c673cae 722{
11fdf7f2
TL
723 param.handle-named-params
724 sources requirements default-build usage-requirements ;
7c673cae
FG
725 return [ targets.create-metatarget boostbook-target-class :
726 [ project.current ] : $(target-name) : $(sources) : $(requirements) :
11fdf7f2 727 $(default-build) : $(usage-requirements) ] ;
7c673cae
FG
728}
729
730
731rule boostbook-to-tests ( target : source : properties * )
732{
733 lock-config ;
734 local boost_root = [ modules.peek : BOOST_ROOT ] ;
735 local native-path = [ path.native [ path.join $(.boostbook-xsl-dir) testing
736 Jamfile ] ] ;
737 local stylesheet = $(native-path:S=.xsl) ;
738 xsltproc.xslt $(target) : $(source) $(stylesheet) : $(properties)
739 <xsl:param>boost.root=$(boost_root) ;
740}