1 # Copyright Vladimir Prus 2002-2006.
2 # Copyright Dave Abrahams 2005-2006.
3 # Copyright Rene Rivera 2005-2007.
4 # Copyright Douglas Gregor 2005.
6 # Distributed under the Boost Software License, Version 1.0.
7 # (See accompanying file LICENSE_1_0.txt or copy at
8 # http://www.boost.org/LICENSE_1_0.txt)
12 # bjam [options] [properties] [install|stage]
14 # Builds and installs Boost.
16 # Targets and Related Options:
18 # install Install headers and compiled library files to the
19 # ======= configured locations (below).
21 # --prefix=<PREFIX> Install architecture independent files here.
22 # Default; C:\Boost on Win32
23 # Default; /usr/local on Unix. Linux, etc.
25 # --exec-prefix=<EPREFIX> Install architecture dependent files here.
28 # --libdir=<DIR> Install library files here.
29 # Default; <EPREFIX>/lib
31 # --includedir=<HDRDIR> Install header files here.
32 # Default; <PREFIX>/include
34 # stage Build and install only compiled library files
35 # ===== to the stage directory.
37 # --stagedir=<STAGEDIR> Install library files here
42 # --build-type=<type> Build the specified pre-defined set of variations
43 # of the libraries. Note, that which variants get
44 # built depends on what each library supports.
46 # minimal (default) - Builds a minimal set of
47 # variants. On Windows, these are static
48 # multithreaded libraries in debug and release
49 # modes, using shared runtime. On Linux, these
50 # are static and shared multithreaded libraries
53 # complete - Build all possible variations.
55 # --build-dir=DIR Build in this location instead of building
56 # within the distribution tree. Recommended!
58 # --show-libraries Displays the list of Boost libraries that require
59 # build and installation steps, then exit.
61 # --layout=<layout> Determines whether to choose library names
62 # and header locations such that multiple
63 # versions of Boost or multiple compilers can
64 # be used on the same system.
66 # versioned - Names of boost binaries
67 # include the Boost version number, name and
68 # version of the compiler and encoded build
69 # properties. Boost headers are installed in a
70 # subdirectory of <HDRDIR> whose name contains
71 # the Boost version number.
73 # tagged -- Names of boost binaries include the
74 # encoded build properties such as variant and
75 # threading, but do not including compiler name
76 # and version, or Boost version. This option is
77 # useful if you build several variants of Boost,
78 # using the same compiler.
80 # system - Binaries names do not include the
81 # Boost version number or the name and version
82 # number of the compiler. Boost headers are
83 # installed directly into <HDRDIR>. This option
84 # is intended for system integrators who are
85 # building distribution packages.
87 # The default value is 'versioned' on Windows, and
90 # --buildid=ID Adds the specified ID to the name of built
91 # libraries. The default is to not add anything.
93 # --python-buildid=ID Adds the specified ID to the name of built
94 # libraries that depend on Python. The default
95 # is to not add anything. This ID is added in
96 # addition t --buildid.
99 # --help This message.
101 # --with-<library> Build and install the specified <library>
102 # If this option is used, only libraries
103 # specified using this option will be built.
105 # --without-<library> Do not build, stage, or install the specified
106 # <library>. By default, all libraries are built.
110 # toolset=toolset Indicates the toolset to build with.
112 # variant=debug|release Select the build variant
114 # link=static|shared Whether to build static or shared libraries
116 # threading=single|multi Whether to build single or multithreaded binaries
118 # runtime-link=static|shared
119 # Whether to link to static or shared C and C++ runtime.
123 # - handle boost version
124 # - handle python options such as pydebug
136 import "class" : new ;
144 import build-system ;
147 path-constant BOOST_ROOT : . ;
148 constant BOOST_VERSION : 1.46.1 ;
149 constant BOOST_JAMROOT_MODULE : $(__name__) ;
151 local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ]
153 if $(version-tag[3]) = 0
155 version-tag = $(version-tag[1-2]) ;
158 constant BOOST_VERSION_TAG : $(version-tag:J="_") ;
160 # Option to choose how many variants to build. The default is "minimal".
161 local build-type = [ MATCH "^--build-type=(.*)" : [ modules.peek : ARGV ] ] ;
162 build-type ?= minimal ;
163 if ! ( $(build-type) in minimal complete )
165 ECHO "The value of the --build-type option should be either 'complete' or 'minimal'" ;
169 rule handle-static-runtime ( properties * )
171 # Using static runtime with shared libraries is impossible on Linux,
172 # and dangerous on Windows. Therefore, we disallow it. This might
173 # be drastic, but it was disabled for a while with nobody complaining.
175 # For CW, static runtime is needed so that std::locale works.
176 if <link>shared in $(properties) && <runtime-link>static in $(properties) &&
177 ! ( <toolset>cw in $(properties) )
179 ECHO "error: link=shared together with runtime-link=static is not allowed" ;
180 ECHO "error: such property combination is either impossible " ;
181 ECHO "error: or too dangerious to be of any use" ;
188 : requirements <include>.
189 # Disable auto-linking for all targets here, primarily because it caused
191 <define>BOOST_ALL_NO_LIB=1
192 # Used to encode variant in target name. See the 'tag' rule below.
193 <tag>@$(__name__).tag
194 <conditional>@handle-static-runtime
195 # The standard library Sun compilers use by default has no chance
196 # of working with Boost. Override it.
197 <toolset>sun:<stdlib>sun-stlport
198 # Comeau does not support shared lib
199 <toolset>como:<link>static
200 <toolset>como-linux:<define>_GNU_SOURCE=1
201 # When building docs within Boost, we want the standard Boost style
202 <xsl:param>boost.defaults=Boost
203 : usage-requirements <include>.
208 # Setup convenient aliases for all libraries.
210 all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
211 [ glob libs/*/build/Jamfile ] ]
214 all-libraries = [ sequence.unique $(all-libraries) ] ;
215 # The function_types library has a Jamfile, but it's used for maintenance
216 # purposes, there's no library to build and install.
217 all-libraries = [ set.difference $(all-libraries) : function_types ] ;
219 configure.register-components $(all-libraries) ;
221 local rule explicit-alias ( id : targets + )
223 alias $(id) : $(targets) ;
228 # First, the complicated libraries: where the target name in Jamfile is
229 # different from its directory name.
230 explicit-alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
231 explicit-alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
232 explicit-alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
233 explicit-alias bgl-vis : libs/graps/build//bgl-vis ;
234 explicit-alias serialization : libs/serialization/build//boost_serialization ;
235 explicit-alias wserialization : libs/serialization/build//boost_wserialization ;
236 for local l in $(all-libraries)
238 if ! $(l) in test graph serialization
240 explicit-alias $(l) : libs/$(l)/build//boost_$(l) ;
244 alias headers : : : : <include>. ;
247 # Decides which libraries are to be installed by looking at --with-<library>
248 # --without-<library> arguments. Returns the list of directories under "libs"
249 # which must be built and installed.
251 rule libraries-to-install ( existing-libraries * )
253 local argv = [ modules.peek : ARGV ] ;
254 local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
255 local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;
257 if ! $(with-parameter) && ! $(without-parameter)
259 # Nothing is specified on command line. See if maybe
260 # project-config.jam has some choices.
261 local project-config-libs = [ modules.peek project-config : libraries ] ;
262 with-parameter = [ MATCH --with-(.*) : $(project-config-libs) ] ;
263 without-parameter = [ MATCH --without-(.*) : $(project-config-libs) ] ;
267 if $(with-parameter) && $(without-parameter)
269 ECHO "error: both --with-<library> and --without-<library> specified" ;
273 local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
276 ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
279 local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
282 ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
288 return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
292 return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
297 # What kind of layout are we doing?
298 layout = [ option.get layout : "" ] ;
299 # On Windows, we used versioned layout by default in order to
300 # be compatible with autolink. On other systems, we use system
301 # layout which is what every other program uses. Note that windows
302 # check is static, and won't
305 if [ modules.peek : NT ]
314 layout-$(layout) = true ;
316 if $(layout) = system && $(build-type) = complete
318 ECHO "error: Cannot use --layout=system with --build-type complete." ;
319 ECHO "error: Please used either --layout=versioned or --layout=tagged " ;
320 ECHO "error: if you wish to build multiple variants." ;
321 if ! [ modules.peek : NT ]
323 ECHO "error: Note that --layout=system is default on Unix starting with Boost 1.40." ;
328 # Possible stage only location.
329 local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ;
330 stage-locate ?= stage ;
331 path-constant BOOST_STAGE_LOCATE : $(stage-locate) ;
335 local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ]
337 PYTHON_ROOT ?= $(python-root) ;
340 # Select the libraries to install.
341 libraries = [ libraries-to-install $(all-libraries) ] ;
342 configure.components-building $(libraries) ;
344 if --show-libraries in [ modules.peek : ARGV ]
346 ECHO "The following libraries require building:" ;
347 for local l in $(libraries)
355 local build-id = [ MATCH "^--buildid=(.*)" : [ modules.peek : ARGV ] ] ;
358 constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ;
361 # Python build id (only for Python libraries)
362 local python-id = [ MATCH "^--python-buildid=(.*)" : [ modules.peek : ARGV ] ] ;
365 constant PYTHON_ID : [ regex.replace $(python-id) "[*\\/:.\"\']" "_" ] ;
368 # This rule is called by Boost.Build to determine the name of target. We use it
369 # to encode the build variant, compiler name and boost version in the target
372 rule tag ( name : type ? : property-set )
374 if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
377 if $(layout) = versioned
379 result = [ common.format-name
380 <base> <toolset> <threading> <runtime> -$(BOOST_VERSION_TAG)
382 : $(name) : $(type) : $(property-set) ] ;
384 else if $(layout) = tagged
386 result = [ common.format-name
387 <base> <threading> <runtime>
389 : $(name) : $(type) : $(property-set) ] ;
391 else if $(layout) = system
393 result = [ common.format-name
396 : $(name) : $(type) : $(property-set) ] ;
400 ECHO "error: invalid layout '$(layout)'" ;
404 # Optionally add version suffix. On NT, library with version suffix
405 # will not be recognized by linkers. On CYGWIN, we get strage
406 # duplicate symbol errors when library is generated with version
407 # suffix. On OSX, version suffix is not needed -- the linker expects
408 # the libFoo.1.2.3.dylib format. AIX linkers do not accept version
409 # suffixes either. Pgi compilers can not accept library with version
411 if $(type) = SHARED_LIB &&
412 ( ! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix ) &&
413 ! ( [ $(property-set).get <toolset> ] in pgi ) )
415 result = $(result).$(BOOST_VERSION) ;
423 # Install to system location.
425 install-requirements = <install-source-root>$(BOOST_ROOT)/boost ;
427 if $(layout-versioned)
429 install-requirements += <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
433 install-requirements += <install-header-subdir>boost ;
435 if [ modules.peek : NT ]
437 install-requirements += <install-default-prefix>C:/Boost ;
439 else if [ modules.peek : UNIX ]
441 install-requirements += <install-default-prefix>/usr/local ;
445 # The .SUNWCCh files are present in tr1 include directory and have to be installed,
446 # see http://lists.boost.org/Archives/boost/2007/05/121430.php
447 [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ]
448 [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ]
449 [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ]
453 package.install install-proper
454 : $(install-requirements) <install-no-version-symlinks>on
456 : libs/$(libraries)/build
459 explicit install-proper ;
461 # Install just library.
463 : libs/$(libraries)/build
464 : <location>$(stage-locate)/lib
465 <install-dependencies>on <install-type>LIB
466 <install-no-version-symlinks>on
468 explicit stage-proper ;
471 if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] )
473 rule make-unversioned-links ( project name ? : property-set : sources * )
478 local nt = [ modules.peek : NT ] ;
480 # Collect the libraries that have the version number in 'filtered'.
481 for local s in $(sources)
486 m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ;
490 m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]dylib)" "(.*[.]a)" :
499 # Create links without version.
500 for local s in $(filtered)
502 local name = [ $(s).name ] ;
503 local ea = [ $(s).action ] ;
504 local ep = [ $(ea).properties ] ;
505 local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ;
507 local noversion-file ;
510 noversion-file = [ MATCH "(.*)-[0-9_]+(.*[.]lib)" : $(name) ] ;
515 [ MATCH "(.*)-[0-9_]+(.*[.]so)[.0-9]*" : $(name) ]
516 [ MATCH "(.*)-[0-9_]+(.*[.]dylib)" : $(name) ]
517 [ MATCH "(.*)-[0-9_]+(.*[.]a)" : $(name) ]
518 [ MATCH "(.*)-[0-9_]+(.*[.]dll[.]a)" : $(name) ] ;
522 $(noversion-file[1])$(noversion-file[2]) ;
523 result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project)
530 generate stage-unversioned : stage-proper :
531 <generating-rule>@make-unversioned-links ;
532 explicit stage-unversioned ;
534 generate install-unversioned : install-proper :
535 <generating-rule>@make-unversioned-links ;
536 explicit install-unversioned ;
540 # Create do-nothing aliases.
541 alias stage-unversioned ;
542 explicit stage-unversioned ;
543 alias install-unversioned ;
544 explicit install-unversioned ;
547 # This is a special metatarget class that handles the --build-type=complete
549 class top-level-target : alias-target-class
554 rule __init__ ( name : project : sources * : requirements *
555 : default-build * : usage-requirements * )
557 alias-target-class.__init__ $(name) : $(project) : $(sources) :
558 $(requirements) : $(default-build) : $(usage-requirements) ;
560 local m = [ $(project).project-module ] ;
561 self.build-type = [ modules.peek $(m) : build-type ] ;
562 # On Linux, we build release variant by default, since few users will
563 # ever want to debug C++ Boost libraries, and there's no ABI
564 # incompatibility between debug and release variants. We build
565 # shared and static libraries since that's what most packages
566 # seem to provide (.so in libfoo and .a in libfoo-dev).
567 self.minimal-properties = [ property-set.create
568 <variant>release <threading>multi <link>shared <link>static <runtime-link>shared ] ;
569 # On Windows, new IDE projects use:
571 # runtime-link=dynamic, threading=multi, variant=(debug|release)
573 # and in addition, C++ Boost's autolink defaults to static linking.
574 self.minimal-properties-win = [ property-set.create
575 <variant>debug <variant>release <threading>multi <link>static <runtime-link>shared ] ;
577 self.complete-properties = [ property-set.create
578 <variant>debug <variant>release
579 <threading>single <threading>multi
580 <link>shared <link>static
581 <runtime-link>shared <runtime-link>static ] ;
584 rule generate ( property-set )
586 local x = [ modules.peek : top-level-targets ] ;
588 modules.poke : top-level-targets : $(x) ;
589 if $(self.build-type) = minimal
593 local os = [ $(property-set).get <target-os> ] ;
594 # Because we completely override parent's 'generate'
595 # we need to check for default value of feature ourself.
598 os = [ feature.defaults <target-os> ] ;
604 expanded = [ targets.apply-default-build $(property-set)
605 : $(self.minimal-properties-win) ] ;
609 expanded = [ targets.apply-default-build $(property-set)
610 : $(self.minimal-properties) ] ;
612 return [ build-multiple $(expanded) ] ;
614 else if $(self.build-type) = complete
616 local expanded = [ targets.apply-default-build $(property-set)
617 : $(self.complete-properties) ] ;
619 # Filter inappopriate combinations
621 for local p in $(expanded)
623 # See comment in handle-static-runtime regarding this logic.
624 if [ $(p).get <link> ] = shared && [ $(p).get <runtime-link> ] = static
625 && [ $(p).get <toolset> ] != cw
634 return [ build-multiple $(filtered) ] ;
638 errors.error "Unknown build type" ;
642 rule build-multiple ( property-sets * )
644 local usage-requirements = [ property-set.empty ] ;
646 for local p in $(property-sets)
648 local r = [ alias-target-class.generate $(p) ] ;
651 usage-requirements = [ $(usage-requirements).add $(r[1]) ] ;
655 return $(usage-requirements) [ sequence.unique $(result) ] ;
660 targets.create-metatarget top-level-target : [ project.current ]
662 : install-proper install-unversioned
664 targets.create-metatarget top-level-target : [ project.current ]
666 : stage-proper stage-unversioned
672 stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ;
674 # This target is built by default, and will forward to 'stage'
675 # after producing some explanations.
676 targets.create-metatarget top-level-target : [ project.current ]
683 "\nBuilding the Boost C++ Libraries.\n\n" ;
688 local tl = [ modules.peek : top-level-targets ] ;
689 if stage in $(tl) || install in $(tl)
691 # FIXME: remove if when Boost regression tests use trunk
693 if PAD in [ RULENAMES ]
695 configure.print-component-configuration ;
699 IMPORT $(__name__) : pre-build : : $(__name__).pre-build ;
700 build-system.set-pre-build-hook $(__name__).pre-build ;
702 rule post-build ( ok ? )
704 if forward in [ modules.peek : top-level-targets ]
709 "\n\nThe Boost C++ Libraries were successfully built!
711 The following directory should be added to compiler include paths:
715 The following directory should be added to linker library paths:
722 IMPORT $(__name__) : post-build : : $(__name__).post-build ;
723 build-system.set-post-build-hook $(__name__).post-build ;
725 # This rule should be called from libraries' Jamfiles and will create two
726 # targets, "install" and "stage", that will install or stage that library. The
727 # --prefix option is respected, but --with and --without options, naturally, are
730 # - libraries -- list of library targets to install.
732 rule boost-install ( libraries * )
734 package.install install
735 : <dependency>/boost//install-proper-headers $(install-requirements)
738 : # No headers, it is handled by the dependency.
741 install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
743 local c = [ project.current ] ;
744 local project-module = [ $(c).project-module ] ;
745 module $(project-module)
753 # Make project ids of all libraries known.
754 for local l in $(all-libraries)
756 use-project /boost/$(l) : libs/$(l)/build ;