* libltdl/config/ltmain.m4sh (func_resolve_sysroot): New. (func_mode_link): Always pass result of stripping -L and -R to func_resolve_sysroot before using it. Remove absolute path expansion when func_resolve_sysroot subsumes it. Expand sysroot in -rpath. When processing dependent libraries also resolve sysroot paths there.
Signed-off-by: Paolo Bonzini <bonz...@gnu.org> Signed-off-by: Charles Wilson <libt...@cwilson.fastmail.fm> --- libltdl/config/ltmain.m4sh | 81 ++++++++++++++++++++++++++++++++----------- 1 files changed, 60 insertions(+), 21 deletions(-) diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index 4f373db..f7951c4 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -544,6 +544,36 @@ func_source () } +# func_resolve_sysroot PATH +# Change PATH to an absolute path or replace a leading = with a +# sysroot. Store the result into func_resolve_sysroot_result +func_resolve_sysroot () +{ + func_resolve_sysroot_result=$1 + case $func_resolve_sysroot_result in + [\\/]* | [A-Za-z]:[\\/]*) ;; + =*) + func_stripname '=' '' "$func_resolve_sysroot_result" + func_resolve_sysroot_result=$lt_sysroot$func_stripname_result + ;; + *) + if test -d "$1"; then + absdir=`cd "$1" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of \`$dir'" + func_resolve_sysroot_result=`cd "$dir" && pwd` + else + func_dirname_and_basename "$1" "" "." + absdir=`cd "$func_dirname_result" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of \`$func_dirname_result'" + func_resolve_sysroot_result="$absdir/$func_basename_result" + fi + ;; + esac +} + + # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. @@ -4340,29 +4370,26 @@ func_mode_link () ;; -L*) - func_stripname '-L' '' "$arg" - dir=$func_stripname_result - if test -z "$dir"; then + func_stripname "-L" '' "$arg" + if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi - # We need an absolute path. - case $dir in - [\\/]* | [A-Za-z]:[\\/]*) ;; - *) - absdir=`cd "$dir" && pwd` - test -z "$absdir" && \ - func_fatal_error "cannot determine absolute directory name of \`$dir'" - dir="$absdir" - ;; - esac + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result case "$deplibs " in - *" -L$dir "*) ;; + *" -L$dir "* | *" $arg "*) + # Will only happen for absolute or sysroot arguments + ;; *) - func_append deplibs " -L$dir" + # Preserve sysroot, but never include relative directories + case $dir in + [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; + *) func_append deplibs " -L$dir" ;; + esac func_append lib_search_path " $dir" ;; esac @@ -4514,6 +4541,10 @@ func_mode_link () # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; + =*) + func_stripname '=' '' "$arg" + dir=$lt_sysroot$func_stripname_result + ;; *) func_fatal_error "only absolute run-paths are allowed" ;; @@ -5042,7 +5073,8 @@ func_mode_link () test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" - func_append newlib_search_path " $func_stripname_result" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then @@ -5056,7 +5088,8 @@ func_mode_link () finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" - func_append newlib_search_path " $func_stripname_result" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" @@ -5066,8 +5099,9 @@ func_mode_link () ;; # -L -R*) if test "$pass" = link; then - func_stripname '-R' '' "$deplib" - dir=$func_stripname_result + func_stripname '-L' '' "$deplib" + func_resolve_sysroot "$func_stripname_result" + dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; @@ -5375,7 +5409,8 @@ func_mode_link () for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" - func_append newlib_search_path " $func_stripname_result" + func_resolve_sysroot "$func_stripname_result" + func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? @@ -5776,6 +5811,8 @@ func_mode_link () tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" + func_resolve_sysroot "$deplib" + deplib=$func_resolve_sysroot_result if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; @@ -5791,8 +5828,10 @@ func_mode_link () case $deplib in -L*) path="$deplib" ;; *.la) + func_resolve_sysroot "$deplib" + deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." - dir="$func_dirname_result" + dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; -- 1.7.1