• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright Vladimir Prus 2002-2006.
2# Copyright Dave Abrahams 2005-2006.
3# Copyright Rene Rivera 2005-2007.
4# Copyright Douglas Gregor 2005.
5#
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)
9
10# Usage:
11#
12#   b2 [options] [properties] [install|stage]
13#
14#   Builds and installs Boost.
15#
16# Targets and Related Options:
17#
18#   install                 Install headers and compiled library files to the
19#   =======                 configured locations (below).
20#
21#   --prefix=<PREFIX>       Install architecture independent files here.
22#                           Default: C:\Boost on Windows
23#                           Default: /usr/local on Unix, Linux, etc.
24#
25#   --exec-prefix=<EPREFIX> Install architecture dependent files here.
26#                           Default: <PREFIX>
27#
28#   --libdir=<LIBDIR>       Install library files here.
29#                           Default: <EPREFIX>/lib
30#
31#   --includedir=<HDRDIR>   Install header files here.
32#                           Default: <PREFIX>/include
33#
34#   --cmakedir=<CMAKEDIR>   Install CMake configuration files here.
35#                           Default: <LIBDIR>/cmake
36#
37#   --no-cmake-config       Do not install CMake configuration files.
38#
39#   stage                   Build and install only compiled library files to the
40#   =====                   stage directory.
41#
42#   --stagedir=<STAGEDIR>   Install library files here
43#                           Default: ./stage
44#
45# Other Options:
46#
47#   --build-type=<type>     Build the specified pre-defined set of variations of
48#                           the libraries. Note, that which variants get built
49#                           depends on what each library supports.
50#
51#                               -- minimal -- (default) Builds a minimal set of
52#                               variants. On Windows, these are static
53#                               multithreaded libraries in debug and release
54#                               modes, using shared runtime. On Linux, these are
55#                               static and shared multithreaded libraries in
56#                               release mode.
57#
58#                               -- complete -- Build all possible variations.
59#
60#   --build-dir=DIR         Build in this location instead of building within
61#                           the distribution tree. Recommended!
62#
63#   --show-libraries        Display the list of Boost libraries that require
64#                           build and installation steps, and then exit.
65#
66#   --layout=<layout>       Determine whether to choose library names and header
67#                           locations such that multiple versions of Boost or
68#                           multiple compilers can be used on the same system.
69#
70#                               -- versioned -- Names of boost binaries include
71#                               the Boost version number, name and version of
72#                               the compiler and encoded build properties. Boost
73#                               headers are installed in a subdirectory of
74#                               <HDRDIR> whose name contains the Boost version
75#                               number.
76#
77#                               -- tagged -- Names of boost binaries include the
78#                               encoded build properties such as variant and
79#                               threading, but do not including compiler name
80#                               and version, or Boost version. This option is
81#                               useful if you build several variants of Boost,
82#                               using the same compiler.
83#
84#                               -- system -- Binaries names do not include the
85#                               Boost version number or the name and version
86#                               number of the compiler. Boost headers are
87#                               installed directly into <HDRDIR>. This option is
88#                               intended for system integrators building
89#                               distribution packages.
90#
91#                           The default value is 'versioned' on Windows, and
92#                           'system' on Unix.
93#
94#   --buildid=ID            Add the specified ID to the name of built libraries.
95#                           The default is to not add anything.
96#
97#   --python-buildid=ID     Add the specified ID to the name of built libraries
98#                           that depend on Python. The default is to not add
99#                           anything. This ID is added in addition to --buildid.
100#
101#   --help                  This message.
102#
103#   --with-<library>        Build and install the specified <library>. If this
104#                           option is used, only libraries specified using this
105#                           option will be built.
106#
107#   --without-<library>     Do not build, stage, or install the specified
108#                           <library>. By default, all libraries are built.
109#
110# Properties:
111#
112#   toolset=toolset         Indicate the toolset to build with.
113#
114#   variant=debug|release   Select the build variant
115#
116#   link=static|shared      Whether to build static or shared libraries
117#
118#   threading=single|multi  Whether to build single or multithreaded binaries
119#
120#   runtime-link=static|shared
121#                           Whether to link to static or shared C and C++
122#                           runtime.
123#
124
125# TODO:
126#  - handle boost version
127#  - handle python options such as pydebug
128
129import boostcpp ;
130import package ;
131
132import sequence ;
133import xsltproc ;
134import set ;
135import path ;
136import link ;
137import notfile ;
138import virtual-target ;
139import "class" : new ;
140import property-set ;
141import threadapi-feature ;
142import option ;
143# Backslash because of `bcp --namespace`
144import tools/boost\_install/boost-install ;
145
146path-constant BOOST_ROOT : . ;
147constant BOOST_VERSION : 1.76.0 ;
148constant BOOST_JAMROOT_MODULE : $(__name__) ;
149
150# Allow subprojects to simply `import config : requires ;` to get access to the requires rule
151modules.poke : BOOST_BUILD_PATH : $(BOOST_ROOT)/libs/config/checks [ modules.peek : BOOST_BUILD_PATH ] ;
152
153boostcpp.set-version $(BOOST_VERSION) ;
154
155use-project /boost/architecture : libs/config/checks/architecture ;
156
157local all-headers =
158    [ MATCH .*libs/(.*)/include/boost : [ glob libs/*/include/boost libs/*/*/include/boost ] ] ;
159
160for dir in $(all-headers)
161{
162    link-directory $(dir)-headers : libs/$(dir)/include/boost : <location>. ;
163    explicit $(dir)-headers ;
164}
165
166if $(all-headers)
167{
168    constant BOOST_MODULARLAYOUT : $(all-headers) ;
169}
170
171project boost
172    : requirements <include>.
173
174      [ boostcpp.architecture ]
175      [ boostcpp.address-model ]
176
177      # Disable auto-linking for all targets here, primarily because it caused
178      # troubles with V2.
179      <define>BOOST_ALL_NO_LIB=1
180      # Used to encode variant in target name. See the 'tag' rule below.
181      <tag>@$(__name__).tag
182      <conditional>@handle-static-runtime
183      # Comeau does not support shared lib
184      <toolset>como:<link>static
185      <toolset>como-linux:<define>_GNU_SOURCE=1
186      # When building docs within Boost, we want the standard Boost style
187      <xsl:param>boost.defaults=Boost
188      <conditional>@threadapi-feature.detect
189    : usage-requirements <include>.
190    : default-build
191      <visibility>hidden
192      <threading>multi
193    : build-dir bin.v2
194    ;
195
196# This rule is called by Boost.Build to determine the name of target. We use it
197# to encode the build variant, compiler name and boost version in the target
198# name.
199#
200rule tag ( name : type ? : property-set )
201{
202    return [ boostcpp.tag $(name) : $(type) : $(property-set) ] ;
203}
204
205rule python-tag ( name : type ? : property-set )
206{
207    return [ boostcpp.python-tag $(name) : $(type) : $(property-set) ] ;
208}
209
210rule handle-static-runtime ( properties * )
211{
212    # Using static runtime with shared libraries is impossible on Linux, and
213    # dangerous on Windows. Therefore, we disallow it. This might be drastic,
214    # but it was disabled for a while without anybody complaining.
215
216    # For CW, static runtime is needed so that std::locale works.
217    if <link>shared in $(properties) && <runtime-link>static in $(properties) &&
218        ! ( <toolset>cw in $(properties) )
219    {
220        if ! $(.shared-static-warning-emitted)
221        {
222            ECHO "warning: skipping configuration link=shared, runtime-link=static" ;
223            ECHO "warning: this combination is either impossible or too dangerous" ;
224            ECHO "warning: to be of any use" ;
225            .shared-static-warning-emitted = 1 ;
226        }
227
228        return <build>no ;
229    }
230}
231
232all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
233    [ glob libs/*/build/Jamfile ] ] ;
234
235all-libraries = [ sequence.unique $(all-libraries) ] ;
236# The function_types library has a Jamfile, but it's used for maintenance
237# purposes, there's no library to build and install.
238all-libraries = [ set.difference $(all-libraries) : function_types ] ;
239
240# Setup convenient aliases for all libraries.
241
242local rule explicit-alias ( id : targets + )
243{
244    alias $(id) : $(targets) ;
245    explicit $(id) ;
246}
247
248# First, the complicated libraries: where the target name in Jamfile is
249# different from its directory name.
250explicit-alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
251explicit-alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
252explicit-alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
253explicit-alias bgl-vis : libs/graps/build//bgl-vis ;
254explicit-alias serialization : libs/serialization/build//boost_serialization ;
255explicit-alias wserialization : libs/serialization/build//boost_wserialization ;
256for local l in $(all-libraries)
257{
258    if ! $(l) in test graph serialization headers
259    {
260        explicit-alias $(l) : libs/$(l)/build//boost_$(l) ;
261    }
262}
263
264# Log has an additional target
265explicit-alias log_setup : libs/log/build//boost_log_setup ;
266
267rule do-nothing { }
268
269rule generate-alias ( project name : property-set : sources * )
270{
271    local action-name = [ $(property-set).get <action> ] ;
272    local m = [ MATCH ^@(.*) : $(action-name) ] ;
273    property-set = [ property-set.empty ] ;
274    local action = [ new action $(sources) : $(m[1]) : $(property-set) ] ;
275    local t = [ new notfile-target $(name) : $(project) : $(action) ] ;
276    return [ virtual-target.register $(t) ] ;
277}
278
279generate headers : $(all-headers)-headers : <generating-rule>@generate-alias <action>@do-nothing : : <include>.  ;
280
281#alias headers : $(all-headers)-headers : : : <include>.  ;
282explicit headers ;
283
284# Make project ids of all libraries known.
285for local l in $(all-libraries)
286{
287    use-project /boost/$(l) : libs/$(l)/build ;
288}
289
290if [ path.exists $(BOOST_ROOT)/tools/inspect/build ]
291{
292    use-project /boost/tools/inspect : tools/inspect/build ;
293}
294
295if [ path.exists $(BOOST_ROOT)/libs/wave/tool/build ]
296{
297    use-project /boost/libs/wave/tool : libs/wave/tool/build ;
298}
299
300# Make the boost-install rule visible in subprojects
301
302# This rule should be called from libraries' Jamfiles and will create two
303# targets, "install" and "stage", that will install or stage that library. The
304# --prefix option is respected, but --with and --without options, naturally, are
305# ignored.
306#
307# - libraries -- list of library targets to install.
308
309rule boost-install ( libraries * )
310{
311    boost-install.boost-install $(libraries) ;
312}
313
314# Creates a library target, adding autolink support and also creates
315# stage and install targets via boost-install, above.
316rule boost-lib ( name : sources * : requirements * : default-build * : usage-requirements * )
317{
318    autolink = <link>shared:<define>BOOST_$(name:U)_DYN_LINK=1 ;
319    name = boost_$(name) ;
320    lib $(name)
321        : $(sources)
322        : $(requirements) $(autolink)
323        : $(default-build)
324        : $(usage-requirements) $(autolink)
325        ;
326    boost-install $(name) ;
327}
328
329
330# Declare special top-level targets that build and install the desired variants
331# of the libraries.
332boostcpp.declare-targets $(all-libraries) ;
333