]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # $Id$ |
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) | |
8 | ||
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. | |
15 | # | |
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: | |
b32b8144 | 20 | # <threadapi>win32 and <threadapi>pthread. |
7c673cae FG |
21 | # |
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). | |
29 | # | |
30 | # To request the pthread variant on windows, from boost root you would | |
31 | # say e.g: | |
32 | # bjam msvc-8.0 --with-thread install threadapi=pthread | |
33 | ######################################################################### | |
34 | ||
35 | import os ; | |
7c673cae FG |
36 | import indirect ; |
37 | import path ; | |
38 | import configure ; | |
b32b8144 | 39 | import threadapi-feature ; |
7c673cae FG |
40 | |
41 | project boost/thread | |
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 | |
49 | <tag>@$(__name__).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 | |
54 | ||
55 | <library>/boost/system//boost_system | |
56 | #-pedantic -ansi -std=gnu++0x -Wextra -fpermissive | |
57 | <warnings>all | |
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 | |
68 | ||
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 | |
80 | ||
81 | #<toolset>pathscale:<cxxflags>-Wextra | |
82 | <toolset>pathscale:<cxxflags>-Wno-long-long | |
83 | <toolset>pathscale:<cxxflags>-pedantic | |
84 | ||
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 | |
93 | ||
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 | |
101 | ||
102 | <toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor | |
103 | <toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor | |
104 | ||
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 | |
112 | ||
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 | |
119 | ||
120 | <toolset>intel:<cxxflags>-wd193,304,383,444 | |
121 | <toolset>intel:<cxxflags>-wd593,981 | |
122 | <toolset>intel:<cxxflags>-wd1418 | |
123 | <toolset>intel:<cxxflags>-wd2415 | |
124 | ||
125 | <toolset>msvc:<cxxflags>/wd4100 | |
126 | <toolset>msvc:<cxxflags>/wd4512 | |
127 | <toolset>msvc:<cxxflags>/wd6246 | |
128 | ||
129 | <target-os>windows:<define>WIN32_LEAN_AND_MEAN | |
130 | <target-os>windows:<define>BOOST_USE_WINDOWS_H | |
131 | ||
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 | |
142 | ; | |
143 | ||
7c673cae FG |
144 | exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ; |
145 | ||
146 | rule tag ( name : type ? : property-set ) | |
147 | { | |
148 | local result = $(name) ; | |
149 | ||
150 | if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB | |
151 | { | |
152 | local api = [ $(property-set).get <threadapi> ] ; | |
153 | ||
154 | # non native api gets additional tag | |
b32b8144 | 155 | if $(api) != [ threadapi-feature.get-default $(property-set) ] { |
7c673cae FG |
156 | result = $(result)_$(api) ; |
157 | } | |
158 | } | |
159 | ||
160 | # forward to the boost tagging rule | |
161 | return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag | |
162 | $(result) : $(type) : $(property-set) ] ; | |
163 | } | |
164 | ||
165 | rule win32_pthread_paths ( properties * ) | |
166 | { | |
167 | local result ; | |
168 | local PTW32_INCLUDE ; | |
169 | local PTW32_LIB ; | |
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 ] ; | |
176 | ||
177 | if ! ( $(PTW32_INCLUDE) && $(PTW32_LIB) ) | |
178 | { | |
179 | if ! $(.notified) | |
180 | { | |
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 "************************************************************" ; | |
190 | .notified = true ; | |
191 | } | |
192 | } | |
193 | else | |
194 | { | |
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) | |
199 | { | |
200 | libname = $(libname)VC2.lib ; | |
201 | } | |
202 | if <toolset>gcc in $(properties) | |
203 | { | |
204 | libname = lib$(libname)GC2.a ; | |
205 | } | |
206 | lib_path = [ path.glob $(lib_path) : $(libname) ] ; | |
207 | if ! $(lib_path) | |
208 | { | |
209 | if ! $(.notified) | |
210 | { | |
211 | echo "************************************************************" ; | |
212 | echo "Trying to build Boost.Thread with pthread support." ; | |
213 | echo "But the library" $(libname) "could not be found in path" ; | |
214 | echo $(PTW32_LIB) ; | |
215 | echo "************************************************************" ; | |
216 | .notified = true ; | |
217 | } | |
218 | } | |
219 | else | |
220 | { | |
221 | result += <include>$(include_path) ; | |
222 | result += <library>$(lib_path) ; | |
223 | } | |
224 | } | |
225 | return $(result) ; | |
226 | } | |
227 | ||
228 | rule usage-requirements ( properties * ) | |
229 | { | |
230 | local result ; | |
231 | if <threadapi>pthread in $(properties) | |
232 | { | |
233 | result += <define>BOOST_THREAD_POSIX ; | |
234 | if <target-os>windows in $(properties) | |
235 | { | |
236 | result += [ win32_pthread_paths $(properties) ] ; | |
237 | # TODO: What is for static linking? Is the <library> also needed | |
238 | # in that case? | |
239 | } | |
240 | } | |
241 | ||
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) | |
243 | #{ | |
244 | result += <library>/boost/chrono//boost_chrono ; | |
245 | #} | |
246 | ||
247 | return $(result) ; | |
248 | } | |
249 | ||
250 | rule requirements ( properties * ) | |
251 | { | |
252 | local result ; | |
253 | ||
254 | if <threadapi>pthread in $(properties) | |
255 | { | |
256 | result += <define>BOOST_THREAD_POSIX ; | |
257 | if <target-os>windows in $(properties) | |
258 | { | |
259 | local paths = [ win32_pthread_paths $(properties) ] ; | |
260 | if $(paths) | |
261 | { | |
262 | result += $(paths) ; | |
263 | } | |
264 | else | |
265 | { | |
266 | result = <build>no ; | |
267 | } | |
268 | } | |
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 ; | |
273 | } | |
274 | } else { | |
275 | result += <define>BOOST_THREAD_USES_CHRONO ; | |
276 | result += <library>/boost/chrono//boost_chrono ; | |
277 | } | |
278 | ||
279 | return $(result) ; | |
280 | } | |
281 | ||
282 | alias thread_sources | |
283 | : ## win32 sources ## | |
284 | win32/thread.cpp | |
285 | win32/tss_dll.cpp | |
286 | win32/tss_pe.cpp | |
287 | future.cpp | |
288 | : ## requirements ## | |
289 | <threadapi>win32 | |
290 | ; | |
291 | ||
292 | alias thread_sources | |
293 | : ## pthread sources ## | |
294 | pthread/thread.cpp | |
295 | pthread/once.cpp | |
296 | future.cpp | |
297 | : ## requirements ## | |
298 | <threadapi>pthread | |
299 | ; | |
300 | ||
301 | explicit thread_sources ; | |
302 | ||
303 | lib boost_thread | |
304 | : thread_sources | |
305 | : <conditional>@requirements | |
306 | : | |
307 | : <link>shared:<define>BOOST_THREAD_USE_DLL=1 | |
308 | <link>static:<define>BOOST_THREAD_USE_LIB=1 | |
309 | <conditional>@usage-requirements | |
310 | ; | |
311 | ||
312 | boost-install boost_thread ; |