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 Win32
23#                           Default; /usr/local on Unix. Linux, etc.
24#
25#   --exec-prefix=<EPREFIX> Install architecture dependent files here.
26#                           Default; <PREFIX>
27#
28#   --libdir=<DIR>          Install library files here.
29#                           Default; <EPREFIX>/lib
30#
31#   --includedir=<HDRDIR>   Install header files here.
32#                           Default; <PREFIX>/include
33#
34#   stage                   Build and install only compiled library files to the
35#   =====                   stage directory.
36#
37#   --stagedir=<STAGEDIR>   Install library files here
38#                           Default; ./stage
39#
40# Other Options:
41#
42#   --build-type=<type>     Build the specified pre-defined set of variations of
43#                           the libraries. Note, that which variants get built
44#                           depends on what each library supports.
45#
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 are
50#                               static and shared multithreaded libraries in
51#                               release mode.
52#
53#                               -- complete -- Build all possible variations.
54#
55#   --build-dir=DIR         Build in this location instead of building within
56#                           the distribution tree. Recommended!
57#
58#   --show-libraries        Display the list of Boost libraries that require
59#                           build and installation steps, and then exit.
60#
61#   --layout=<layout>       Determine whether to choose library names and header
62#                           locations such that multiple versions of Boost or
63#                           multiple compilers can be used on the same system.
64#
65#                               -- versioned -- Names of boost binaries include
66#                               the Boost version number, name and version of
67#                               the compiler and encoded build properties. Boost
68#                               headers are installed in a subdirectory of
69#                               <HDRDIR> whose name contains the Boost version
70#                               number.
71#
72#                               -- tagged -- Names of boost binaries include the
73#                               encoded build properties such as variant and
74#                               threading, but do not including compiler name
75#                               and version, or Boost version. This option is
76#                               useful if you build several variants of Boost,
77#                               using the same compiler.
78#
79#                               -- system -- Binaries names do not include the
80#                               Boost version number or the name and version
81#                               number of the compiler. Boost headers are
82#                               installed directly into <HDRDIR>. This option is
83#                               intended for system integrators building
84#                               distribution packages.
85#
86#                           The default value is 'versioned' on Windows, and
87#                           'system' on Unix.
88#
89#   --buildid=ID            Add the specified ID to the name of built libraries.
90#                           The default is to not add anything.
91#
92#   --python-buildid=ID     Add the specified ID to the name of built libraries
93#                           that depend on Python. The default is to not add
94#                           anything. This ID is added in addition to --buildid.
95#
96#   --help                  This message.
97#
98#   --with-<library>        Build and install the specified <library>. If this
99#                           option is used, only libraries specified using this
100#                           option will be built.
101#
102#   --without-<library>     Do not build, stage, or install the specified
103#                           <library>. By default, all libraries are built.
104#
105# Properties:
106#
107#   toolset=toolset         Indicate the toolset to build with.
108#
109#   variant=debug|release   Select the build variant
110#
111#   link=static|shared      Whether to build static or shared libraries
112#
113#   threading=single|multi  Whether to build single or multithreaded binaries
114#
115#   runtime-link=static|shared
116#                           Whether to link to static or shared C and C++
117#                           runtime.
118#
119
120# TODO:
121#  - handle boost version
122#  - handle python options such as pydebug
123
124import boostcpp ;
125import package ;
126
127import sequence ;
128import xsltproc ;
129import set ;
130import path ;
131import link ;
132
133path-constant BOOST_ROOT : . ;
134constant BOOST_VERSION : 1.59.0 ;
135constant BOOST_JAMROOT_MODULE : $(__name__) ;
136
137boostcpp.set-version $(BOOST_VERSION) ;
138
139use-project /boost/architecture : libs/config/checks/architecture ;
140
141local all-headers =
142    [ MATCH .*libs/(.*)/include/boost : [ glob libs/*/include/boost libs/*/*/include/boost ] ] ;
143
144for dir in $(all-headers)
145{
146    link-directory $(dir)-headers : libs/$(dir)/include/boost : <location>. ;
147    explicit $(dir)-headers ;
148}
149
150if $(all-headers)
151{
152    constant BOOST_MODULARLAYOUT : $(all-headers) ;
153}
154
155project boost
156    : requirements <include>.
157
158      [ boostcpp.architecture ]
159      [ boostcpp.address-model ]
160
161      # Disable auto-linking for all targets here, primarily because it caused
162      # troubles with V2.
163      <define>BOOST_ALL_NO_LIB=1
164      # Used to encode variant in target name. See the 'tag' rule below.
165      <tag>@$(__name__).tag
166      <conditional>@handle-static-runtime
167      # Comeau does not support shared lib
168      <toolset>como:<link>static
169      <toolset>como-linux:<define>_GNU_SOURCE=1
170      # When building docs within Boost, we want the standard Boost style
171      <xsl:param>boost.defaults=Boost
172    : usage-requirements <include>.
173    : build-dir bin.v2
174    ;
175
176# This rule is called by Boost.Build to determine the name of target. We use it
177# to encode the build variant, compiler name and boost version in the target
178# name.
179#
180rule tag ( name : type ? : property-set )
181{
182    return [ boostcpp.tag $(name) : $(type) : $(property-set) ] ;
183}
184
185rule handle-static-runtime ( properties * )
186{
187    # Using static runtime with shared libraries is impossible on Linux, and
188    # dangerous on Windows. Therefore, we disallow it. This might be drastic,
189    # but it was disabled for a while without anybody complaining.
190
191    # For CW, static runtime is needed so that std::locale works.
192    if <link>shared in $(properties) && <runtime-link>static in $(properties) &&
193        ! ( <toolset>cw in $(properties) )
194    {
195        ECHO "error: link=shared together with runtime-link=static is not allowed" ;
196        ECHO "error: such property combination is either impossible " ;
197        ECHO "error: or too dangerious to be of any use" ;
198        EXIT ;
199    }
200}
201
202all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
203    [ glob libs/*/build/Jamfile ] ] ;
204
205all-libraries = [ sequence.unique $(all-libraries) ] ;
206# The function_types library has a Jamfile, but it's used for maintenance
207# purposes, there's no library to build and install.
208all-libraries = [ set.difference $(all-libraries) : function_types ] ;
209
210# Setup convenient aliases for all libraries.
211
212local rule explicit-alias ( id : targets + )
213{
214    alias $(id) : $(targets) ;
215    explicit $(id) ;
216}
217
218# First, the complicated libraries: where the target name in Jamfile is
219# different from its directory name.
220explicit-alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ;
221explicit-alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
222explicit-alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
223explicit-alias bgl-vis : libs/graps/build//bgl-vis ;
224explicit-alias serialization : libs/serialization/build//boost_serialization ;
225explicit-alias wserialization : libs/serialization/build//boost_wserialization ;
226for local l in $(all-libraries)
227{
228    if ! $(l) in test graph serialization
229    {
230        explicit-alias $(l) : libs/$(l)/build//boost_$(l) ;
231    }
232}
233
234# Log has an additional target
235explicit-alias log_setup : libs/log/build//boost_log_setup ;
236
237alias headers : $(all-headers)-headers : : : <include>.  ;
238explicit headers ;
239
240# Make project ids of all libraries known.
241for local l in $(all-libraries)
242{
243    use-project /boost/$(l) : libs/$(l)/build ;
244}
245
246if [ path.exists $(BOOST_ROOT)/tools/inspect ]
247{
248    use-project /boost/tools/inspect : tools/inspect/build ;
249}
250
251if [ path.exists $(BOOST_ROOT)/libs/wave/tool ]
252{
253    use-project /boost/libs/wave/tool : libs/wave/tool/build ;
254}
255
256# This rule should be called from libraries' Jamfiles and will create two
257# targets, "install" and "stage", that will install or stage that library. The
258# --prefix option is respected, but --with and --without options, naturally, are
259# ignored.
260#
261# - libraries -- list of library targets to install.
262#
263rule boost-install ( libraries * )
264{
265    package.install install
266        : <dependency>/boost//install-proper-headers $(install-requirements)
267        : # No binaries
268        : $(libraries)
269        : # No headers, it is handled by the dependency.
270    ;
271
272    install stage : $(libraries) : <location>$(BOOST_STAGE_LOCATE) ;
273
274    module [ CALLER_MODULE ]
275    {
276        explicit stage ;
277        explicit install ;
278    }
279}
280
281headers =
282    # The .SUNWCCh files are present in tr1 include directory and have to be
283    # installed (see http://lists.boost.org/Archives/boost/2007/05/121430.php).
284    [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ]
285    [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ]
286    [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ]
287    ;
288
289# Declare special top-level targets that build and install the desired variants
290# of the libraries.
291boostcpp.declare-targets $(all-libraries) : $(headers) ;
292