From 770539e5b8a90271bd8253200686e24d129be499 Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Mon, 11 Jun 2012 20:57:42 +1000 Subject: [PATCH 1/4] Add support for Boost.Timer --- build-aux/boost.m4 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index 3d4e47c..cefce28 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -877,6 +877,28 @@ CPPFLAGS=$boost_threads_save_CPPFLAGS ])# BOOST_THREADS +# BOOST_TIMER([PREFERRED-RT-OPT]) +# ----------------------------------------- +# Look for Boost.Timer. For the documentation of PREFERRED-RT-OPT, +# see the documentation of BOOST_FIND_LIB above. +BOOST_DEFUN([Timer], +[BOOST_SYSTEM([$1]) +boost_timer_save_LIBS=$LIBS +boost_timer_save_LDFLAGS=$LDFLAGS +m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl +LIBS="$LIBS $BOOST_SYSTEM_LIBS" +LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" +if test $enable_static_boost = yes; then + AC_SUBST([BOOST_TIMER_LIBS], ["$BOOST_TIMER_LIBS $BOOST_SYSTEM_LIBS"]) +fi +BOOST_FIND_LIB([timer], [$1], + [boost/timer/timer.hpp], + [boost::timer::cpu_timer t;]) +LIBS=$boost_timer_save_LIBS +LDFLAGS=$boost_timer_save_LDFLAGS +])# BOOST_TIMER + + # BOOST_TOKENIZER() # ----------------- # Look for Boost.Tokenizer From 92a23600c1278d48fdf4bfeacd9dd44cb811fb6b Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Mon, 11 Jun 2012 22:57:14 +1000 Subject: [PATCH 2/4] Cache the search paths and reuse them for subsequent library checks This optimises the way libraries are searched for. With a dynamic link, the tag name is searched for independently of the library path. This results in approximately six times fewer attempted links. For both dynamic and static links, once a tag name and library path are found, the values are cached and tried first when searching for subsequent libraries. This results in a huge speed increase for the second and later library checks. --- build-aux/boost.m4 | 142 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 107 insertions(+), 35 deletions(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index cefce28..9a71413 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -360,40 +360,107 @@ dnl start the for loops). boost_failed_libs= # Don't bother to ident the 6 nested for loops, only the 2 innermost ones # matter. +boost_full_tags= for boost_tag_ in -$boost_cv_lib_tag ''; do for boost_ver_ in -$boost_cv_lib_version ''; do for boost_mt_ in $boost_mt -mt ''; do for boost_rtopt_ in $boost_rtopt '' -d; do - for boost_lib in \ - boost_$1$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ - boost_$1$boost_tag_$boost_rtopt_$boost_ver_ \ - boost_$1$boost_tag_$boost_mt_$boost_ver_ \ - boost_$1$boost_tag_$boost_ver_ + for boost_suffix in \ + $boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ \ + $boost_tag_$boost_rtopt_$boost_ver_ \ + $boost_tag_$boost_mt_$boost_ver_ \ + $boost_tag_$boost_ver_ do - # Avoid testing twice the same lib - case $boost_failed_libs in #( - *@$boost_lib@*) continue;; - esac - # If with_boost is empty, we'll search in /lib first, which is not quite - # right so instead we'll try to a location based on where the headers are. - boost_tmp_lib=$with_boost - test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} - for boost_ldpath in "$boost_tmp_lib/lib" '' \ - /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ - "$with_boost" C:/Boost/lib /lib* - do - test -e "$boost_ldpath" || continue - boost_save_LDFLAGS=$LDFLAGS - # Are we looking for a static library? - case $boost_ldpath:$boost_rtopt_ in #( - *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) - Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" - test -e "$Boost_lib_LIBS" || continue;; #( - *) # No: use -lboost_foo to find the shared library. - Boost_lib_LIBS="-l$boost_lib";; - esac - boost_save_LIBS=$LIBS + boost_full_tags="$boost_full_tags $boost_suffix" + done +done +done +done +done + +# If with_boost is empty, we'll search in /lib first, which is not quite +# right so instead we'll try to a location based on where the headers are. +boost_tmp_lib=$with_boost +test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} + +# Create some compiler parameters for each existing directory of the known +# possibilities where Boost might be. +boost_all_ldpaths= +for boost_ldpath in "$boost_tmp_lib/lib" \ + /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ + "$with_boost" C:/Boost/lib /lib* +do + test -e "$boost_ldpath" || continue + boost_all_ldpaths="$boost_all_ldpaths -L$boost_ldpath" +done + +boost_save_LDFLAGS=$LDFLAGS +boost_save_LIBS=$LIBS +for boost_tag_ in "$last_boost_tag" $boost_full_tags ''; do + boost_lib=boost_$1$boost_tag_ + # Avoid testing twice the same lib + case $boost_failed_libs in #( + *@$boost_lib@*) continue;; + esac + + # Are we looking for a static library? + case $boost_ldpath:$boost_rtopt_ in #( + *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) + for boost_ldpath in "$last_boost_libdir" '' "$boost_tmp_lib/lib" \ + /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ + "$with_boost" C:/Boost/lib /lib* + do + Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" + test -e "$Boost_lib_LIBS" || continue + LDFLAGS=$boost_save_LDFLAGS + test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" + LIBS="$Boost_lib_LIBS $boost_save_LIBS" +dnl First argument of AC_LINK_IFELSE left empty because the test file is +dnl generated only once above (before we start the for loops). + _BOOST_AC_LINK_IFELSE([], + [Boost_lib=yes], [Boost_lib=no]) + ac_objext=$boost_save_ac_objext + if test x"$Boost_lib" = xyes; then + last_boost_libdir="$boost_ldpath" + if test x"$boost_ldpath" != x; then + Boost_lib_LDFLAGS="-L$boost_ldpath -Wl,-R$boost_ldpath" + Boost_lib_LDPATH="$boost_ldpath" + fi + break + fi + done + ;; + *) # No: use -lboost_foo to find the shared library. + Boost_lib_LIBS="-l$boost_lib" + + # Tell the linker to look in all known paths for the libraries. + # This way we only have to attempt one link per tag until we get a hit. + LDFLAGS="$LDFLAGS $boost_all_ldpaths" LIBS="$Boost_lib_LIBS $LIBS" +dnl First argument of AC_LINK_IFELSE left empty because the test file is +dnl generated only once above (before we start the for loops). + _BOOST_AC_LINK_IFELSE([], + [found_boost_tag=yes], [found_boost_tag=no]) + ac_objext=$boost_save_ac_objext + ;; + esac + LIBS="$boost_save_LIBS" + LDFLAGS=$boost_save_LDFLAGS + + if test x"$found_boost_tag" = xyes; then + # Now we have the library+tag name ($boost_lib) try to narrow down the + # libdir. Note we are only here when linking dynamically, not statically. + + # Remember the tag we just found to try first on the next library check. + last_boost_tag="$boost_tag_" + + # The empty path is checked first (after a previous successful path) in + # case the libraries appear in the linker's built in search path. (In this + # case any path we specify would succeed, so we try specifying none first.) + for boost_ldpath in "$last_boost_libdir" '' $boost_all_paths; do + Boost_lib_LIBS="-l$boost_lib" + LIBS="$Boost_lib_LIBS $LIBS" + LDFLAGS=$boost_save_LDFLAGS test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" dnl First argument of AC_LINK_IFELSE left empty because the test file is dnl generated only once above (before we start the for loops). @@ -403,18 +470,23 @@ dnl generated only once above (before we start the for loops). LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS if test x"$Boost_lib" = xyes; then - Boost_lib_LDFLAGS="-L$boost_ldpath -Wl,-R$boost_ldpath" - Boost_lib_LDPATH="$boost_ldpath" - break 6 + if test x"$boost_ldpath" != x; then + Boost_lib_LDFLAGS="-L$boost_ldpath -Wl,-R$boost_ldpath" + Boost_lib_LDPATH="$boost_ldpath" + fi + # Remember the directory to try first with the next lib. + last_boost_libdir="$boost_ldpath" + break 2 else boost_failed_libs="$boost_failed_libs@$boost_lib@" fi done - done -done -done -done + # If we end up here, either we found a tag but couldn't find the libdir + # when linking dynamically, or a static link was requested and this tag + # is invalid. So keep going and look for a better tag. + fi done + rm -f conftest.$ac_objext ]) case $Boost_lib in #( From 6725c5fc0823b203d4d9975d04b346de373f7ae7 Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Tue, 10 Jul 2012 13:15:59 +1000 Subject: [PATCH 3/4] Use AC_REQUIRE when checking for BOOST_SYSTEM in Boost.Timer This amends commit 770539e5b8a90271bd8253200686e24d129be499 --- build-aux/boost.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index 9a71413..5667228 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -954,7 +954,7 @@ CPPFLAGS=$boost_threads_save_CPPFLAGS # Look for Boost.Timer. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Timer], -[BOOST_SYSTEM([$1]) +[AC_REQUIRE([BOOST_SYSTEM])dnl boost_timer_save_LIBS=$LIBS boost_timer_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl From 25766359951da49a2737c4eaef67702f6a008ae2 Mon Sep 17 00:00:00 2001 From: Adam Nielsen Date: Tue, 10 Jul 2012 14:01:17 +1000 Subject: [PATCH 4/4] Make sure all vars start with boost_ and list possible library paths only once This amends commit 92a23600c1278d48fdf4bfeacd9dd44cb811fb6b --- build-aux/boost.m4 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index 5667228..5b13add 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -383,12 +383,16 @@ done boost_tmp_lib=$with_boost test x"$with_boost" = x && boost_tmp_lib=${boost_cv_inc_path%/include} +# This is the list of possible library locations. They are searched in +# order, so the most common ones are first. Spaces are not permitted in +# any path names. +boost_all_paths="$with_boost /usr/lib* $boost_tmp_lib/lib \ + /usr/local/lib* /opt/lib* /opt/local/lib* C:/Boost/lib /lib*" + # Create some compiler parameters for each existing directory of the known # possibilities where Boost might be. boost_all_ldpaths= -for boost_ldpath in "$boost_tmp_lib/lib" \ - /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ - "$with_boost" C:/Boost/lib /lib* +for boost_ldpath in $boost_all_paths do test -e "$boost_ldpath" || continue boost_all_ldpaths="$boost_all_ldpaths -L$boost_ldpath" @@ -396,7 +400,7 @@ done boost_save_LDFLAGS=$LDFLAGS boost_save_LIBS=$LIBS -for boost_tag_ in "$last_boost_tag" $boost_full_tags ''; do +for boost_tag_ in "$boost_prev_tag" $boost_full_tags ''; do boost_lib=boost_$1$boost_tag_ # Avoid testing twice the same lib case $boost_failed_libs in #( @@ -406,9 +410,7 @@ for boost_tag_ in "$last_boost_tag" $boost_full_tags ''; do # Are we looking for a static library? case $boost_ldpath:$boost_rtopt_ in #( *?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) - for boost_ldpath in "$last_boost_libdir" '' "$boost_tmp_lib/lib" \ - /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ - "$with_boost" C:/Boost/lib /lib* + for boost_ldpath in "$boost_prev_libdir" '' $boost_all_paths do Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" test -e "$Boost_lib_LIBS" || continue @@ -421,7 +423,7 @@ dnl generated only once above (before we start the for loops). [Boost_lib=yes], [Boost_lib=no]) ac_objext=$boost_save_ac_objext if test x"$Boost_lib" = xyes; then - last_boost_libdir="$boost_ldpath" + boost_prev_libdir="$boost_ldpath" if test x"$boost_ldpath" != x; then Boost_lib_LDFLAGS="-L$boost_ldpath -Wl,-R$boost_ldpath" Boost_lib_LDPATH="$boost_ldpath" @@ -452,12 +454,12 @@ dnl generated only once above (before we start the for loops). # libdir. Note we are only here when linking dynamically, not statically. # Remember the tag we just found to try first on the next library check. - last_boost_tag="$boost_tag_" + boost_prev_tag="$boost_tag_" # The empty path is checked first (after a previous successful path) in # case the libraries appear in the linker's built in search path. (In this # case any path we specify would succeed, so we try specifying none first.) - for boost_ldpath in "$last_boost_libdir" '' $boost_all_paths; do + for boost_ldpath in "$boost_prev_libdir" '' $boost_all_paths; do Boost_lib_LIBS="-l$boost_lib" LIBS="$Boost_lib_LIBS $LIBS" LDFLAGS=$boost_save_LDFLAGS @@ -475,7 +477,7 @@ dnl generated only once above (before we start the for loops). Boost_lib_LDPATH="$boost_ldpath" fi # Remember the directory to try first with the next lib. - last_boost_libdir="$boost_ldpath" + boost_prev_libdir="$boost_ldpath" break 2 else boost_failed_libs="$boost_failed_libs@$boost_lib@"