From d32c96ccd6dacf2c60504a6b847e3d82400adfac Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 11 Aug 2010 15:35:54 -0400 Subject: [PATCH] add libtool --mode=finish mode for sysroot * doc/libtool.texi (Finish mode): Document behavior when *.la files are passed. * libltdl/config/ltmain.m4sh (func_mode_finish): Eliminate sysroot or `=' signs representing it from files in $libs. * tests/sysroot.at (SYSROOT_TESTS): Test for presence of sysroot references before running libtool --mode=finish, and for absence afterwards. --- doc/libtool.texi | 18 ++++++++++++------ libltdl/config/ltmain.m4sh | 21 +++++++++++++++++++++ tests/sysroot.at | 3 +++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/doc/libtool.texi b/doc/libtool.texi index 914bd1d82..4b256bf03 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -1721,12 +1721,18 @@ commands are also completed. @cindex finish mode @cindex mode, finish -@dfn{Finish} mode helps system administrators install libtool libraries -so that they can be located and linked into user programs. - -Each @var{mode-arg} is interpreted as the name of a library directory. -Running this command may require superuser privileges, so the -@option{--dry-run} option may be useful. +@dfn{Finish} mode has two functions. One is to help system administrators +install libtool libraries so that they can be located and linked into +user programs. To invoke this functionality, pass the name of a library +directory as @var{mode-arg}. Running this command may require superuser +privileges, and the @option{--dry-run} option may be useful. + +The second is to facilitate transferring libtool libraries to a native +compilation environment after they were built in a cross-compilation +environment. Cross-compilation environments may rely on recent libtool +features, and running libtool in finish mode will make it easier to +work with older versions of libtool. This task is performed whenever +the @var{mode-arg} is a @samp{.la} file. @node Uninstall mode @section Uninstall mode diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index f9d62bee4..d29fd5d81 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -1418,6 +1418,27 @@ func_mode_finish () fi done + if test -n "$libs"; then + tmpdir=`func_mktempdir` + if test -n "$lt_sysroot"; then + sysroot_regex=`$ECHO "$lt_sysroot" | $SED 's/[].[^$\\*|]/\\\\&/g'` + sysroot_cmd="s|\([ ']\)$sysroot_regex|\1|g;" + else + sysroot_cmd= + fi + + # Remove sysroot references + for lib in $libs; do + $opt_dry_run || { + sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ + > $tmpdir/tmp-la + mv -f $tmpdir/tmp-la $lib + } + file="$outputname" + done + $opt_dry_run || ${RM}r "$tmpdir" + fi + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then diff --git a/tests/sysroot.at b/tests/sysroot.at index 869c9c49e..c0ac6d166 100644 --- a/tests/sysroot.at +++ b/tests/sysroot.at @@ -186,6 +186,9 @@ LT_AT_BOOTSTRAP([], [-I $abs_top_srcdir/libltdl/m4], [ignore], AT_CHECK([$MAKE install DESTDIR=$sysroot], [0], [ignore], [ignore]) AT_CHECK([test -f $sysroot/$prefix/bin/prog$EXEEXT]) AT_CHECK([grep -F "$sysroot" "$sysroot/$prefix/bin/prog$EXEEXT"], [1]) +AT_CHECK([grep "'.*=" $sysroot/$prefix/lib/lib2.la], [0], [ignore]) +AT_CHECK([./libtool --mode=finish $sysroot/$prefix/lib/lib@<:@12@:>@.la], [0], [ignore]) +AT_CHECK([grep "'.*=" $sysroot/$prefix/lib/lib@<:@12@:>@.la], [1]) # missing tests # 1) pass absolute .la files -- 2.47.2