1[[bbv2.reference]] 2= Reference 3 4[[bbv2.reference.general]] 5== General information 6 7[[bbv2.reference.init]] 8=== Initialization 9 10Immediately upon starting, the B2 engine (*`b2`*) loads the Jam 11code that implements the build system. To do this, it searches for a 12file called `boost-build.jam`, first in the invocation directory, then 13in its parent and so forth up to the filesystem root, and finally in the 14directories specified by the environment variable BOOST_BUILD_PATH. On 15Unix BOOST_BUILD_PATH defaults to `/usr/share/boost-build`. When 16found, the file is interpreted, and should specify the build system 17location by calling the boost-build rule: 18 19[source] 20---- 21rule boost-build ( location ? ) 22---- 23 24If location is a relative path, it is treated as relative to the 25directory of `boost-build.jam`. The directory specified by that location 26and the directories in BOOST_BUILD_PATH are then searched for a file 27called `bootstrap.jam`, which is expected to bootstrap the build system. 28This arrangement allows the build system to work without any 29command-line or environment variable settings. For example, if the build 30system files were located in a directory "build-system/" at your project 31root, you might place a `boost-build.jam` at the project root 32containing: 33 34[source] 35---- 36boost-build build-system ; 37---- 38 39In this case, running *`b2`* anywhere in the project tree will 40automatically find the build system. 41 42The default `bootstrap.jam`, after loading some standard definitions, 43loads both `site-config.jam` and `user-config.jam`. 44 45[[bbv2.reference.rules]] 46== Builtin rules 47 48This section contains the list of all rules that can be used in 49Jamfile — both rules that define new targets and auxiliary rules. 50 51[[bbv2.reference.rules.exe]]`exe`:: 52Creates an executable file. See 53link:#bbv2.tasks.programs[the section called “Programs”]. 54 55[[bbv2.reference.rules.lib]]`lib`:: 56Creates an library file. See 57link:#bbv2.tasks.libraries[the section called “Libraries”]. 58 59[[bbv2.reference.rules.install]]`install`:: 60Installs built targets and other files. See 61link:#bbv2.tasks.installing[the section called “Installing”]. 62 63[[bbv2.reference.rules.alias]]`alias`:: 64Creates an alias for other targets. See 65link:#bbv2.tasks.alias[the section called “Alias”]. 66 67[[bbv2.reference.rules.unit-test]]`unit-test`:: 68Creates an executable that will be automatically run. See 69link:#bbv2.builtins.testing[the section called “Testing”]. 70 71[[bbv2.reference.rules.test]]`compile`; `compile-fail`; `link`; `link-fail`; `run`; `run-fail`:: 72Specialized rules for testing. See 73link:#bbv2.builtins.testing[the section called “Testing”]. 74 75[[bbv2.reference.rules.check-target-builds]]`check-target-builds`:: 76The `check-target-builds` allows you to conditionally use different 77properties depending on whether some metatarget builds, or not. This 78is similar to functionality of configure script in `autotools` projects. 79The function signature is: 80+ 81---- 82rule check-target-builds ( target message ? : true-properties * : false-properties * ) 83---- 84+ 85This function can only be used when passing requirements or usage 86requirements to a metatarget rule. For example, to make an application 87link to a library if it's available, one has use the following: 88+ 89---- 90exe app : app.cpp : [ check-target-builds has_foo "System has foo" : <library>foo : <define>FOO_MISSING=1 ] ; 91---- 92+ 93For another example, the alias rule can be used to consolidate 94configuration choices and make them available to other metatargets, 95like so: 96+ 97---- 98alias foobar : : : : [ check-target-builds has_foo "System has foo" : <library>foo : <library>bar ] ; 99---- 100 101[[bbv2.reference.rules.obj]]`obj`:: 102Creates an object file. Useful when a single source file must be 103compiled with special properties. 104 105[[bbv2.reference.rules.preprocessed]]`preprocessed`:: 106Creates an preprocessed source file. The arguments follow the 107link:#bbv2.main-target-rule-syntax[common syntax]. 108 109[[bbv2.reference.rules.glob]]`glob`:: 110The `glob` rule takes a list shell pattern and returns the list of 111files in the project's source directory that match the pattern. For 112example: 113+ 114---- 115lib tools : [ glob *.cpp ] ; 116---- 117+ 118It is possible to also pass a second argument—the list of exclude 119patterns. The result will then include the list of files matching any 120of include patterns, and not matching any of the exclude patterns. For 121example: 122+ 123---- 124lib tools : [ glob *.cpp : file_to_exclude.cpp bad*.cpp ] ; 125---- 126 127[[bbv2.reference.glob-tree]]`glob-tree`:: 128The `glob-tree` is similar to the `glob` except that it operates 129recursively from the directory of the containing Jamfile. For example: 130+ 131---- 132ECHO [ glob-tree *.cpp : .svn ] ; 133---- 134+ 135will print the names of all {CPP} files in your project. The `.svn` 136exclude pattern prevents the `glob-tree` rule from entering 137administrative directories of the Subversion version control system. 138 139[[bbv2.reference.rules.project]]`project`:: 140Declares project id and attributes, including project requirements. 141See link:#bbv2.overview.projects[the section called “Projects”]. 142 143[[bbv2.reference.rules.use-project]]`use-project`:: 144Assigns a symbolic project ID to a project at a given path. This rule 145must be better documented! 146 147[[bbv2.reference.rules.explicit]]`explicit`:: 148The `explicit` rule takes a single parameter--a list of target names. 149The named targets will be marked explicit, and will be built only if 150they are explicitly requested on the command line, or if their 151dependents are built. Compare this to ordinary targets, that are built 152implicitly when their containing project is built. 153 154[[bbv2.reference.rules.always]]`always`:: 155The `always` function takes a single parameter—a list of metatarget 156names. The targets produced by the named metatargets will be 157always considered out of date. Consider this example: 158+ 159---- 160exe hello : hello.cpp ; 161exe bye : bye.cpp ; 162always hello ; 163---- 164+ 165If a build of `hello` is requested, then it will always be recompiled. Note that 166if a build of `hello` is not requested, for example you specify just 167`bye` on the command line, `hello` will not be recompiled. 168 169[[bbv2.reference.rules.constant]]`constant`:: 170Sets project-wide constant. Takes two parameters: variable name and a 171value and makes the specified variable name accessible in this Jamfile 172and any child Jamfiles. For example: 173+ 174---- 175constant VERSION : 1.34.0 ; 176---- 177 178[[bbv2.reference.rules.path-constant]]`path-constant`:: 179Same as `constant` except that the value is treated as path relative 180to Jamfile location. For example, if `b2` is invoked in the current 181directory, and Jamfile in `helper` subdirectory has: 182+ 183---- 184path-constant DATA : data/a.txt ; 185---- 186+ 187then the variable `DATA` will be set to `helper/data/a.txt`, and if 188*`b2`* is invoked from the `helper` directory, then the variable `DATA` 189will be set to `data/a.txt`. 190 191[[bbv2.reference.rules.build-project]]`build-project`:: 192Cause some other project to be built. This rule takes a single 193parameter—a directory name relative to the containing Jamfile. When 194the containing Jamfile is built, the project located at that directory 195will be built as well. At the moment, the parameter to this rule 196should be a directory name. Project ID or general target references 197are not allowed. 198 199[[bbv2.reference.rules.test-suite]]`test-suite`:: 200This rule is deprecated and equivalent to `alias`. 201 202[[bbv2.overview.builtins.features]] 203== Builtin features 204 205This section documents the features that are built-in into B2. 206For features with a fixed set of values, that set is provided, with the 207default value listed first. 208 209include::../../src/tools/features/address-model-feature.jam[tag=doc] 210include::../../src/tools/features/sanitizers-feature.jam[tag=addr-doc] 211include::../../src/tools/features/allow-feature.jam[tag=doc] 212include::../../src/tools/features/architecture-feature.jam[tag=doc] 213include::../../src/tools/features/archiveflags-feature.jam[tag=doc] 214include::../../src/tools/features/asmflags-feature.jam[tag=doc] 215include::../../src/tools/features/exception-feature.jam[tag=asynch-doc] 216include::../../src/tools/features/build-feature.jam[tag=doc] 217include::../../src/tools/features/cflags-feature.jam[tag=doc] 218include::../../src/tools/features/conditional-feature.jam[tag=doc] 219include::../../src/tools/features/coverage-feature.jam[tag=doc] 220include::../../src/tools/features/cxxflags-feature.jam[tag=doc] 221include::../../src/tools/features/cxxstd-feature.jam[tag=doc] 222include::../../src/tools/features/cxxabi-feature.jam[tag=doc] 223include::../../src/tools/features/cxx-template-depth-feature.jam[tag=doc] 224include::../../src/tools/features/debug-feature.jam[tag=doc] 225include::../../src/tools/features/define-feature.jam[tag=doc] 226include::../../src/tools/features/dll-feature.jam[tag=def-doc] 227include::../../src/tools/features/dependency-feature.jam[tag=doc] 228include::../../src/tools/features/dll-feature.jam[tag=doc] 229include::../../src/tools/msvc.jam[tag=embed-doc] 230include::../../src/tools/features/exception-feature.jam[tag=doc] 231include::../../src/tools/features/fflags-feature.jam[tag=doc] 232include::../../src/tools/features/file-feature.jam[tag=doc] 233include::../../src/tools/features/find-lib-feature.jam[tag=doc] 234include::../../src/tools/features/flags-feature.jam[tag=doc] 235include::../../src/tools/features/dll-feature.jam[tag=hardcode-doc] 236include::../../src/tools/features/dependency-feature.jam[tag=impl-doc] 237include::../../src/tools/features/force-include-feature.jam[tag=doc] 238include::../../src/tools/features/include-feature.jam[tag=doc] 239include::../../src/tools/features/optimization-feature.jam[tag=inline-doc] 240include::../../src/tools/stage.jam[tag=features-install-package-doc] 241include::../../src/tools/stage.jam[tag=features-install-prefix-doc] 242include::../../src/tools/features/instruction-set-feature.jam[tag=doc] 243include::../../src/tools/features/library-feature.jam[tag=doc] 244include::../../src/tools/features/find-lib-feature.jam[tag=path-doc] 245include::../../src/tools/features/sanitizers-feature.jam[tag=leak-doc] 246include::../../src/tools/features/link-feature.jam[tag=doc] 247include::../../src/tools/features/linkflags-feature.jam[tag=doc] 248include::../../src/tools/features/local-visibility-feature.jam[tag=doc] 249include::../../src/tools/features/location-feature.jam[tag=doc] 250include::../../src/tools/features/location-prefix-feature.jam[tag=doc] 251include::../../src/tools/features/objcflags-feature.jam[tag=doc] 252include::../../src/tools/features/name-feature.jam[tag=doc] 253include::../../src/tools/features/optimization-feature.jam[tag=doc] 254include::../../src/tools/features/debug-feature.jam[tag=prof-doc] 255include::../../src/tools/features/relevant-feature.jam[tag=doc] 256include::../../src/tools/features/rtti-feature.jam[tag=doc] 257include::../../src/tools/features/runtime-feature.jam[tag=doc] 258include::../../src/tools/features/search-feature.jam[tag=doc] 259include::../../src/tools/features/source-feature.jam[tag=doc] 260include::../../src/tools/stage.jam[tag=features-staging-prefix-doc] 261include::../../src/tools/features/stdlib-feature.jam[tag=doc] 262include::../../src/tools/features/strip-feature.jam[tag=doc] 263include::../../src/tools/features/dll-feature.jam[tag=suppress-doc] 264include::../../src/tools/features/tag-feature.jam[tag=doc] 265include::../../src/tools/features/os-feature.jam[tag=doc] 266include::../../src/tools/features/threading-feature.jam[tag=doc] 267include::../../src/tools/features/sanitizers-feature.jam[tag=thread-doc] 268include::../../src/tools/features/toolset-feature.jam[tag=doc] 269include::../../src/tools/features/define-feature.jam[tag=undef-doc] 270include::../../src/tools/features/sanitizers-feature.jam[tag=undef-doc] 271include::../../src/tools/features/dependency-feature.jam[tag=use-doc] 272include::../../src/tools/features/user-interface-feature.jam[tag=doc] 273include::../../src/tools/features/variant-feature.jam[tag=doc] 274include::../../src/tools/features/optimization-feature.jam[tag=vector-doc] 275include::../../src/tools/features/version-feature.jam[tag=doc] 276include::../../src/tools/features/visibility-feature.jam[tag=doc] 277include::../../src/tools/features/warnings-feature.jam[tag=doc] 278include::../../src/tools/features/translate-path-feature.jam[tag=doc] 279include::../../src/tools/features/lto-feature.jam[tag=doc] 280 281[[bbv2.reference.tools]] 282== Builtin tools 283 284B2 comes with support for a large number of {CPP} compilers, and 285other tools. This section documents how to use those tools. 286 287Before using any tool, you must declare your intention, and possibly 288specify additional information about the tool's configuration. This is 289done by calling the `using` rule, typically in your `user-config.jam`, 290for example: 291 292[source] 293---- 294using gcc ; 295---- 296 297additional parameters can be passed just like for other rules, for 298example: 299 300[source] 301---- 302using gcc : 4.0 : g++-4.0 ; 303---- 304 305The options that can be passed to each tool are documented in the 306subsequent sections. 307 308[[bbv2.reference.tools.compilers]] 309=== {CPP} Compilers 310 311This section lists all B2 modules that support {CPP} compilers 312and documents how each one can be initialized. The name of support 313module for compiler is also the value for the `toolset` feature that can 314be used to explicitly request that compiler. 315 316:leveloffset: +3 317include::../../src/tools/acc.jam[tag=doc] 318include::../../src/tools/borland.jam[tag=doc] 319include::../../src/tools/como.jam[tag=doc] 320include::../../src/tools/cw.jam[tag=doc] 321include::../../src/tools/dmc.jam[tag=doc] 322include::../../src/tools/gcc.jam[tag=doc] 323include::../../src/tools/hp_cxx.jam[tag=doc] 324include::../../src/tools/intel.jam[tag=doc] 325include::../../src/tools/msvc.jam[tag=doc] 326include::../../src/tools/sun.jam[tag=doc] 327include::../../src/tools/vacpp.jam[tag=doc] 328:leveloffset: -3 329 330=== Third-party libraries 331 332B2 provides special support for some third-party {CPP} libraries, 333documented below. 334 335[[bbv2.reference.tools.libraries.stlport]] 336==== STLport library 337 338The http://stlport.org[STLport] library is an alternative implementation 339of {CPP} runtime library. B2 supports using that library on 340Windows platform. Linux is hampered by different naming of libraries in 341each STLport version and is not officially supported. 342 343Before using STLport, you need to configure it in `user-config.jam` 344using the following syntax: 345 346[source] 347---- 348using stlport : version : header-path : library-path ; 349---- 350 351Where version is the version of STLport, for example `5.1.4`, headers is 352the location where STLport headers can be found, and libraries is the 353location where STLport libraries can be found. The version should always 354be provided, and the library path should be provided if you're using 355STLport's implementation of `iostreams`. Note that STLport 5.* always uses 356its own `iostream` implementation, so the library path is required. 357 358When STLport is configured, you can build with STLport by requesting 359`stdlib=stlport` on the command line. 360 361[[bbv2.reference.tools.libraries.zlib]] 362==== zlib 363 364Provides support for the http://www.zlib.net[zlib] library. zlib can be 365configured either to use precompiled binaries or to build the library 366from source. 367 368zlib can be initialized using the following syntax 369 370[source] 371---- 372using zlib : version : options : condition : is-default ; 373---- 374 375Options for using a prebuilt library: 376 377`search`:: 378 The directory containing the zlib binaries. 379`name`:: 380 Overrides the default library name. 381`include`:: 382 The directory containing the zlib headers. 383 384If none of these options is specified, then the environmental variables 385ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will be used instead. 386 387Options for building zlib from source: 388 389`source`:: 390 The zlib source directory. Defaults to the environmental variable 391 ZLIB_SOURCE. 392`tag`:: 393 Sets the link:#bbv2.builtin.features.tag[tag] property to adjust the 394 file name of the library. Ignored when using precompiled binaries. 395`build-name`:: 396 The base name to use for the compiled library. Ignored when using 397 precompiled binaries. 398 399Examples: 400 401[source] 402---- 403# Find zlib in the default system location 404using zlib ; 405# Build zlib from source 406using zlib : 1.2.7 : <source>/home/steven/zlib-1.2.7 ; 407# Find zlib in /usr/local 408using zlib : 1.2.7 : <include>/usr/local/include <search>/usr/local/lib ; 409# Build zlib from source for msvc and find 410# prebuilt binaries for gcc. 411using zlib : 1.2.7 : <source>C:/Devel/src/zlib-1.2.7 : <toolset>msvc ; 412using zlib : 1.2.7 : : <toolset>gcc ; 413---- 414 415[[bbv2.reference.tools.libraries.bzip2]] 416==== bzip2 417 418Provides support for the http://www.bzip.org[bzip2] library. bzip2 can 419be configured either to use precompiled binaries or to build the library 420from source. 421 422bzip2 can be initialized using the following syntax 423 424[source] 425---- 426using bzip2 : version : options : condition : is-default ; 427---- 428 429Options for using a prebuilt library: 430 431`search`:: 432 The directory containing the bzip2 binaries. 433`name`:: 434 Overrides the default library name. 435`include`:: 436 The directory containing the bzip2 headers. 437 438If none of these options is specified, then the environmental variables 439BZIP2_LIBRARY_PATH, BZIP2_NAME, and BZIP2_INCLUDE will be used instead. 440 441Options for building bzip2 from source: 442 443`source`:: 444 The bzip2 source directory. Defaults to the environmental variable 445 BZIP2_SOURCE. 446`tag`:: 447 Sets the link:#bbv2.builtin.features.tag[tag] property to adjust the 448 file name of the library. Ignored when using precompiled binaries. 449`build-name`:: 450 The base name to use for the compiled library. Ignored when using 451 precompiled binaries. 452 453Examples: 454 455[source] 456---- 457# Find bzip in the default system location 458using bzip2 ; 459# Build bzip from source 460using bzip2 : 1.0.6 : <source>/home/sergey/src/bzip2-1.0.6 ; 461# Find bzip in /usr/local 462using bzip2 : 1.0.6 : <include>/usr/local/include <search>/usr/local/lib ; 463# Build bzip from source for msvc and find 464# prebuilt binaries for gcc. 465using bzip2 : 1.0.6 : <source>C:/Devel/src/bzip2-1.0.6 : <toolset>msvc ; 466using bzip2 : 1.0.6 : : <toolset>gcc ; 467---- 468 469[[bbv2.reference.tools.libraries.python]] 470==== Python 471 472Provides support for the http://www.python.org[python] language 473environment to be linked in as a library. 474 475python can be initialized using the following syntax 476 477[source] 478---- 479using python : [version] : [command-or-prefix] : [includes] : [libraries] : [conditions] : [extension-suffix] ; 480---- 481 482Options for using python: 483 484`version`:: 485The version of Python to use. Should be in Major.Minor format, for example 4862.3. Do not include the sub-minor version. 487 488`command-or-prefix`:: 489Preferably, a command that invokes a Python interpreter. Alternatively, the 490installation prefix for Python libraries and includes. If empty, will be 491guessed from the version, the platform's installation patterns, and the 492python executables that can be found in PATH. 493 494`includes`:: 495the include path to Python headers. If empty, will be guessed. 496 497`libraries`:: 498the path to Python library binaries. If empty, will be guessed. On 499MacOS/Darwin, you can also pass the path of the Python framework. 500 501`conditions`:: 502if specified, should be a set of properties that are matched against the 503build configuration when B2 selects a Python configuration to use. 504 505`extension-suffix`:: 506A string to append to the name of extension modules before the true filename 507extension. Ordinarily we would just compute this based on the value of the 508`<python-debugging>` feature. However ubuntu's `python-dbg` package uses the 509windows convention of appending _d to debug-build extension modules. We have 510no way of detecting ubuntu, or of probing python for the "_d" requirement, 511and if you configure and build python using `--with-pydebug`, you'll be using 512the standard *nix convention. Defaults to "" (or "_d" when targeting windows 513and <python-debugging> is set). 514 515Examples: 516 517[source] 518---- 519# Find python in the default system location 520using python ; 521# 2.7 522using python : 2.7 ; 523# 3.5 524using python : 3.5 ; 525 526# On ubuntu 16.04 527using python 528: 2.7 # version 529: # Interpreter/path to dir 530: /usr/include/python2.7 # includes 531: /usr/lib/x86_64-linux-gnu # libs 532: # conditions 533; 534 535using python 536: 3.5 # version 537: # Interpreter/path to dir 538: /usr/include/python3.5 # includes 539: /usr/lib/x86_64-linux-gnu # libs 540: # conditions 541; 542 543# On windows 544using python 545: 2.7 # version 546: C:\\Python27-32\\python.exe # Interperter/path to dir 547: C:\\Python27-32\\include # includes 548: C:\\Python27-32\\libs # libs 549: <address-model>32 <address-model> # conditions - both 32 and unspecified 550; 551 552using python 553: 2.7 # version 554: C:\\Python27-64\\python.exe # Interperter/path to dir 555: C:\\Python27-64\\include # includes 556: C:\\Python27-64\\libs # libs 557: <address-model>64 # conditions 558; 559---- 560 561=== Documentation tools 562 563B2 support for the Boost documentation tools is documented 564below. 565 566[[bbv2.reference.tools.doc.xsltproc]] 567==== xsltproc 568 569To use xsltproc, you first need to configure it using the following 570syntax: 571 572[source] 573---- 574using xsltproc : xsltproc ; 575---- 576 577Where xsltproc is the xsltproc executable. If xsltproc is not specified, 578and the variable XSLTPROC is set, the value of XSLTPROC will be used. 579Otherwise, xsltproc will be searched for in PATH. 580 581The following options can be provided, using 582_`<option-name>option-value syntax`_: 583 584`xsl:param`:: 585 Values should have the form name=value 586`xsl:path`:: 587 Sets an additional search path for xi:include elements. 588`catalog`:: 589 A catalog file used to rewrite remote URL's to a local copy. 590 591The xsltproc module provides the following rules. Note that these 592operate on jam targets and are intended to be used by another toolset, 593such as boostbook, rather than directly by users. 594 595`xslt`:: 596+ 597---- 598rule xslt ( target : source stylesheet : properties * ) 599---- 600+ 601Runs xsltproc to create a single output file. 602 603`xslt-dir`:: 604+ 605---- 606rule xslt-dir ( target : source stylesheet : properties * : dirname ) 607---- 608+ 609Runs xsltproc to create multiple outputs in a directory. `dirname` is 610unused, but exists for historical reasons. The output directory is 611determined from the target. 612 613[[bbv2.reference.tools.doc.boostbook]] 614==== boostbook 615 616To use boostbook, you first need to configure it using the following 617syntax: 618 619[source] 620---- 621using boostbook : docbook-xsl-dir : docbook-dtd-dir : boostbook-dir ; 622---- 623 624`docbook-xsl-dir` is the DocBook XSL stylesheet directory. If not 625provided, we use `DOCBOOK_XSL_DIR` from the environment (if available) or 626look in standard locations. Otherwise, we let the XML processor load the 627stylesheets remotely. 628 629`docbook-dtd-dir` is the DocBook DTD directory. If not provided, we use 630`DOCBOOK_DTD_DIR` From the environment (if available) or look in standard 631locations. Otherwise, we let the XML processor load the DTD remotely. 632 633`boostbook-dir` is the BoostBook directory with the DTD and XSL sub-dirs. 634 635The boostbook module depends on xsltproc. For pdf or ps output, it also 636depends on fop. 637 638The following options can be provided, using 639_`<option-name>option-value syntax`_: 640 641`format`:: 642+ 643*Allowed values:* `html`, `xhtml`, `htmlhelp`, `onehtml`, `man`, 644`pdf`, `ps`, `docbook`, `fo`, `tests`. 645+ 646The `format` feature determines the type of output produced by the 647boostbook rule. 648 649The boostbook module defines a rule for creating a target following the 650common syntax. 651 652`boostbook`:: 653+ 654---- 655rule boostbook ( target-name : sources * : requirements * : default-build * ) 656---- 657+ 658Creates a boostbook target. 659 660[[bbv2.reference.tools.doc.doxygen]] 661==== doxygen 662 663To use doxygen, you first need to configure it using the following 664syntax: 665 666[source] 667---- 668using doxygen : name ; 669---- 670 671`name` is the doxygen command. If it is not specified, it will be found in 672the PATH. 673 674The doxygen module depends on the boostbook module when generating 675BoostBook XML. 676 677The following options can be provided, using 678_`<option-name>option-value syntax`_: 679 680`doxygen:param`:: 681+ 682All the values of `doxygen:param` are added to the `doxyfile`. 683 684`prefix`:: 685+ 686Specifies the common prefix of all headers when generating BoostBook 687XML. Everything before this will be stripped off. 688 689`reftitle`:: 690+ 691Specifies the title of the library-reference section, when generating 692BoostBook XML. 693 694`doxygen:xml-imagedir`:: 695+ 696When generating BoostBook XML, specifies the directory in which to 697place the images generated from LaTex formulae. 698+ 699WARNING: The path is interpreted relative to the current working directory, 700not relative to the Jamfile. This is necessary to match the behavior of 701BoostBook. 702 703The doxygen module defines a rule for creating a target following the 704common syntax. 705 706`doxygen`:: 707+ 708---- 709rule doxygen ( target : sources * : requirements * : default-build * : usage-requirements * ) 710---- 711+ 712Creates a doxygen target. If the target name ends with .html, then 713this will generate an html directory. Otherwise it will generate 714BoostBook XML. 715 716[[bbv2.reference.tools.doc.quickbook]] 717==== quickbook 718 719The quickbook module provides a generator to convert from Quickbook to 720BoostBook XML. 721 722To use quickbook, you first need to configure it using the following 723syntax: 724 725[source] 726---- 727using quickbook : command ; 728---- 729 730`command` is the quickbook executable. If it is not specified, B2 731will compile it from source. If it is unable to find the source it will 732search for a quickbook executable in PATH. 733 734[[bbv2.reference.tools.doc.fop]] 735==== fop 736 737The fop module provides generators to convert from XSL formatting 738objects to Postscript and PDF. 739 740To use fop, you first need to configure it using the following syntax: 741 742[source] 743---- 744using fop : fop-command : java-home : java ; 745---- 746 747`fop-command` is the command to run fop. If it is not specified, 748B2 will search for it in PATH and FOP_HOME. 749 750Either `java-home` or `java` can be used to specify where to find java. 751 752[[bbv2.reference.modules]] 753== Builtin modules 754 755This section describes the modules that are provided by B2. The 756import rule allows rules from one module to be used in another module or 757Jamfile. 758 759[[bbv2.reference.modules.modules]] 760=== modules 761 762The `modules` module defines basic functionality for handling modules. 763 764A module defines a number of rules that can be used in other modules. 765Modules can contain code at the top level to initialize the module. This 766code is executed the first time the module is loaded. 767 768NOTE: A Jamfile is a special kind of module which is managed by the build 769system. Although they cannot be loaded directly by users, the other 770features of modules are still useful for Jamfiles. 771 772Each module has its own namespaces for variables and rules. If two 773modules A and B both use a variable named X, each one gets its own copy 774of X. They won't interfere with each other in any way. Similarly, 775importing rules into one module has no effect on any other module. 776 777Every module has two special variables. `$(__file__)` contains the name 778of the file that the module was loaded from and `$(__name__)` contains 779the name of the module. 780 781NOTE: `$(__file__)` does not contain the full path to the file. If you need 782this, use `modules.binding`. 783 7841. `rule binding ( module-name )` 785+ 786Returns the filesystem binding of the given module. 787+ 788For example, a module can get its own location with: 789+ 790[source,jam] 791---- 792me = [ modules.binding $(__name__) ] ; 793---- 794 7952. `rule poke ( module-name ? : variables + : value * )` 796+ 797Sets the module-local value of a variable. 798+ 799For example, to set a variable in the global module: 800+ 801[source,jam] 802---- 803modules.poke : ZLIB_INCLUDE : /usr/local/include ; 804---- 805 8063. `rule peek ( module-name ? : variables + )` 807+ 808Returns the module-local value of a variable. 809+ 810For example, to read a variable from the global module: 811+ 812[source,jam] 813---- 814local ZLIB_INCLUDE = [ modules.peek : ZLIB_INCLUDE ] ; 815---- 816 8174. `rule call-in ( module-name ? : rule-name args * : * )` 818+ 819Call the given rule locally in the given module. Use this for rules 820accepting rule names as arguments, so that the passed rule may be 821invoked in the context of the rule's caller (for example, if the rule 822accesses module globals or is a local rule). 823+ 824NOTE: rules called this way may accept at most 8 parameters. 825+ 826Example: 827+ 828[source,jam] 829---- 830rule filter ( f : values * ) 831{ 832 local m = [ CALLER_MODULE ] ; 833 local result ; 834 for v in $(values) 835 { 836 if [ modules.call-in $(m) : $(f) $(v) ] 837 { 838 result += $(v) ; 839 } 840 } 841 return result ; 842} 843---- 844 8455. `rule load ( module-name : filename ? : search * )` 846+ 847Load the indicated module if it is not already loaded. 848+ 849`module-name`:: 850 Name of module to load. 851+ 852`filename`:: 853 (partial) path to file; Defaults to `$(module-name).jam` 854+ 855`search`:: 856 Directories in which to search for filename. Defaults to 857 `$(BOOST_BUILD_PATH)`. 858 8596. `rule import ( module-names + : rules-opt * : rename-opt * )` 860+ 861Load the indicated module and import rule names into the current module. 862Any members of `rules-opt` will be available without qualification in 863the caller's module. Any members of `rename-opt` will be taken as the 864names of the rules in the caller's module, in place of the names they 865have in the imported module. If `rules-opt = '*'`, all rules from the 866indicated module are imported into the caller's module. If `rename-opt` 867is supplied, it must have the same number of elements as `rules-opt`. 868+ 869NOTE: The `import` rule is available without qualification in all modules. 870+ 871Examples: 872+ 873[source,jam] 874---- 875import path ; 876import path : * ; 877import path : join ; 878import path : native make : native-path make-path ; 879---- 880 8817. `rule clone-rules ( source-module target-module )` 882+ 883Define exported copies in `$(target-module)` of all rules exported from 884`$(source-module)`. Also make them available in the global module with 885qualification, so that it is just as though the rules were defined 886originally in `$(target-module)`. 887 888:leveloffset: +2 889 890include::path.adoc[] 891 892include::regex.adoc[] 893 894include::sequence.adoc[] 895 896include::../../src/tools/stage.jam[tag=doc] 897 898include::type.adoc[] 899 900:leveloffset: -2 901 902[[bbv2.reference.class]] 903== Builtin classes 904 905:leveloffset: +2 906 907include::abstract-target.adoc[] 908 909include::project-target.adoc[] 910 911include::main-target.adoc[] 912 913include::basic-target.adoc[] 914 915include::typed-target.adoc[] 916 917include::property-set.adoc[] 918 919:leveloffset: -2 920 921[[bbv2.reference.buildprocess]] 922== Build process 923 924The general overview of the build process was given in the 925link:#bbv2.overview.build_process[user documentation]. This section 926provides additional details, and some specific rules. 927 928To recap, building a target with specific properties includes the 929following steps: 930 9311. applying the default build, 9322. selecting the main target alternative to use, 9333. determining the "common" properties, 9344. building targets referred by the the sources list and dependency 935properties, 9365. adding the usage requirements produced when building dependencies to 937the "common" properties, 9386. building the target using generators, 9397. computing the usage requirements to be returned. 940 941[[bbv2.reference.buildprocess.alternatives]] 942=== Alternative selection 943 944When a target has several alternatives, one of them must be selected. 945The process is as follows: 946 9471. For each alternative, its _condition_ is defined as the set of 948link:#bbv2.reference.features.attributes.base[base properties] in its 949requirements. link:#bbv2.reference.variants.propcond[Conditional 950properties] are excluded. 951 9522. An alternative is viable only if all properties in its condition are 953present in the build request. 954 9553. If there's only one viable alternative, it's chosen. Otherwise, an 956attempt is made to find the best alternative. An alternative a is better 957than another alternative b, if the set of properties in b's condition is 958a strict subset of the set of properties of a's condition. If one viable 959alternative is better than all the others, it's selected. Otherwise, an 960error is reported. 961 962[[bbv2.reference.buildprocess.common]] 963=== Determining common properties 964 965"Common" properties is a somewhat artificial term. This is the 966intermediate property set from which both the build request for 967dependencies and the properties for building the target are derived. 968 969Since the default build and alternatives are already handled, we have 970only two inputs: the build request and the requirements. Here are the 971rules about common properties. 972 9731. Non-free features can have only one value 974 9752. A non-conditional property in the requirements is always present in 976common properties. 977 9783. A property in the build request is present in common properties, 979unless it is overridden by a property in the requirements. 980 9814. If either the build request, or the requirements (non-conditional or 982conditional) include an expandable property (either composite, or with a 983specified sub-feature value), the behavior is equivalent to explicitly 984adding all the expanded properties to the build request or the 985requirements respectively. 986 9875. If the requirements include a 988link:#bbv2.reference.variants.propcond[conditional property], and the 989condition of this property is true in the context of common properties, 990then the conditional property should be in common properties as well. 991 9926. If no value for a feature is given by other rules here, it has 993default value in common properties. 994 995These rules are declarative. They don't specify how to compute the 996common properties. However, they provide enough information for the 997user. The important point is the handling of conditional requirements. 998The condition can be satisfied either by a property in the build 999request, by non-conditional requirements, or even by another conditional 1000property. For example, the following example works as expected: 1001 1002[source] 1003---- 1004exe a : a.cpp 1005 : <toolset>gcc:<variant>release 1006 <variant>release:<define>FOO ; 1007---- 1008 1009[[bbv2.reference.buildprocess.targetpath]] 1010=== Target Paths 1011 1012Several factors determine the location of a concrete file target. All 1013files in a project are built under the directory bin unless this is 1014overridden by the build-dir project attribute. Under bin is a path that 1015depends on the properties used to build each target. This path is 1016uniquely determined by all non-free, non-incidental properties. For 1017example, given a property set containing: `<toolset>gcc` 1018`<toolset-gcc:version>4.6.1` `<variant>debug` `<warnings>all` `<define>_DEBUG` 1019`<include>/usr/local/include` `<link>static`, the path will be 1020`gcc-4.6.1/debug/link-static`. `<warnings>` is an incidental feature and 1021`<define>` and `<include>` are free features, so they do not affect the path. 1022 1023Sometimes the paths produced by B2 can become excessively long. 1024There are a couple of command line options that can help with this. 1025`--abbreviate-paths` reduces each element to no more than five characters. 1026For example, `link-static` becomes `lnk-sttc`. The `--hash` option reduces the 1027path to a single directory using an MD5 hash. 1028 1029There are two features that affect the build directory. The `<location>` 1030feature completely overrides the default build directory. For example, 1031 1032[source] 1033---- 1034exe a : a.cpp : <location>. ; 1035---- 1036 1037builds all the files produced by `a` in the directory of the Jamfile. 1038This is generally discouraged, as it precludes variant builds. 1039 1040The <location-prefix> feature adds a prefix to the path, under the 1041project's build directory. For example, 1042 1043[source] 1044---- 1045exe a : a.cpp : <location-prefix>subdir ; 1046---- 1047 1048will create the files for `a` in `bin/subdir/gcc-4.6.1/debug` 1049 1050[[bbv2.reference.definitions]] 1051== Definitions 1052 1053[[bbv2.reference.features]] 1054=== Features and properties 1055 1056A _feature_ is a normalized (toolset-independent) aspect of a build 1057configuration, such as whether inlining is enabled. Feature names may 1058not contain the '`>`' character. 1059 1060Each feature in a build configuration has one or more associated 1061__value__s. Feature values for non-free features may not contain the 1062punctuation characters of pointy bracket (‘`<`’), colon (‘`:`’ ), 1063equal sign (‘`=`’) and dashes (‘`-`’). Feature values for free 1064features may not contain the pointy bracket (‘`<`’) character. 1065 1066A _property_ is a (feature,value) pair, expressed as <feature>value. 1067 1068A _subfeature_ is a feature that only exists in the presence of its 1069parent feature, and whose identity can be derived (in the context of its 1070parent) from its value. A subfeature's parent can never be another 1071subfeature. Thus, features and their subfeatures form a two-level 1072hierarchy. 1073 1074A _value-string_ for a feature *F* is a string of the form 1075`value-subvalue1-subvalue2`...`-subvalueN`, where `value` is a legal 1076value for *F* and `subvalue1`...`subvalueN` are legal values of some of 1077*F*'s subfeatures separated with dashes (‘`-`’). 1078For example, the properties `<toolset>gcc <toolset-version>3.0.1` can 1079be expressed more concisely using a value-string, as `<toolset>gcc-3.0.1`. 1080 1081A _property set_ is a set of properties (i.e. a collection without 1082duplicates), for instance: `<toolset>gcc <runtime-link>static`. 1083 1084A _property path_ is a property set whose elements have been joined into 1085a single string separated by slashes. A property path representation of 1086the previous example would be `<toolset>gcc/<runtime-link>static`. 1087 1088A _build specification_ is a property set that fully describes the set 1089of features used to build a target. 1090 1091[[bbv2.reference.features.validity]] 1092=== Property Validity 1093 1094For link:#bbv2.reference.features.attributes.free[free] features, all 1095values are valid. For all other features, the valid values are 1096explicitly specified, and the build system will report an error for the 1097use of an invalid feature-value. Subproperty validity may be restricted 1098so that certain values are valid only in the presence of certain other 1099subproperties. For example, it is possible to specify that the 1100`<gcc-target>mingw` property is only valid in the presence of 1101`<gcc-version>2.95.2`. 1102 1103[[bbv2.reference.features.attributes]] 1104=== Feature Attributes 1105 1106Each feature has a collection of zero or more of the following 1107attributes. Feature attributes are low-level descriptions of how the 1108build system should interpret a feature's values when they appear in a 1109build request. We also refer to the attributes of properties, so that an 1110_incidental_ property, for example, is one whose feature has the 1111_incidental_ attribute. 1112 1113* [[bbv2.reference.features.attributes.incidental]] _incidental_ 1114+ 1115Incidental features are assumed not to affect build products at all. As 1116a consequence, the build system may use the same file for targets whose 1117build specification differs only in incidental features. A feature that 1118controls a compiler's warning level is one example of a likely 1119incidental feature. 1120+ 1121Non-incidental features are assumed to affect build products, so the 1122files for targets whose build specification differs in non-incidental 1123features are placed in different directories as described in 1124<<bbv2.reference.buildprocess.targetpath>>. 1125 1126* [[bbv2.reference.features.attributes.propagated]] _propagated_ 1127+ 1128Features of this kind are propagated to dependencies. That is, if a 1129link:#bbv2.overview.targets.main[main target] is built using a 1130propagated property, the build systems attempts to use the same property 1131when building any of its dependencies as part of that main target. For 1132instance, when an optimized executable is requested, one usually wants 1133it to be linked with optimized libraries. Thus, the `<optimization>` 1134feature is propagated. 1135 1136* [[bbv2.reference.features.attributes.free]] _free_ 1137+ 1138Most features have a finite set of allowed values, and can only take on 1139a single value from that set in a given build specification. Free 1140features, on the other hand, can have several values at a time and each 1141value can be an arbitrary string. For example, it is possible to have 1142several preprocessor symbols defined simultaneously: 1143+ 1144---- 1145<define>NDEBUG=1 <define>HAS_CONFIG_H=1 1146---- 1147 1148* [[bbv2.reference.features.attributes.optional]] _optional_ 1149+ 1150An optional feature is a feature that is not required to appear in a 1151build specification. Every non-optional non-free feature has a default 1152value that is used when a value for the feature is not otherwise 1153specified, either in a target's requirements or in the user's build 1154request. [A feature's default value is given by the first value listed 1155in the feature's declaration. -- move this elsewhere - dwa] 1156 1157* [[bbv2.reference.features.attributes.symmetric]] _symmetric_ 1158+ 1159Normally a feature only generates a sub-variant directory when its value 1160differs from its default value, leading to an asymmetric sub-variant 1161directory structure for certain values of the feature. A symmetric 1162feature always generates a corresponding sub-variant directory. 1163 1164* [[bbv2.reference.features.attributes.path]] _path_ 1165+ 1166The value of a path feature specifies a path. The path is treated as 1167relative to the directory of Jamfile where path feature is used and is 1168translated appropriately by the build system when the build is invoked 1169from a different directory 1170 1171* [[bbv2.reference.features.attributes.implicit]] _implicit_ 1172+ 1173Values of implicit features alone identify the feature. For example, a 1174user is not required to write "<toolset>gcc", but can simply write 1175"gcc". Implicit feature names also don't appear in variant paths, 1176although the values do. Thus: bin/gcc/... as opposed to 1177bin/toolset-gcc/.... There should typically be only a few such features, 1178to avoid possible name clashes. 1179 1180* [[bbv2.reference.features.attributes.composite]] _composite_ 1181+ 1182Composite features actually correspond to groups of properties. For 1183example, a build variant is a composite feature. When generating targets 1184from a set of build properties, composite features are recursively 1185expanded and _added_ to the build property set, so rules can find them 1186if necessary. Non-composite non-free features override components of 1187composite features in a build property set. 1188 1189* [[bbv2.reference.features.attributes.dependency]] _dependency_ 1190+ 1191The value of a dependency feature is a target reference. When used for 1192building of a main target, the value of dependency feature is treated as 1193additional dependency. 1194+ 1195For example, dependency features allow to state that library A depends 1196on library B. As the result, whenever an application will link to A, it 1197will also link to B. Specifying B as dependency of A is different from 1198adding B to the sources of A. 1199 1200[[bbv2.reference.features.attributes.base]] 1201Features that are neither free nor incidental are called _base_ 1202features. 1203 1204[[bbv2.reference.features.declaration]] 1205=== Feature Declaration 1206 1207The low-level feature declaration interface is the `feature` rule from 1208the `feature` module: 1209 1210[source] 1211---- 1212rule feature ( name : allowed-values * : attributes * ) 1213---- 1214 1215A feature's allowed-values may be extended with the `feature.extend` 1216rule. 1217 1218[[bbv2.reference.variants.proprefine]] 1219=== Property refinement 1220 1221When a target with certain properties is requested, and that target 1222requires some set of properties, it is needed to find the set of 1223properties to use for building. This process is called _property 1224refinement_ and is performed by these rules 1225 12261. Each property in the required set is added to the original property 1227set 1228 12292. If the original property set includes property with a different 1230value of non free feature, that property is removed. 1231 1232[[bbv2.reference.variants.propcond]] 1233=== Conditional properties 1234 1235Sometime it's desirable to apply certain requirements only for a 1236specific combination of other properties. For example, one of compilers 1237that you use issues a pointless warning that you want to suppress by 1238passing a command line option to it. You would not want to pass that 1239option to other compilers. Conditional properties allow you to do just 1240that. Their syntax is: 1241 1242.... 1243property ( "," property ) * ":" property 1244.... 1245 1246For example, the problem above would be solved by: 1247 1248[source] 1249---- 1250exe hello : hello.cpp : <toolset>yfc:<cxxflags>-disable-pointless-warning ; 1251---- 1252 1253The syntax also allows several properties in the condition, for example: 1254 1255[source] 1256---- 1257exe hello : hello.cpp : <os>NT,<toolset>gcc:<link>static ; 1258---- 1259 1260[[bbv2.reference.ids]] 1261=== Target identifiers and references 1262 1263_Target identifier_ is used to denote a target. The syntax is: 1264 1265.... 1266target-id -> (target-name | file-name | project-id | directory-name) 1267 | (project-id | directory-name) "//" target-name 1268project-id -> path 1269target-name -> path 1270file-name -> path 1271directory-name -> path 1272.... 1273 1274This grammar allows some elements to be recognized as either 1275 1276* name of target declared in current Jamfile (note that target names may 1277include slash). 1278* a regular file, denoted by absolute name or name relative to project's 1279sources location. 1280* project id (at this point, all project ids start with slash). 1281* the directory of another project, denoted by absolute name or name 1282relative to the current project's location. 1283 1284To determine the real meaning the possible interpretations are checked 1285in this order. For example, valid target ids might be: 1286 1287|=== 1288| `a` | target in current project 1289| `lib/b.cpp` | regular file 1290| `/boost/thread` | project "/boost/thread" 1291| `/home/ghost/build/lr_library//parser` | target in specific project 1292| `../boost_1_61_0` | project in specific directory 1293|=== 1294 1295**Rationale:**Target is separated from project by special separator (not 1296just slash), because: 1297 1298* It emphasis that projects and targets are different things. 1299* It allows to have main target names with slashes. 1300 1301[[bbv2.reference.targets.references]] 1302_Target reference_ is used to specify a source target, and may 1303additionally specify desired properties for that target. It has this 1304syntax: 1305 1306.... 1307target-reference -> target-id [ "/" requested-properties ] 1308requested-properties -> property-path 1309.... 1310 1311For example, 1312 1313[source] 1314---- 1315exe compiler : compiler.cpp libs/cmdline/<optimization>space ; 1316---- 1317 1318would cause the version of `cmdline` library, optimized for space, to be 1319linked in even if the `compiler` executable is build with optimization 1320for speed. 1321