]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boostcpp.jam
update sources to v12.2.4
[ceph.git] / ceph / src / boost / boostcpp.jam
CommitLineData
7c673cae
FG
1# Boost.Build support specific for the Boost C++ Libraries.
2# Copyright Vladimir Prus 2002-2010.
3# Copyright Dave Abrahams 2005-2006.
4# Copyright Rene Rivera 2005-2007.
5# Copyright Douglas Gregor 2005.
6#
7# Distributed under the Boost Software License, Version 1.0.
8# (See accompanying file LICENSE_1_0.txt or copy at
9# http://www.boost.org/LICENSE_1_0.txt)
10
11import "class" : new ;
12import common ;
13import configure ;
14import build-system ;
15import generate ;
16import modules ;
17import option ;
18import os ;
19import package ;
20import path ;
21import project ;
22import regex ;
23import set ;
24import targets ;
25import feature ;
26import property ;
27
28##############################################################################
29#
30# 0. General setup. Parse options, check them.
31#
32##############################################################################
33
34BOOST_ROOT = [ modules.binding $(__name__) ] ;
35BOOST_ROOT = $(BOOST_ROOT:D) ;
36
37rule set-version ( version )
38{
39 BOOST_VERSION = $(version) ;
40
41 local version-tag = [ MATCH ^([^.]+)[.]([^.]+)[.]([^.]+) : $(BOOST_VERSION)
42 ] ;
43 if $(version-tag[3]) = 0
44 {
45 version-tag = $(version-tag[1-2]) ;
46 }
47 BOOST_VERSION_TAG = $(version-tag:J=_) ;
48}
49
50# Option to choose how many variants to build. The default is "minimal".
51build-type = [ option.get build-type ] ;
52build-type ?= minimal ;
53if ! ( $(build-type) in complete minimal )
54{
55 EXIT The value of the --build-type option should be either 'complete' or
56 'minimal' ;
57}
58
59# What kind of layout are we doing?
60layout = [ option.get layout : "" ] ;
61# On Windows, we used versioned layout by default in order to be compatible with
62# autolink. On other systems, we use system layout which is what every other
63# program uses. Note that the Windows check is static, and will not be affected
64# by specific build properties used.
65if ! $(layout)
66{
67 if [ os.name ] = NT
68 {
69 layout = versioned ;
70 }
71 else
72 {
73 layout = system ;
74 }
75}
76layout-$(layout) = true ;
77
78if $(layout) = system && $(build-type) = complete
79{
80 ECHO error: Cannot use --layout=system with --build-type complete. ;
81 ECHO error: Please use either --layout=versioned or --layout=tagged ;
82 ECHO error: if you wish to build multiple variants. ;
83 if [ os.name ] != NT
84 {
85 ECHO error: Note that --layout=system is used by default on Unix
86 starting with Boost 1.40. ;
87 }
88 EXIT ;
89}
90
91# Possible stage only location.
92stage-locate = [ option.get stagedir ] ;
93stage-locate ?= stage ;
94BOOST_STAGE_LOCATE = $(stage-locate) ;
95
96# Custom build ID.
97build-id = [ option.get buildid ] ;
98if $(build-id)
99{
100 BUILD_ID = [ regex.replace $(build-id) "[*\\/:.\"\' ]" _ ] ;
101}
102
103# Python build id (for Python libraries only).
104python-id = [ option.get "python-buildid" ] ;
105if $(python-id)
106{
107 PYTHON_ID = [ regex.replace $(python-id) [*\\/:.\"\'] _ ] ;
108}
109
110
111################################################################################
112#
113# 1. 'tag' function adding decorations suitable to the properties if versioned
114# or tagged layout is requested. Called from Jamroot.
115#
116################################################################################
117
118rule tag ( name : type ? : property-set )
119{
120 if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
121 {
122 local result ;
123 if $(layout) = versioned
124 {
125 result = [ common.format-name
b32b8144 126 <base> <toolset> <threading> <runtime> <arch-and-model> -$(BOOST_VERSION_TAG)
7c673cae
FG
127 -$(BUILD_ID)
128 : $(name) : $(type) : $(property-set) ] ;
129 }
130 else if $(layout) = tagged
131 {
132 result = [ common.format-name
133 <base> <threading> <runtime>
134 -$(BUILD_ID)
135 : $(name) : $(type) : $(property-set) ] ;
136 }
137 else if $(layout) = system
138 {
139 result = [ common.format-name
140 <base>
141 -$(BUILD_ID)
142 : $(name) : $(type) : $(property-set) ] ;
143 }
144 else
145 {
146 EXIT error: invalid layout '$(layout:E=)' ;
147 }
148
149 # Optionally add version suffix. On NT, library with version suffix will
150 # not be recognized by linkers. On CYGWIN, we get strage duplicate
151 # symbol errors when library is generated with version suffix. On OSX,
152 # version suffix is not needed -- the linker expects the
153 # libFoo.1.2.3.dylib format. AIX linkers do not accept version suffixes
154 # either. Pgi compilers can not accept a library with version suffix.
155 if $(type) = SHARED_LIB &&
156 ! [ $(property-set).get <target-os> ] in windows cygwin darwin aix &&
157 ! [ $(property-set).get <toolset> ] in pgi
158 {
159 result = $(result).$(BOOST_VERSION) ;
160 }
161
162 return $(result) ;
163 }
164}
165
166# Specialized tag function to use for libraries linking to Python.
167# Appends value of --python-buildid if provided.
168rule python-tag ( name : type ? : property-set )
169{
170 local result = $(name) ;
171 if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB && $(PYTHON_ID)
172 {
173 result = $(result)-$(PYTHON_ID) ;
174 }
175
176 # forward to the boost tagging rule
177 return [ tag $(result) : $(type) : $(property-set) ] ;
178}
179
180################################################################################
181#
182# 2. Declare targets that build and install all libraries. Specifically:
183#
184# - 'stage-proper' that puts all libraries in stage/lib
185# - 'install-proper' that install libraries and headers to system location
186# - 'stage-unversioned' that creates links to libraries without boost version
187# in name
188# - 'install-unversioned' which creates unversioned linked to installed
189# libraries.
190#
191################################################################################
192
193# Worker function suitable to the 'generate' metatarget. Creates a link to
194# 'source', striping any version number information from the name.
195rule make-unversioned-links ( project name ? : property-set : sources * )
196{
197 local filter ;
198 if [ modules.peek : NT ]
199 {
200 filter = (.*[.]lib) ;
201 }
202 else
203 {
204 filter =
205 (.*[.]so)[.0-9]*
206 (.*[.]dylib)
207 (.*[.]a) ;
208 }
209
210 local result ;
211 for local s in $(sources)
212 {
213 local m = [ MATCH ^(.*)-[0-9_]+$(filter)$ : [ $(s).name ] ] ;
214 if $(m)
215 {
216 local ea = [ $(s).action ] ;
217 local ep = [ $(ea).properties ] ;
218 local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ;
219 result += [ new file-target $(m:J=) exact : [ $(s).type ] :
220 $(project) : $(a) ] ;
221 }
222 }
223 return $(result) ;
224}
225
226rule filtered-target ( name : message + : sources + : requirements * )
227{
228 message $(name)-message : warning: $(message) ;
229 alias $(name) : $(sources) : $(requirements) ;
230 alias $(name) : $(name)-message ;
231
232 local p = [ project.current ] ;
233 $(p).mark-target-as-explicit $(name) ;
234 $(p).mark-target-as-explicit $(name)-message ;
235}
236
237rule declare_install_and_stage_proper_targets ( libraries * : headers * )
238{
239 local p = [ project.current ] ;
240 for local l in $(libraries)
241 {
242 if $(l) = locale
243 {
244 filtered-target $(l)-for-install :
245 Skipping Boost.Locale library with threading=single. :
246 libs/$(l)/build : <threading>multi ;
247 }
248 else if $(l) = wave
249 {
250 filtered-target $(l)-for-install :
251 Skipping Boost.Wave library with threading=single. :
252 libs/$(l)/build : <threading>multi ;
253 }
254 else if $(l) = thread
255 {
256 filtered-target $(l)-for-install :
257 Skipping Boost.Thread library with threading=single. :
258 libs/$(l)/build : <threading>multi ;
259 }
260 else
261 {
262 alias $(l)-for-install : libs/$(l)/build ;
263 $(p).mark-target-as-explicit $(l)-for-install ;
264 }
265 }
266 local library-targets = $(libraries)-for-install ;
267
268 install-requirements = <install-source-root>$(BOOST_ROOT)/boost ;
269
270 if $(layout-versioned)
271 {
272 install-requirements +=
273 <install-header-subdir>boost-$(BOOST_VERSION_TAG)/boost ;
274 }
275 else
276 {
277 install-requirements += <install-header-subdir>boost ;
278 }
279
280 if [ os.name ] = NT
281 {
282 install-requirements += <install-default-prefix>C:/Boost ;
283 }
284 else
285 {
286 install-requirements += <install-default-prefix>/usr/local ;
287 }
288
289 p = [ project.current ] ;
290
291 # Complete install.
292 package.install install-proper
293 : $(install-requirements) <install-no-version-symlinks>on
294 :
295 : $(libraries)-for-install
296 : $(headers)
297 ;
298 $(p).mark-target-as-explicit install-proper ;
299
300 # Install just library.
301 install stage-proper
302 : $(libraries)-for-install
303 : <location>$(stage-locate)/lib
304 <install-dependencies>on <install-type>LIB
305 <install-no-version-symlinks>on
306 ;
307 $(p).mark-target-as-explicit stage-proper ;
308
309 # Commented out as it does not seem to work. Whoever wrote this originally,
310 # left some typos in the code, but when that got corrected and the code got
311 # enabled - it started reporting ambiguous/duplicate target Boost Build
312 # errors. Anyone requiring unversioned staged libraries needs to correct
313 # those errors before reenabling this code. For more detailed information
314 # see the related Boost library development mailing list thread at
315 # 'http://lists.boost.org/Archives/boost/2012/06/194312.php'.
316 # (06.07.2012.) (Jurko)
317 #~ if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] )
318 #~ {
319 #~ generate stage-unversioned : stage-proper :
320 #~ <generating-rule>@boostcpp.make-unversioned-links ;
321 #~ $(p).mark-target-as-explicit stage-unversioned ;
322 #~
323 #~ generate install-unversioned : install-proper :
324 #~ <generating-rule>@boostcpp.make-unversioned-links ;
325 #~ $(p).mark-target-as-explicit install-unversioned ;
326 #~ }
327 #~ else
328 {
329 # Create do-nothing aliases.
330 alias stage-unversioned ;
331 $(p).mark-target-as-explicit stage-unversioned ;
332 alias install-unversioned ;
333 $(p).mark-target-as-explicit install-unversioned ;
334 }
335}
336
337
338################################################################################
339#
340# 3. Declare top-level targets 'stage' and 'install'. These examine the
341# --build-type option and, in case it is 'complete', build the 'install-proper'
342# and 'stage-proper' targets with a number of property sets.
343#
344################################################################################
345
346class top-level-target : alias-target-class
347{
348 import modules ;
349
350 rule __init__ ( name : project : sources * : requirements *
351 : default-build * : usage-requirements * )
352 {
353 alias-target-class.__init__ $(name) : $(project) : $(sources) :
354 $(requirements) : $(default-build) : $(usage-requirements) ;
355
356 self.build-type = [ modules.peek boostcpp : build-type ] ;
357 # On Linux, we build the release variant by default, since few users
358 # will ever want to debug C++ Boost libraries, and there is no ABI
359 # incompatibility between debug and release variants. We build shared
360 # and static libraries since that is what most packages seem to provide
361 # (.so in libfoo and .a in libfoo-dev).
b32b8144 362
7c673cae
FG
363 self.minimal-properties = [ property-set.create <variant>release
364 <threading>multi <link>shared <link>static <runtime-link>shared ] ;
b32b8144 365
7c673cae
FG
366 # On Windows, new IDE projects use:
367 #
368 # runtime-link=dynamic, threading=multi, variant=(debug|release)
369 #
370 # and in addition, C++ Boost's autolink defaults to static linking.
b32b8144 371
7c673cae
FG
372 self.minimal-properties-win = [ property-set.create <variant>debug
373 <variant>release <threading>multi <link>static <runtime-link>shared
b32b8144 374 <address-model>32 <address-model>64 ] ;
7c673cae
FG
375
376 self.complete-properties = [ property-set.create
377 <variant>debug <variant>release
b32b8144 378 <threading>multi
7c673cae
FG
379 <link>shared <link>static
380 <runtime-link>shared <runtime-link>static ] ;
b32b8144
FG
381
382 self.complete-properties-win = [ property-set.create
383 <variant>debug <variant>release
384 <threading>multi
385 <link>shared <link>static
386 <runtime-link>shared <runtime-link>static
387 <address-model>32 <address-model>64 ] ;
7c673cae
FG
388 }
389
390 rule generate ( property-set )
391 {
392 modules.poke : top-level-targets : [ modules.peek : top-level-targets ]
393 $(self.name) ;
b32b8144
FG
394
395 local os = [ $(property-set).get <target-os> ] ;
396
397 # Because we completely override the parent's 'generate' we need to
398 # check for default feature values ourselves.
399
400 if ! $(os)
7c673cae 401 {
b32b8144
FG
402 os = [ feature.defaults <target-os> ] ;
403 os = $(os:G=) ;
404 }
7c673cae 405
b32b8144 406 local build-type-set ;
7c673cae 407
b32b8144
FG
408 if $(self.build-type) = minimal
409 {
7c673cae
FG
410 if $(os) = windows
411 {
b32b8144 412 build-type-set = $(self.minimal-properties-win) ;
7c673cae
FG
413 }
414 else
415 {
b32b8144 416 build-type-set = $(self.minimal-properties) ;
7c673cae 417 }
7c673cae
FG
418 }
419 else if $(self.build-type) = complete
b32b8144
FG
420 {
421 if $(os) = windows
422 {
423 build-type-set = $(self.complete-properties-win) ;
424 }
425 else
426 {
427 build-type-set = $(self.complete-properties) ;
428 }
429 }
430 else
431 {
432 import errors ;
433 errors.error "Unknown build type" ;
434 }
435
436 if $(build-type-set)
7c673cae
FG
437 {
438 local expanded = [ targets.apply-default-build $(property-set)
b32b8144 439 : $(build-type-set) ] ;
7c673cae
FG
440
441 # Filter inappopriate combinations.
442 local filtered ;
443 for local p in $(expanded)
444 {
445 # See comment in handle-static-runtime regarding this logic.
446 if [ $(p).get <link> ] = shared
447 && [ $(p).get <runtime-link> ] = static
448 && [ $(p).get <toolset> ] != cw
449 {
450 # Skip this.
451 }
452 else
453 {
454 filtered += $(p) ;
455 }
456 }
b32b8144 457
7c673cae
FG
458 return [ build-multiple $(filtered) ] ;
459 }
7c673cae
FG
460 }
461
462 rule build-multiple ( property-sets * )
463 {
464 local usage-requirements = [ property-set.empty ] ;
465 local result ;
466 for local p in $(property-sets)
467 {
468 local r = [ alias-target-class.generate $(p) ] ;
469 if $(r)
470 {
471 usage-requirements = [ $(usage-requirements).add $(r[1]) ] ;
472 result += $(r[2-]) ;
473 }
474 }
475 return $(usage-requirements) [ sequence.unique $(result) ] ;
476 }
477}
478
479rule declare_top_level_targets ( libraries * : headers * )
480{
481 declare_install_and_stage_proper_targets $(libraries) : $(headers) ;
482
483 targets.create-metatarget top-level-target : [ project.current ]
484 : install
485 : install-proper install-unversioned
486 ;
487 targets.create-metatarget top-level-target : [ project.current ]
488 : stage
489 : stage-proper stage-unversioned
490 ;
491
492 p = [ project.current ] ;
493 $(p).mark-target-as-explicit install stage ;
494
495 # This target is built by default, and will forward to 'stage' after
496 # producing some explanations.
497 targets.create-metatarget top-level-target : [ project.current ]
498 : forward
499 : explain stage
500 ;
501}
502
503
504stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ;
505
506
507################################################################################
508#
509# 4. Add hook to report configuration before the build, and confirmation with
510# setup instructions after the build.
511#
512################################################################################
513
514message explain : "\nBuilding the Boost C++ Libraries.\n\n" ;
515local p = [ project.current ] ;
516$(p).mark-target-as-explicit explain ;
517
518rule pre-build ( )
519{
520 local tl = [ modules.peek : top-level-targets ] ;
521 if stage in $(tl) || install in $(tl)
522 {
523 # FIXME: Remove 'if' when Boost regression tests start using trunk bjam.
524 if PAD in [ RULENAMES ]
525 {
526 configure.print-component-configuration ;
527 }
528 }
529}
530IMPORT $(__name__) : pre-build : : $(__name__).pre-build ;
531build-system.set-pre-build-hook $(__name__).pre-build ;
532
533# FIXME: Revise stage_abs.
534rule post-build ( ok ? )
535{
536 if forward in [ modules.peek : top-level-targets ]
537 {
538 if $(ok)
539 {
540 local include-path = [ path.native $(BOOST_ROOT) ] ;
541 ECHO "
542
543The Boost C++ Libraries were successfully built!
544
545The following directory should be added to compiler include paths:
546
547 $(include-path)
548
549The following directory should be added to linker library paths:
550
551 $(stage-abs)
552" ;
553 }
554 }
555}
556IMPORT $(__name__) : post-build : : $(__name__).post-build ;
557build-system.set-post-build-hook $(__name__).post-build ;
558
559
560################################################################################
561#
562# 5. Top-level setup.
563#
564################################################################################
565
566# Decides which libraries are to be installed by looking at --with-<library>
567# --without-<library> arguments. Returns the list of directories under "libs"
568# which must be built and installed.
569#
570rule libraries-to-install ( existing-libs * )
571{
572 local argv = [ modules.peek : ARGV ] ;
573 local with-parameter = [ MATCH ^--with-(.*) : $(argv) ] ;
574 local without-parameter = [ MATCH ^--without-(.*) : $(argv) ] ;
575
576 if ! $(with-parameter) && ! $(without-parameter)
577 {
578 # Nothing is specified on command line. See if maybe project-config.jam
579 # has some choices.
580 local libs = [ modules.peek project-config : libraries ] ;
581 with-parameter = [ MATCH ^--with-(.*) : $(libs) ] ;
582 without-parameter = [ MATCH ^--without-(.*) : $(libs) ] ;
583 }
584
585 # Do some checks.
586 if $(with-parameter) && $(without-parameter)
587 {
588 EXIT error: both --with-<library> and --without-<library> specified ;
589 }
590
591 local wrong = [ set.difference $(with-parameter) : $(existing-libs) ] ;
592 if $(wrong)
593 {
594 EXIT error: wrong library name '$(wrong[1])' in the --with-<library>
595 option. ;
596 }
597 local wrong = [ set.difference $(without-parameter) : $(existing-libs) ] ;
598 if $(wrong)
599 {
600 EXIT error: wrong library name '$(wrong[1])' in the --without-<library>
601 option. ;
602 }
603
604 if $(with-parameter)
605 {
606 return [ set.intersection $(existing-libs) : $(with-parameter) ] ;
607 }
608 else
609 {
610 return [ set.difference $(existing-libs) : $(without-parameter) ] ;
611 }
612}
613
614rule declare-targets ( all-libraries * : headers * )
615{
616 configure.register-components $(all-libraries) ;
617
618 # Select the libraries to install.
619 libraries = [ libraries-to-install $(all-libraries) ] ;
620 configure.components-building $(libraries) ;
621
622 if [ option.get "show-libraries" : : true ]
623 {
624 ECHO The following libraries require building: ;
625 for local l in $(libraries)
626 {
627 ECHO " - $(l)" ;
628 }
629 EXIT ;
630 }
631
632 declare_top_level_targets $(libraries) : $(headers) ;
633}
634
635# Returns the properties identifying the toolset. We'll use them
636# below to configure checks. These are essentially same as in
637# configure.builds, except we don't use address-model and
638# architecture - as we're trying to detect them here.
639#
640rule toolset-properties ( properties * )
641{
642 local toolset = [ property.select <toolset> : $(properties) ] ;
643 local toolset-version-property = "<toolset-$(toolset:G=):version>" ;
644 return [ property.select <target-os> <toolset> $(toolset-version-property) : $(properties) ] ;
645}
646
647feature.feature deduced-address-model : 32 64 : propagated optional composite hidden ;
648feature.compose <deduced-address-model>32 : <address-model>32 ;
649feature.compose <deduced-address-model>64 : <address-model>64 ;
650
651rule deduce-address-model ( properties * )
652{
653 local result ;
654 local filtered = [ toolset-properties $(properties) ] ;
655
656 if [ configure.builds /boost/architecture//32 : $(filtered) : 32-bit ]
657 {
658 result = 32 ;
659 }
660 else if [ configure.builds /boost/architecture//64 : $(filtered) : 64-bit ]
661 {
662 result = 64 ;
663 }
664
665 if $(result)
666 {
667 # Normally, returning composite feature here is equivalent to forcing
668 # consituent properties as well. But we only want to indicate toolset
669 # deduced default, so also pick whatever address-model is explicitly
670 # specified, if any.
671 result = <deduced-address-model>$(result) [ property.select <address-model> : $(properties) ] ;
672 }
673 return $(result) ;
674}
675
676rule address-model ( )
677{
678 return <conditional>@boostcpp.deduce-address-model ;
679}
680
681local deducable-architectures = arm mips1 power sparc x86 combined ;
682feature.feature deduced-architecture : $(deducable-architectures) : propagated optional composite hidden ;
683for a in $(deducable-architectures)
684{
685 feature.compose <deduced-architecture>$(a) : <architecture>$(a) ;
686}
687
688rule deduce-architecture ( properties * )
689{
690 local result ;
691 local filtered = [ toolset-properties $(properties) ] ;
692 if [ configure.builds /boost/architecture//arm : $(filtered) : arm ]
693 {
694 result = arm ;
695 }
696 else if [ configure.builds /boost/architecture//mips1 : $(filtered) : mips1 ]
697 {
698 result = mips1 ;
699 }
700 else if [ configure.builds /boost/architecture//power : $(filtered) : power ]
701 {
702 result = power ;
703 }
704 else if [ configure.builds /boost/architecture//sparc : $(filtered) : sparc ]
705 {
706 result = sparc ;
707 }
708 else if [ configure.builds /boost/architecture//x86 : $(filtered) : x86 ]
709 {
710 result = x86 ;
711 }
712 else if [ configure.builds /boost/architecture//combined : $(filtered) : combined ]
713 {
714 result = combined ;
715 }
716
717 if $(result)
718 {
719 # See comment in deduce-address-model.
720 result = <deduced-architecture>$(result) [ property.select <architecture> : $(properties) ] ;
721 }
722 return $(result) ;
723}
724
725rule architecture ( )
726{
727 return <conditional>@boostcpp.deduce-architecture ;
728}