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