2 # Copyright 2006-2007 Roland Schwarz.
3 # Copyright 2007 Anthony Williams
4 # Copyright 2011-2012 Vicente J.Botet Escriba.
5 # Distributed under the Boost Software License, Version 1.0. (See
6 # accompanying file LICENSE_1_0.txt or copy at
7 # http://www.boost.org/LICENSE_1_0.txt)
9 #########################################################################
10 # The boost threading library can be built on top of different API's
11 # Currently this is the win32 API and the pthreads API.
12 # Pthread is native on unix variants.
13 # To get pthread on windows you need the pthread win32 library
14 # http://sourceware.org/pthreads-win32 which is available under LGPL.
16 # You need to provide the include path and lib path in the variables
17 # PTW32_INCLUDE and PTW32_LIB respectively. You can specify these
18 # paths in site-config.jam, user-config.jam or in the environment.
19 # A new feature is provided to request a specific API:
20 # <threadapi>win32 and <threadapi>pthread.
22 # The naming of the resulting libraries is mostly the same for the
23 # variant native to the build platform, i.e.
24 # boost_thread and the boost specific tagging.
25 # For the library variant that is not native on the build platform
26 # an additional tag is applied:
27 # boost_thread_pthread for the pthread variant on windows, and
28 # boost_thread_win32 for the win32 variant (likely when built on cygwin).
30 # To request the pthread variant on windows, from boost root you would
32 # bjam msvc-8.0 --with-thread install threadapi=pthread
33 #########################################################################
39 import threadapi-feature ;
42 : source-location ../src
43 : requirements <threading>multi
44 #<link>static:<define>BOOST_THREAD_STATIC_LINK=1
45 #<link>shared:<define>BOOST_THREAD_DYN_LINK=1
46 <link>static:<define>BOOST_THREAD_BUILD_LIB=1
47 <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
48 -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
50 <toolset>gcc:<cxxflags>-Wno-long-long
51 #<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
52 #<define>BOOST_SYSTEM_NO_DEPRECATED
53 #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
55 <library>/boost/system//boost_system
56 #-pedantic -ansi -std=gnu++0x -Wextra -fpermissive
58 <toolset>gcc:<cxxflags>-Wextra
59 <toolset>gcc:<cxxflags>-pedantic
60 <toolset>gcc:<cxxflags>-Wno-long-long
61 #<toolset>gcc:<cxxflags>-ansi
62 #<toolset>gcc:<cxxflags>-fpermissive
63 <toolset>gcc-4:<cxxflags>-Wno-variadic-macros
64 <toolset>gcc-5:<cxxflags>-Wno-variadic-macros
65 #<toolset>gcc:<cxxflags>-Wunused-local-typedefs
66 <toolset>gcc:<cxxflags>-Wunused-function
67 <toolset>gcc:<cxxflags>-Wno-unused-parameter
69 <toolset>darwin:<cxxflags>-Wextra
70 <toolset>darwin:<cxxflags>-pedantic
71 #<toolset>darwin:<cxxflags>-ansi
72 <toolset>darwin:<cxxflags>-fpermissive
73 <toolset>darwin:<cxxflags>-Wno-long-long
74 #<toolset>darwin:<cxxflags>-Wno-variadic-macros
75 <toolset>darwin-4:<cxxflags>-Wno-variadic-macros
76 <toolset>darwin-5:<cxxflags>-Wno-variadic-macros
77 #<toolset>darwin:<cxxflags>-Wunused-local-typedefs
78 <toolset>darwin:<cxxflags>-Wunused-function
79 <toolset>darwin:<cxxflags>-Wno-unused-parameter
81 #<toolset>pathscale:<cxxflags>-Wextra
82 <toolset>pathscale:<cxxflags>-Wno-long-long
83 <toolset>pathscale:<cxxflags>-pedantic
85 <toolset>clang:<warnings>on
86 <toolset>clang:<cxxflags>-Wextra
87 #<toolset>clang:<cxxflags>-ansi
88 #<toolset>clang:<cxxflags>-fpermissive
89 <toolset>clang:<cxxflags>-Wno-long-long
90 <toolset>clang:<cxxflags>-Wunused-function
91 <toolset>clang:<cxxflags>-Wno-variadic-macros
92 <toolset>clang:<cxxflags>-Wno-unused-parameter
94 #<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
95 #<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
96 #<toolset>gcc-mingw-4.6.0:<cxxflags>-fdiagnostics-show-option
97 #<toolset>gcc-mingw-4.6.3:<cxxflags>-fdiagnostics-show-option
98 #<toolset>gcc-mingw-4.7.0:<cxxflags>-fdiagnostics-show-option
99 #<toolset>gcc-mingw-4.8.0:<cxxflags>-fdiagnostics-show-option
100 #<toolset>gcc:<cxxflags>-Wno-missing-field-initializers
102 <toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor
103 <toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
105 #<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
106 #<toolset>clang-2.8:<cxxflags>-Wno-unused-function
107 #<toolset>clang-2.9:<cxxflags>-Wno-delete-non-virtual-dtor
108 #<toolset>clang-2.9:<cxxflags>-Wno-unused-function
109 <toolset>clang-3.0:<cxxflags>-Wno-delete-non-virtual-dtor
110 #<toolset>clang-3.0:<cxxflags>-Wno-unused-function
111 #<toolset>clang-3.0:<cxxflags>-Wno-unused-variable
113 # Note: Some of the remarks from the Intel compiler are disabled
114 # remark #193: zero used for undefined preprocessing identifier "XXX"
115 # remark #304: access control not specified ("public" by default)
116 # remark #593: variable "XXX" was set but never used
117 # remark #1418: external function definition with no prior declaration
118 # remark #2415: variable "XXX" of static storage duration was declared but never referenced
120 <toolset>intel:<cxxflags>-wd193,304,383,444
121 <toolset>intel:<cxxflags>-wd593,981
122 <toolset>intel:<cxxflags>-wd1418
123 <toolset>intel:<cxxflags>-wd2415
125 <toolset>msvc:<cxxflags>/wd4100
126 <toolset>msvc:<cxxflags>/wd4512
127 <toolset>msvc:<cxxflags>/wd6246
129 <target-os>windows:<define>WIN32_LEAN_AND_MEAN
130 <target-os>windows:<define>BOOST_USE_WINDOWS_H
132 # : default-build <threading>multi
133 : usage-requirements # pass these requirement to dependents (i.e. users)
134 #<link>static:<define>BOOST_THREAD_STATIC_LINK=1
135 #<link>shared:<define>BOOST_THREAD_DYN_LINK=1
136 <link>static:<define>BOOST_THREAD_BUILD_LIB=1
137 <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
138 #<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
139 #<define>BOOST_SYSTEM_NO_DEPRECATED
140 #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
141 <library>/boost/system//boost_system
144 exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ;
146 rule tag ( name : type ? : property-set )
148 local result = $(name) ;
150 if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
152 local api = [ $(property-set).get <threadapi> ] ;
154 # non native api gets additional tag
155 if $(api) != [ threadapi-feature.get-default $(property-set) ] {
156 result = $(result)_$(api) ;
160 # forward to the boost tagging rule
161 return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
162 $(result) : $(type) : $(property-set) ] ;
165 rule win32_pthread_paths ( properties * )
168 local PTW32_INCLUDE ;
170 PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ;
171 PTW32_LIB = [ modules.peek : PTW32_LIB ] ;
172 PTW32_INCLUDE ?= [ modules.peek user-config : PTW32_INCLUDE ] ;
173 PTW32_LIB ?= [ modules.peek user-config : PTW32_LIB ] ;
174 PTW32_INCLUDE ?= [ modules.peek site-config : PTW32_INCLUDE ] ;
175 PTW32_LIB ?= [ modules.peek site-config : PTW32_LIB ] ;
177 if ! ( $(PTW32_INCLUDE) && $(PTW32_LIB) )
181 echo "************************************************************" ;
182 echo "Trying to build Boost.Thread with pthread support." ;
183 echo "If you need pthread you should specify the paths." ;
184 echo "You can specify them in site-config.jam, user-config.jam" ;
185 echo "or in the environment." ;
186 echo "For example:" ;
187 echo "PTW32_INCLUDE=C:\\Program Files\\ptw32\\Pre-built2\\include" ;
188 echo "PTW32_LIB=C:\\Program Files\\ptw32\\Pre-built2\\lib" ;
189 echo "************************************************************" ;
195 local include_path = [ path.make $(PTW32_INCLUDE) ] ;
196 local lib_path = [ path.make $(PTW32_LIB) ] ;
197 local libname = pthread ;
198 if <toolset>msvc in $(properties)
200 libname = $(libname)VC2.lib ;
202 if <toolset>gcc in $(properties)
204 libname = lib$(libname)GC2.a ;
206 lib_path = [ path.glob $(lib_path) : $(libname) ] ;
211 echo "************************************************************" ;
212 echo "Trying to build Boost.Thread with pthread support." ;
213 echo "But the library" $(libname) "could not be found in path" ;
215 echo "************************************************************" ;
221 result += <include>$(include_path) ;
222 result += <library>$(lib_path) ;
228 rule usage-requirements ( properties * )
231 if <threadapi>pthread in $(properties)
233 result += <define>BOOST_THREAD_POSIX ;
234 if <target-os>windows in $(properties)
236 result += [ win32_pthread_paths $(properties) ] ;
237 # TODO: What is for static linking? Is the <library> also needed
242 #if ! <toolset>vacpp in $(properties) || <toolset-vacpp:version>11.1 in $(properties) || <toolset-vacpp:version>12.1.0.1 in $(properties) || <toolset-vacpp:version>12.1 in $(properties)
244 result += <library>/boost/chrono//boost_chrono ;
250 rule requirements ( properties * )
254 if <threadapi>pthread in $(properties)
256 result += <define>BOOST_THREAD_POSIX ;
257 if <target-os>windows in $(properties)
259 local paths = [ win32_pthread_paths $(properties) ] ;
269 result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
270 if ! [ configure.builds has_atomic_flag_lockfree
271 : $(properties) : "lockfree boost::atomic_flag" ] {
272 result += <library>/boost/atomic//boost_atomic ;
275 result += <define>BOOST_THREAD_USES_CHRONO ;
276 result += <library>/boost/chrono//boost_chrono ;
283 : ## win32 sources ##
293 : ## pthread sources ##
301 explicit thread_sources ;
305 : <conditional>@requirements
307 : <link>shared:<define>BOOST_THREAD_USE_DLL=1
308 <link>static:<define>BOOST_THREAD_USE_LIB=1
309 <conditional>@usage-requirements
312 boost-install boost_thread ;