Jamfile.v2 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. # The boost threading library can be built on top of different API's
  10. # Currently this is the win32 API and the pthreads API.
  11. # Pthread is native on unix variants.
  12. # To get pthread on windows you need the pthread win32 library
  13. # http://sourceware.org/pthreads-win32 which is available under LGPL.
  14. #
  15. # You need to provide the include path and lib path in the variables
  16. # PTW32_INCLUDE and PTW32_LIB respectively. You can specify these
  17. # paths in site-config.jam, user-config.jam or in the environment.
  18. # A new feature is provided to request a specific API:
  19. # <threadapi>win32 and <threadapi>pthread.
  20. #
  21. # The naming of the resulting libraries is mostly the same for the
  22. # variant native to the build platform, i.e.
  23. # boost_thread and the boost specific tagging.
  24. # For the library variant that is not native on the build platform
  25. # an additional tag is applied:
  26. # boost_thread_pthread for the pthread variant on windows, and
  27. # boost_thread_win32 for the win32 variant (likely when built on cygwin).
  28. #
  29. # To request the pthread variant on windows, from boost root you would
  30. # say e.g:
  31. # bjam msvc-8.0 --with-thread install threadapi=pthread
  32. #########################################################################
  33. import os ;
  34. import indirect ;
  35. import path ;
  36. import configure ;
  37. import threadapi-feature ;
  38. exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ;
  39. project boost/thread
  40. : source-location ../src
  41. : requirements <threading>multi
  42. #<link>static:<define>BOOST_THREAD_STATIC_LINK=1
  43. #<link>shared:<define>BOOST_THREAD_DYN_LINK=1
  44. <link>static:<define>BOOST_THREAD_BUILD_LIB=1
  45. <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
  46. -<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
  47. <tag>@$(__name__).tag
  48. <toolset>gcc:<cxxflags>-Wno-long-long
  49. #<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
  50. #<define>BOOST_SYSTEM_NO_DEPRECATED
  51. #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
  52. #-pedantic -ansi -std=gnu++0x -Wextra -fpermissive
  53. <warnings>all
  54. <toolset>gcc:<cxxflags>-Wextra
  55. <toolset>gcc:<cxxflags>-pedantic
  56. <toolset>gcc:<cxxflags>-Wno-long-long
  57. #<toolset>gcc:<cxxflags>-ansi
  58. #<toolset>gcc:<cxxflags>-fpermissive
  59. <toolset>gcc-4:<cxxflags>-Wno-variadic-macros
  60. <toolset>gcc-5:<cxxflags>-Wno-variadic-macros
  61. #<toolset>gcc:<cxxflags>-Wunused-local-typedefs
  62. <toolset>gcc:<cxxflags>-Wunused-function
  63. <toolset>gcc:<cxxflags>-Wno-unused-parameter
  64. <toolset>darwin:<cxxflags>-Wextra
  65. <toolset>darwin:<cxxflags>-pedantic
  66. #<toolset>darwin:<cxxflags>-ansi
  67. <toolset>darwin:<cxxflags>-fpermissive
  68. <toolset>darwin:<cxxflags>-Wno-long-long
  69. #<toolset>darwin:<cxxflags>-Wno-variadic-macros
  70. <toolset>darwin-4:<cxxflags>-Wno-variadic-macros
  71. <toolset>darwin-5:<cxxflags>-Wno-variadic-macros
  72. #<toolset>darwin:<cxxflags>-Wunused-local-typedefs
  73. <toolset>darwin:<cxxflags>-Wunused-function
  74. <toolset>darwin:<cxxflags>-Wno-unused-parameter
  75. #<toolset>pathscale:<cxxflags>-Wextra
  76. <toolset>pathscale:<cxxflags>-Wno-long-long
  77. <toolset>pathscale:<cxxflags>-pedantic
  78. <toolset>clang:<warnings>on
  79. <toolset>clang:<cxxflags>-Wextra
  80. #<toolset>clang:<cxxflags>-ansi
  81. #<toolset>clang:<cxxflags>-fpermissive
  82. <toolset>clang:<cxxflags>-Wno-long-long
  83. <toolset>clang:<cxxflags>-Wunused-function
  84. <toolset>clang:<cxxflags>-Wno-variadic-macros
  85. <toolset>clang:<cxxflags>-Wno-unused-parameter
  86. #<toolset>gcc-mingw-4.4.0:<cxxflags>-fdiagnostics-show-option
  87. #<toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
  88. #<toolset>gcc-mingw-4.6.0:<cxxflags>-fdiagnostics-show-option
  89. #<toolset>gcc-mingw-4.6.3:<cxxflags>-fdiagnostics-show-option
  90. #<toolset>gcc-mingw-4.7.0:<cxxflags>-fdiagnostics-show-option
  91. #<toolset>gcc-mingw-4.8.0:<cxxflags>-fdiagnostics-show-option
  92. #<toolset>gcc:<cxxflags>-Wno-missing-field-initializers
  93. <toolset>darwin-4.6.2:<cxxflags>-Wno-delete-non-virtual-dtor
  94. <toolset>darwin-4.7.0:<cxxflags>-Wno-delete-non-virtual-dtor
  95. #<toolset>clang-2.8:<cxxflags>-Wno-delete-non-virtual-dtor
  96. #<toolset>clang-2.8:<cxxflags>-Wno-unused-function
  97. #<toolset>clang-2.9:<cxxflags>-Wno-delete-non-virtual-dtor
  98. #<toolset>clang-2.9:<cxxflags>-Wno-unused-function
  99. <toolset>clang-3.0:<cxxflags>-Wno-delete-non-virtual-dtor
  100. #<toolset>clang-3.0:<cxxflags>-Wno-unused-function
  101. #<toolset>clang-3.0:<cxxflags>-Wno-unused-variable
  102. # Note: Some of the remarks from the Intel compiler are disabled
  103. # remark #193: zero used for undefined preprocessing identifier "XXX"
  104. # remark #304: access control not specified ("public" by default)
  105. # remark #593: variable "XXX" was set but never used
  106. # remark #1418: external function definition with no prior declaration
  107. # remark #2415: variable "XXX" of static storage duration was declared but never referenced
  108. <toolset>intel:<cxxflags>-wd193,304,383,444
  109. <toolset>intel:<cxxflags>-wd593,981
  110. <toolset>intel:<cxxflags>-wd1418
  111. <toolset>intel:<cxxflags>-wd2415
  112. <toolset>msvc:<cxxflags>/wd4100
  113. <toolset>msvc:<cxxflags>/wd4512
  114. <toolset>msvc:<cxxflags>/wd6246
  115. <target-os>windows:<define>WIN32_LEAN_AND_MEAN
  116. <target-os>windows:<define>BOOST_USE_WINDOWS_H
  117. # : default-build <threading>multi
  118. : usage-requirements # pass these requirement to dependents (i.e. users)
  119. #<link>static:<define>BOOST_THREAD_STATIC_LINK=1
  120. #<link>shared:<define>BOOST_THREAD_DYN_LINK=1
  121. <link>static:<define>BOOST_THREAD_BUILD_LIB=1
  122. <link>shared:<define>BOOST_THREAD_BUILD_DLL=1
  123. #<define>BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED
  124. #<define>BOOST_SYSTEM_NO_DEPRECATED
  125. #<define>BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS
  126. ;
  127. rule tag ( name : type ? : property-set )
  128. {
  129. local result = $(name) ;
  130. if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
  131. {
  132. local api = [ $(property-set).get <threadapi> ] ;
  133. # non native api gets additional tag
  134. if $(api) != [ threadapi-feature.get-default $(property-set) ] {
  135. result = $(result)_$(api) ;
  136. }
  137. }
  138. # forward to the boost tagging rule
  139. return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
  140. $(result) : $(type) : $(property-set) ] ;
  141. }
  142. rule win32_pthread_paths ( properties * )
  143. {
  144. local result ;
  145. local PTW32_INCLUDE ;
  146. local PTW32_LIB ;
  147. PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ;
  148. PTW32_LIB = [ modules.peek : PTW32_LIB ] ;
  149. PTW32_INCLUDE ?= [ modules.peek user-config : PTW32_INCLUDE ] ;
  150. PTW32_LIB ?= [ modules.peek user-config : PTW32_LIB ] ;
  151. PTW32_INCLUDE ?= [ modules.peek site-config : PTW32_INCLUDE ] ;
  152. PTW32_LIB ?= [ modules.peek site-config : PTW32_LIB ] ;
  153. if ! ( $(PTW32_INCLUDE) && $(PTW32_LIB) )
  154. {
  155. if ! $(.notified)
  156. {
  157. echo "************************************************************" ;
  158. echo "Trying to build Boost.Thread with pthread support." ;
  159. echo "If you need pthread you should specify the paths." ;
  160. echo "You can specify them in site-config.jam, user-config.jam" ;
  161. echo "or in the environment." ;
  162. echo "For example:" ;
  163. echo "PTW32_INCLUDE=C:\\Program Files\\ptw32\\Pre-built2\\include" ;
  164. echo "PTW32_LIB=C:\\Program Files\\ptw32\\Pre-built2\\lib" ;
  165. echo "************************************************************" ;
  166. .notified = true ;
  167. }
  168. }
  169. else
  170. {
  171. local include_path = [ path.make $(PTW32_INCLUDE) ] ;
  172. local lib_path = [ path.make $(PTW32_LIB) ] ;
  173. local libname = pthread ;
  174. if <toolset>msvc in $(properties)
  175. {
  176. libname = $(libname)VC2.lib ;
  177. }
  178. if <toolset>gcc in $(properties)
  179. {
  180. libname = lib$(libname)GC2.a ;
  181. }
  182. lib_path = [ path.glob $(lib_path) : $(libname) ] ;
  183. if ! $(lib_path)
  184. {
  185. if ! $(.notified)
  186. {
  187. echo "************************************************************" ;
  188. echo "Trying to build Boost.Thread with pthread support." ;
  189. echo "But the library" $(libname) "could not be found in path" ;
  190. echo $(PTW32_LIB) ;
  191. echo "************************************************************" ;
  192. .notified = true ;
  193. }
  194. }
  195. else
  196. {
  197. result += <include>$(include_path) ;
  198. result += <library>$(lib_path) ;
  199. }
  200. }
  201. return $(result) ;
  202. }
  203. rule usage-requirements ( properties * )
  204. {
  205. local result ;
  206. if <threadapi>pthread in $(properties)
  207. {
  208. result += <define>BOOST_THREAD_POSIX ;
  209. if <target-os>windows in $(properties)
  210. {
  211. result += [ win32_pthread_paths $(properties) ] ;
  212. # TODO: What is for static linking? Is the <library> also needed
  213. # in that case?
  214. }
  215. }
  216. if <threadapi>win32 in $(properties)
  217. {
  218. result += <define>BOOST_THREAD_WIN32 ;
  219. }
  220. #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)
  221. #{
  222. result += <library>/boost/chrono//boost_chrono ;
  223. #}
  224. return $(result) ;
  225. }
  226. rule requirements ( properties * )
  227. {
  228. local result ;
  229. if <threadapi>pthread in $(properties)
  230. {
  231. result += <define>BOOST_THREAD_POSIX ;
  232. if <target-os>windows in $(properties)
  233. {
  234. local paths = [ win32_pthread_paths $(properties) ] ;
  235. if $(paths)
  236. {
  237. result += $(paths) ;
  238. }
  239. else
  240. {
  241. result = <build>no ;
  242. }
  243. }
  244. result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
  245. if ! [ configure.builds has_atomic_flag_lockfree
  246. : $(properties) : "lockfree boost::atomic_flag" ] {
  247. result += <library>/boost/atomic//boost_atomic ;
  248. }
  249. } else {
  250. if <threadapi>win32 in $(properties)
  251. {
  252. result += <define>BOOST_THREAD_WIN32 ;
  253. }
  254. result += <define>BOOST_THREAD_USES_CHRONO ;
  255. result += <library>/boost/chrono//boost_chrono ;
  256. }
  257. return $(result) ;
  258. }
  259. alias thread_sources
  260. : ## win32 sources ##
  261. win32/thread.cpp
  262. win32/tss_dll.cpp
  263. win32/tss_pe.cpp
  264. win32/thread_primitives.cpp
  265. future.cpp
  266. : ## requirements ##
  267. <threadapi>win32
  268. ;
  269. alias thread_sources
  270. : ## pthread sources ##
  271. pthread/thread.cpp
  272. pthread/once.cpp
  273. future.cpp
  274. : ## requirements ##
  275. <threadapi>pthread
  276. ;
  277. explicit thread_sources ;
  278. lib boost_thread
  279. : thread_sources
  280. : <conditional>@requirements
  281. :
  282. : <link>shared:<define>BOOST_THREAD_USE_DLL=1
  283. <link>static:<define>BOOST_THREAD_USE_LIB=1
  284. <conditional>@usage-requirements
  285. ;
  286. boost-install boost_thread ;