From 327cf1493b491a93513883a796bcc100357238fd Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Wed, 27 Jan 2016 15:24:18 -0500 Subject: [PATCH 1/7] if --with_boost is specified, search *only* the specified directory hierarchy for libraries. Arguably, if --with_boost is specified, the user wants to use only that boost installation, and no other. This changeset implements this behavior. The original code in _BOOST_FIND_LIBS prepended the --with_boost path to the default list of paths, resulting in all of the paths being searched if the library wasn't found in that specified by --with_boost. Because the search for a library begins with the most specialized version: boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_ boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_ boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_ boost_$boost_lib_$boost_tag_$boost_ver_ if the user's preferred boost installation has a less specialized version of a library than one provided in the default path, the latter will be chosen instead. This may lead to a mismatch between the headers discovered in the --with_boost hierarchy and the library discovered in the default path, if they are for different versions of boost, leading to link problems if the latter is for an earlier version . Additionally, this will silently invalidate a request for a specific version of boost in BOOST_REQUIRE, as it will be fulfilled by the headers, but not by the library. The new code does the following: * It will only search the --with_boost hierarchy if that is provided; * It will (following the suggestion of issue #49 by mateidavid) use the absolute path to the library so that the linker's default library paths are not searched if the library is not found in the --with_boost hierarchy * It adds a second path "$with_boost/lib" to the search path, as that seems to be a standard place for libraries N.B. There is still a potential for mishap if --with_boost is *not* specified, namely that if there exist multiple boost installations and some do not have all of the libraries, it is possible to end up with libraries selected from multiple installations. --- build-aux/boost.m4 | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index c2cee53..bb56e7d 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -47,6 +47,16 @@ m4_define([_BOOST_SERIAL], [m4_translit([ m4_pattern_forbid([^_?(BOOST|Boost)_]) +# _BOOST_SHELL_FUNCTIONS +# -------------------------------------------------------- +# +# Useful shell functions. Call +# AC_REQUIRE([_BOOST_SHELL_FUNCTIONS]) +# before using +AC_DEFUN([_BOOST_SHELL_FUNCTIONS], +[_boost_join_path() { _boost_join_path_save_IFS=$IFS; IFS=@ ; echo "$[]*" ; IFS=$_boost_join_path_save_IFS ; } ] +) + # _BOOST_SED_CPP(SED-PROGRAM, PROGRAM, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) @@ -390,7 +400,8 @@ AC_DEFUN([BOOST_FIND_LIB], # ERROR_ON_UNUSABLE can be set to "no" if the caller does not want their # configure to fail AC_DEFUN([_BOOST_FIND_LIBS], -[Boost_lib=no +[AC_REQUIRE([_BOOST_SHELL_FUNCTIONS]) +Boost_lib=no case "$3" in #( (mt | mt-) boost_mt=-mt; boost_rtopt=;; #( (mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #( @@ -462,27 +473,37 @@ for boost_rtopt_ in $boost_rtopt '' -d; do 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* + # If with_boost is specified; search *only* within that hierarchy, + # otherwise search the "standard" places, starting with a location + # based upon where the headers are. + AS_IF( [ test x"$with_boost" = x ], + [ boost_ldpaths=`_boost_join_path ${boost_cv_inc_path%/include} '' \ + /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ + C:/Boost/lib /lib*` ], + [ boost_ldpaths=`_boost_join_path "$with_boost" "$with_boost/lib"` ] + ) + + save_IFS=$IFS + IFS=@ + for boost_ldpath in `echo "$boost_ldpaths"` do + IFS=$save_IFS # Don't waste time with directories that don't exist. if test x"$boost_ldpath" != x && test ! -e "$boost_ldpath"; then continue fi boost_save_LDFLAGS=$LDFLAGS + # use an absolute path to the requested library to avoid finding it + # in the linker's default search path # 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";; + Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" ;; + (*) # No: + Boost_lib_LIBS="$boost_ldpath/lib$boost_lib$shrext_cmds" ;; esac + # Don't waste time with libraries that don't exist + test -e "$Boost_lib_LIBS" || continue boost_save_LIBS=$LIBS LIBS="$Boost_lib_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" From 9fd9d350ff943006f47cbb7aa160b5ec88073874 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Thu, 28 Jan 2016 10:09:10 -0500 Subject: [PATCH 2/7] properly use the undocumented libtool shrext_cmds variable shrext_cmds is actually a quoted set of commands to generate the shared library extension, not the actual shrext itself (regardless of it initially being set directly to .so as a default). --- build-aux/boost.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index bb56e7d..11aa221 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -453,6 +453,7 @@ dnl start the for loops). ]) ac_objext=$boost_save_ac_objext boost_failed_libs= + eval eval _boost_shrext=$shrext_cmds # Don't bother to ident the following nested for loops, only the 2 # innermost ones matter. for boost_lib_ in $2; do @@ -500,7 +501,7 @@ for boost_rtopt_ in $boost_rtopt '' -d; do (*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" ;; (*) # No: - Boost_lib_LIBS="$boost_ldpath/lib$boost_lib$shrext_cmds" ;; + Boost_lib_LIBS="$boost_ldpath/lib$boost_lib$_boost_shrext" ;; esac # Don't waste time with libraries that don't exist test -e "$Boost_lib_LIBS" || continue From f958f59eb8a847199cc254dd0f6dc808745646cf Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 27 Aug 2019 15:05:16 -0400 Subject: [PATCH 3/7] rebase on boost master --- build-aux/boost.m4 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index 11aa221..970531b 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -339,6 +339,7 @@ AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl +AS_VAR_PUSHDEF([Boost_lib_abs_path], [boost_cv_lib_$1_abs_path])dnl AS_IF([test x"$8" = "xno"], [not_found_header='true']) BOOST_FIND_HEADER([$4], [$not_found_header]) boost_save_CPPFLAGS=$CPPFLAGS @@ -499,15 +500,17 @@ for boost_rtopt_ in $boost_rtopt '' -d; do # 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" ;; + Boost_lib_abs_path="$boost_ldpath/lib$boost_lib.$libext" + Boost_lib_LIBS="$Boost_lib_abs_path" ;; (*) # No: - Boost_lib_LIBS="$boost_ldpath/lib$boost_lib$_boost_shrext" ;; + Boost_lib_abs_path="$boost_ldpath/lib$boost_lib$_boost_shrext" + Boost_lib_LIBS="-l$boost_lib";; esac # Don't waste time with libraries that don't exist - test -e "$Boost_lib_LIBS" || continue + test -e "$Boost_lib_abs_path" || continue boost_save_LIBS=$LIBS LIBS="$Boost_lib_LIBS $LIBS" - test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" + test x"$boost_ldpath" != x && LDFLAGS=" -L$boost_ldpath $LDFLAGS" 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([], @@ -527,8 +530,8 @@ dnl generated only once above (before we start the for loops). boost_rpath_link_ldflag_found=yes;; *) for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do - LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" - LIBS="$Boost_lib_LIBS $boost_save_LIBS" + LDFLAGS="-L$boost_ldpath $boost_save_LDFLAGS $boost_cv_rpath_link_ldflag$boost_ldpath" + LIBS="$boost_save_LIBS $Boost_lib_LIBS" _BOOST_AC_LINK_IFELSE([], [boost_rpath_link_ldflag_found=yes break], From bd7cf99c0c25fffad1c4db99074dec20006f2762 Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 27 Aug 2019 17:45:05 -0400 Subject: [PATCH 4/7] don't use boost_cv_inc_path to generate a test ldpath if it's not a path boost_cv_inc_path can have values 'yes' and 'no' in addition to a real path, so don't use it to generate an ldpath if it's 'yes' or 'no' --- build-aux/boost.m4 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index 970531b..b5ba393 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -479,7 +479,12 @@ for boost_rtopt_ in $boost_rtopt '' -d; do # otherwise search the "standard" places, starting with a location # based upon where the headers are. AS_IF( [ test x"$with_boost" = x ], - [ boost_ldpaths=`_boost_join_path ${boost_cv_inc_path%/include} '' \ + [ + AS_IF( [ test x"$boost_cv_inc_path" = xno || test x"$boost_cv_inc_path" = xyes ], + [boost_tmp_lib=], + [boost_tmp_lib=${boost_cv_inc_path%/include} ] + ) + boost_ldpaths=`_boost_join_path $boost_tmp_lib '' \ /opt/local/lib* /usr/local/lib* /opt/lib* /usr/lib* \ C:/Boost/lib /lib*` ], [ boost_ldpaths=`_boost_join_path "$with_boost" "$with_boost/lib"` ] From e7565e69def10811c9ecd5f61b450e8f990ae35f Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 27 Aug 2019 17:46:51 -0400 Subject: [PATCH 5/7] don't check for a library's existence if the tested ldpath = '' If the tested ldpath = '', using it to create an absolute path to a library leads to a path in the root directory, which isn't what's intended. So don't. Additionally if ldpath = '', it's equivalent to letting the linker use only the system default paths, and there's no way of knowing in which directory the linker might find the library. --- build-aux/boost.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index b5ba393..505d9ad 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -512,7 +512,9 @@ for boost_rtopt_ in $boost_rtopt '' -d; do Boost_lib_LIBS="-l$boost_lib";; esac # Don't waste time with libraries that don't exist - test -e "$Boost_lib_abs_path" || continue + if test x"$boost_ldpath" != x && test ! -e "$boost_lib_abs_path"; then + continue + fi boost_save_LIBS=$LIBS LIBS="$Boost_lib_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS=" -L$boost_ldpath $LDFLAGS" From c67d13d1015768ba61940d718a8943dd76b6bfdb Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Tue, 27 Aug 2019 18:02:14 -0400 Subject: [PATCH 6/7] remove now-obsolete comment about passing absolute path to library to linker --- build-aux/boost.m4 | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-aux/boost.m4 b/build-aux/boost.m4 index 505d9ad..a2933b1 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -500,8 +500,6 @@ for boost_rtopt_ in $boost_rtopt '' -d; do continue fi boost_save_LDFLAGS=$LDFLAGS - # use an absolute path to the requested library to avoid finding it - # in the linker's default search path # Are we looking for a static library? case $boost_ldpath:$boost_rtopt_ in #( (*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) From 1c22b615d91e0caab07223d2a4c270359cb2183b Mon Sep 17 00:00:00 2001 From: Diab Jerius Date: Mon, 9 Sep 2019 16:36:19 -0400 Subject: [PATCH 7/7] fix captilization typo --- 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 a2933b1..42ea1b7 100644 --- a/build-aux/boost.m4 +++ b/build-aux/boost.m4 @@ -510,7 +510,7 @@ for boost_rtopt_ in $boost_rtopt '' -d; do Boost_lib_LIBS="-l$boost_lib";; esac # Don't waste time with libraries that don't exist - if test x"$boost_ldpath" != x && test ! -e "$boost_lib_abs_path"; then + if test x"$boost_ldpath" != x && test ! -e "$Boost_lib_abs_path"; then continue fi boost_save_LIBS=$LIBS