# $Id$ # Copyright 2006-2007 Roland Schwarz. # Copyright 2007 Anthony Williams # Copyright 2011-2012 Vicente J.Botet Escriba. # Distributed under the Boost Software License, Version 1.0. (See # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) ######################################################################### # The boost threading library can be built on top of different API's # Currently this is the win32 API and the pthreads API. # Pthread is native on unix variants. # To get pthread on windows you need the pthread win32 library # http://sourceware.org/pthreads-win32 which is available under LGPL. # # You need to provide the include path and lib path in the variables # PTW32_INCLUDE and PTW32_LIB respectively. You can specify these # paths in site-config.jam, user-config.jam or in the environment. # A new feature is provided to request a specific API: # win32 and multi #static:BOOST_THREAD_STATIC_LINK=1 #shared:BOOST_THREAD_DYN_LINK=1 static:BOOST_THREAD_BUILD_LIB=1 shared:BOOST_THREAD_BUILD_DLL=1 -@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag @$(__name__).tag gcc:-Wno-long-long #BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED #BOOST_SYSTEM_NO_DEPRECATED #BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS /boost/system//boost_system #-pedantic -ansi -std=gnu++0x -Wextra -fpermissive all gcc:-Wextra gcc:-pedantic gcc:-Wno-long-long #gcc:-ansi #gcc:-fpermissive gcc-4:-Wno-variadic-macros gcc-5:-Wno-variadic-macros #gcc:-Wunused-local-typedefs gcc:-Wunused-function gcc:-Wno-unused-parameter darwin:-Wextra darwin:-pedantic #darwin:-ansi darwin:-fpermissive darwin:-Wno-long-long #darwin:-Wno-variadic-macros darwin-4:-Wno-variadic-macros darwin-5:-Wno-variadic-macros #darwin:-Wunused-local-typedefs darwin:-Wunused-function darwin:-Wno-unused-parameter #pathscale:-Wextra pathscale:-Wno-long-long pathscale:-pedantic clang:on clang:-Wextra #clang:-ansi #clang:-fpermissive clang:-Wno-long-long clang:-Wunused-function clang:-Wno-variadic-macros clang:-Wno-unused-parameter #gcc-mingw-4.4.0:-fdiagnostics-show-option #gcc-mingw-4.5.0:-fdiagnostics-show-option #gcc-mingw-4.6.0:-fdiagnostics-show-option #gcc-mingw-4.6.3:-fdiagnostics-show-option #gcc-mingw-4.7.0:-fdiagnostics-show-option #gcc-mingw-4.8.0:-fdiagnostics-show-option #gcc:-Wno-missing-field-initializers darwin-4.6.2:-Wno-delete-non-virtual-dtor darwin-4.7.0:-Wno-delete-non-virtual-dtor #clang-2.8:-Wno-delete-non-virtual-dtor #clang-2.8:-Wno-unused-function #clang-2.9:-Wno-delete-non-virtual-dtor #clang-2.9:-Wno-unused-function clang-3.0:-Wno-delete-non-virtual-dtor #clang-3.0:-Wno-unused-function #clang-3.0:-Wno-unused-variable # Note: Some of the remarks from the Intel compiler are disabled # remark #193: zero used for undefined preprocessing identifier "XXX" # remark #304: access control not specified ("public" by default) # remark #593: variable "XXX" was set but never used # remark #1418: external function definition with no prior declaration # remark #2415: variable "XXX" of static storage duration was declared but never referenced intel:-wd193,304,383,444 intel:-wd593,981 intel:-wd1418 intel:-wd2415 msvc:/wd4100 msvc:/wd4512 msvc:/wd6246 windows:WIN32_LEAN_AND_MEAN windows:BOOST_USE_WINDOWS_H # : default-build multi : usage-requirements # pass these requirement to dependents (i.e. users) #static:BOOST_THREAD_STATIC_LINK=1 #shared:BOOST_THREAD_DYN_LINK=1 static:BOOST_THREAD_BUILD_LIB=1 shared:BOOST_THREAD_BUILD_DLL=1 #BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED #BOOST_SYSTEM_NO_DEPRECATED #BOOST_THREAD_DONT_PROVIDE_INTERRUPTIONS /boost/system//boost_system ; local rule default_threadapi ( ) { local api = pthread ; if [ os.name ] = "NT" { api = win32 ; } return $(api) ; } feature.feature threadapi : pthread win32 : propagated ; feature.set-default threadapi : [ default_threadapi ] ; exe has_atomic_flag_lockfree : ../build/has_atomic_flag_lockfree_test.cpp ; rule tag ( name : type ? : property-set ) { local result = $(name) ; if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB { local api = [ $(property-set).get ] ; # non native api gets additional tag if $(api) != [ default_threadapi ] { result = $(result)_$(api) ; } } # forward to the boost tagging rule return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag $(result) : $(type) : $(property-set) ] ; } rule win32_pthread_paths ( properties * ) { local result ; local PTW32_INCLUDE ; local PTW32_LIB ; PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ; PTW32_LIB = [ modules.peek : PTW32_LIB ] ; PTW32_INCLUDE ?= [ modules.peek user-config : PTW32_INCLUDE ] ; PTW32_LIB ?= [ modules.peek user-config : PTW32_LIB ] ; PTW32_INCLUDE ?= [ modules.peek site-config : PTW32_INCLUDE ] ; PTW32_LIB ?= [ modules.peek site-config : PTW32_LIB ] ; if ! ( $(PTW32_INCLUDE) && $(PTW32_LIB) ) { if ! $(.notified) { echo "************************************************************" ; echo "Trying to build Boost.Thread with pthread support." ; echo "If you need pthread you should specify the paths." ; echo "You can specify them in site-config.jam, user-config.jam" ; echo "or in the environment." ; echo "For example:" ; echo "PTW32_INCLUDE=C:\\Program Files\\ptw32\\Pre-built2\\include" ; echo "PTW32_LIB=C:\\Program Files\\ptw32\\Pre-built2\\lib" ; echo "************************************************************" ; .notified = true ; } } else { local include_path = [ path.make $(PTW32_INCLUDE) ] ; local lib_path = [ path.make $(PTW32_LIB) ] ; local libname = pthread ; if msvc in $(properties) { libname = $(libname)VC2.lib ; } if gcc in $(properties) { libname = lib$(libname)GC2.a ; } lib_path = [ path.glob $(lib_path) : $(libname) ] ; if ! $(lib_path) { if ! $(.notified) { echo "************************************************************" ; echo "Trying to build Boost.Thread with pthread support." ; echo "But the library" $(libname) "could not be found in path" ; echo $(PTW32_LIB) ; echo "************************************************************" ; .notified = true ; } } else { result += $(include_path) ; result += $(lib_path) ; } } return $(result) ; } rule usage-requirements ( properties * ) { local result ; if pthread in $(properties) { result += BOOST_THREAD_POSIX ; if windows in $(properties) { result += [ win32_pthread_paths $(properties) ] ; # TODO: What is for static linking? Is the also needed # in that case? } } #if ! vacpp in $(properties) || 11.1 in $(properties) || 12.1.0.1 in $(properties) || 12.1 in $(properties) #{ result += /boost/chrono//boost_chrono ; #} return $(result) ; } rule requirements ( properties * ) { local result ; if pthread in $(properties) { result += BOOST_THREAD_POSIX ; if windows in $(properties) { local paths = [ win32_pthread_paths $(properties) ] ; if $(paths) { result += $(paths) ; } else { result = no ; } } result += BOOST_THREAD_DONT_USE_CHRONO ; if ! [ configure.builds has_atomic_flag_lockfree : $(properties) : "lockfree boost::atomic_flag" ] { result += /boost/atomic//boost_atomic ; } } else { result += BOOST_THREAD_USES_CHRONO ; result += /boost/chrono//boost_chrono ; } return $(result) ; } alias thread_sources : ## win32 sources ## win32/thread.cpp win32/tss_dll.cpp win32/tss_pe.cpp future.cpp : ## requirements ## win32 ; alias thread_sources : ## pthread sources ## pthread/thread.cpp pthread/once.cpp future.cpp : ## requirements ## pthread ; explicit thread_sources ; lib boost_thread : thread_sources : @requirements : : shared:BOOST_THREAD_USE_DLL=1 static:BOOST_THREAD_USE_LIB=1 @usage-requirements ; boost-install boost_thread ;