diff options
author | Kenneth Heafield <github@kheafield.com> | 2011-11-23 23:12:44 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2011-11-23 23:12:44 +0400 |
commit | 1a4dba45b3ec3c51666fef5355c0ecbddbdf484c (patch) | |
tree | f8d524320b25a034bcec07f0177483d1874ecd29 /Jamroot | |
parent | aec299c1c979bdd478962a154032081a9a692c17 (diff) |
Backwards compatible boost selection. Apparently boost.jam sucks at old versions. Go back to manual boost with shell scripts.
Diffstat (limited to 'Jamroot')
-rw-r--r-- | Jamroot | 70 |
1 files changed, 45 insertions, 25 deletions
@@ -36,34 +36,63 @@ path-constant TOP : . ; +# Shell with trailing line removed http://lists.boost.org/boost-build/2007/08/17051.php +rule trim-nl ( str ) { + return [ MATCH "([^ +]*)" : $(str) ] ; +} +rule _shell ( cmd ) { + return [ trim-nl [ SHELL $(cmd) ] ] ; +} + import option ; -import boost ; -boost.use-project ; -#If boost static libraries are not installed, use dynamic linking. -if [ SHELL $(TOP)"/jam-files/test.sh -static -lboost_program_options" ] != 0 { - force-boost-link = "<link>shared" ; + +rule test_flags ( flags ) { + if [ SHELL $(TOP)"/jam-files/test.sh "$(flags) ] = 0 { + return true ; + } else { + return ; + } +} + +rule auto_shared ( name ) { + if [ test_flags "-static -l "$(name) ] { + return ; + } else { + return "<link>shared" ; + } } + +#Are we +boost-auto-shared = [ auto_shared "boost_program_options" ] ; #Convenience rule for boost libraries. Defines library boost_$(name). -rule boost_lib ( name ) { - alias boost_$(name) : /boost//$(name) : $(force-boost-link) ; +rule boost_lib ( name macro ) { +#Link multi-threaded programs against the -mt version if available. Old +#versions of boost do not have -mt tagged versions of all libraries. Sadly, +#boost.jam does not handle this correctly. + if [ test_flags "-l"$(name)"-mt" ] { + lib inner_boost_$(name) : : <threading>single <name>boost_$(name) ; + lib inner_boost_$(name) : : <threading>multi <name>boost_$(name)-mt ; + } else { + lib inner_boost_$(name) : : <name>boost_$(name) ; + } + + alias boost_$(name) : inner_boost_$(name) : $(boost-auto-shared) : : <link>shared:<define>BOOST_$(macro) ; } -boost_lib thread ; -boost_lib program_options ; -boost_lib unit_test_framework ; +#See tools/build/v2/contrib/boost.jam in a boost distribution for a table of macros to define. +boost_lib thread THREAD_DYN_DLL ; +boost_lib program_options PROGRAM_OPTIONS_DYN_LINK ; +boost_lib unit_test_framework TEST_DYN_LINK ; #Link normally to a library, but sometimes static isn't installed so fall back to dynamic. rule external_lib ( name ) { - if [ SHELL $(TOP)"/jam-files/test.sh -static -l"$(name) ] != 0 { - lib $(name) : : <link>shared ; - } else { - lib $(name) ; - } + lib $(name) : : [ auto_shared $(name) ] ; } external_lib z ; #libSegFault prints a stack trace on segfault. Link against it if available. -if [ SHELL $(TOP)"/jam-files/test.sh -lSegFault" ] = 0 { +if [ test_flags "-lSegfault" ] { external_lib SegFault ; segfault = <library>SegFault ; } @@ -95,15 +124,6 @@ build-project moses-chart-cmd/src ; install-location = [ option.get "install" : $(TOP)/dist ] ; -# Shell with trailing line removed http://lists.boost.org/boost-build/2007/08/17051.php -rule trim-nl ( str ) { - return [ MATCH "([^ -]*)" : $(str) ] ; -} -rule _shell ( cmd ) { - return [ trim-nl [ SHELL $(cmd) ] ] ; -} - if [ option.get "git" : : "yes" ] { install-tag = [ _shell "git rev-parse --verify HEAD |head -c 7" ] ; install-location = $(install-location).$(install-tag) ; |