Index: Jamroot =================================================================== --- Jamroot (revision 40459) +++ Jamroot (working copy) @@ -99,6 +99,7 @@ path-constant BOOST_ROOT : . ; constant BOOST_VERSION : 1.35.0 ; +constant BOOST_JAMROOT_MODULE : $(__name__) ; local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] ; if $(version-tag[3]) = 0 Index: libs/thread/build/Jamfile.v2 =================================================================== --- libs/thread/build/Jamfile.v2 (revision 40459) +++ libs/thread/build/Jamfile.v2 (working copy) @@ -1,83 +1,177 @@ -# Copyright 2006 Roland Schwarz. +# $Id$ +# Copyright 2006-2007 Roland Schwarz. # Copyright 2007 Anthony Williams # 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_BUILD_LIB=1 shared:BOOST_THREAD_BUILD_DLL=1 - : default-build multi + -@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag + @$(__name__).tagi + : default-build multi ; -BOOST_PTHREAD_OPTS = BOOST_THREAD_POSIX ; +local rule default_threadapi ( ) +{ + local api = pthread ; + if [ os.name ] = "NT" { api = win32 ; } + return $(api) ; +} -if [ os.name ] = "NT" +feature.feature threadapi : pthread win32 : propagated ; +feature.set-default threadapi : [ default_threadapi ] ; + +rule tagi ( name : type ? : property-set ) { - AVAILABLE_THREAD_APIS = win32 ; - - local PTW32_INCLUDE = [ modules.peek : PTW32_INCLUDE ] ; - local PTW32_LIB = [ modules.peek : PTW32_LIB ] ; - if $(PTW32_INCLUDE) && $(PTW32_LIB) - { - BOOST_PTHREAD_OPTS += - BOOST_HAS_PTHREADS - $(PTW32_INCLUDE) - $(PTW32_LIB) ; + local result = $(name) ; + + if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB + { + local api = [ $(property-set).get ] ; - AVAILABLE_THREAD_APIS += pthread ; + # non native api gets additional tag + if $(api) != [ default_threadapi ] { + result = $(result)_$(api) ; } - else - { - echo "******************************************************" ; - echo "Building Boost.Thread without optional pthread support" ; - echo "If you need pthread you should specify the paths." ; - echo "For example:" ; - echo "PTW32_INCLUDE=C:\\Program Files\\ptw32\\Pre-built2\\include" ; - echo "PTW32_LIB=C:\\Program Files\\ptw32\\Pre-built2\\lib\\pthreadVC2.lib" ; - echo "******************************************************" ; - BOOST_PTHREAD_OPTS += no ; - } + } + + # forward to the boost tagging rule + return [ indirect.call $(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag + $(result) : $(type) : $(property-set) ] ; } -else + + +rule requirements ( properties * ) { - AVAILABLE_THREAD_APIS = pthread ; - if [ os.name ] = CYGWIN + local result ; + if pthread in $(properties) + { + result += BOOST_THREAD_POSIX ; + if windows in $(properties) { - AVAILABLE_THREAD_APIS += win32 ; - } + 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 ; + } + result = no ; + } + else + { + local include_path = [ path.make $(PTW32_INCLUDE) ] ; + local lib_path = [ path.make $(PTW32_LIB) ] ; + result += $(include_path) ; + 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 ; + } + result = no ; + } + result += $(lib_path) ; + + } + } + } + return $(result) ; } -feature.feature thrd-api : $(AVAILABLE_THREAD_APIS) : propagated composite ; -feature.compose pthread : $(BOOST_PTHREAD_OPTS) ; +alias thread_sources + : ## win32 sources ## + win32/thread.cpp + win32/exceptions.cpp + win32/xtime.cpp + win32/tss.cpp + win32/tss_hooks.cpp + win32/tss_dll.cpp + win32/tss_pe.cpp + : ## requirements ## + win32 + ; -lib boost_thread - : ## sources ## - win32/thread.cpp - win32/exceptions.cpp - win32/xtime.cpp - win32/tss.cpp - win32/tss_hooks.cpp - win32/tss_dll.cpp - win32/tss_pe.cpp - : ## requirements ## - win32 - ; +alias thread_sources + : ## pthread sources ## + pthread/thread.cpp + pthread/exceptions.cpp + pthread/xtime.cpp + pthread/tss.cpp + : ## requirements ## + pthread + ; -# build the pthread based variant +explicit thread_sources ; + lib boost_thread - : ## sources ## - pthread/thread.cpp - pthread/exceptions.cpp - pthread/xtime.cpp - pthread/tss.cpp - : ## requirements ## - pthread - $(BOOST_PTHREAD_OPTS) - ; - + : thread_sources + : @requirements + ; Index: tools/build/v2/build/property.jam =================================================================== --- tools/build/v2/build/property.jam (revision 40459) +++ tools/build/v2/build/property.jam (working copy) @@ -455,19 +455,28 @@ local m = [ MATCH ^@(.+) : $(p:G=) ] ; if $(m) { - if ! [ MATCH ".*([.]).*" : $(m) ] + local v ; + if ! [ MATCH "^([^%]*)%([^%]+)$" : $(m) ] { - # This is unqualified rule name. The user might want - # to set flags on this rule name, and toolset.flag - # auto-qualifies the rule name. Need to do the same - # here so set flag setting work. - # We can arrange for toolset.flag to *not* auto-qualify - # the argument, but then two rules defined in two Jamfiles - # will conflict. - m = $(context-module).$(m) ; + if ! [ MATCH ".*([.]).*" : $(m) ] + { + # This is unqualified rule name. The user might want + # to set flags on this rule name, and toolset.flag + # auto-qualifies the rule name. Need to do the same + # here so set flag setting work. + # We can arrange for toolset.flag to *not* auto-qualify + # the argument, but then two rules defined in two Jamfiles + # will conflict. + m = $(context-module).$(m) ; + } + + v = [ indirect.make $(m) : $(context-module) ] ; } + else + { # rule is already in indirect format + v = $(m) ; + } - local v = [ indirect.make $(m) : $(context-module) ] ; v = @$(v) ; result += $(v:G=$(p:G)) ; }