From 26c8947b8da921dc47d9ab9a99ccb94fe31e2c19 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 21 Feb 1999 17:39:56 +0000 Subject: [PATCH] * depdemo: moved each library into a subdirectory to test hardcoding * ltconfig.in: added hardcode_into_libs (whether library paths should be hardcoded into the libraries instead of the program), shlibpath_overrides_runpath, must_relink * ltmain.in: renamed link-install mode to relink, save the command line arguments properly, simplified hardcoding, use relative/absolute paths where appropriate, take care of shlibpath_overrides_runpath, relinking works now (for programs as well as for libraries) hardcode all (even dependency_libs) library paths into a program, don't add shlibpath/runpath to compile_command, thousands of bugfixes... * inter-library dependencies are now _fully_ functional ! --- ChangeLog | 17 ++ configure.in | 2 +- depdemo/Makefile.am | 17 +- depdemo/configure.in | 8 +- depdemo/main.c | 6 +- ltconfig.in | 21 ++ ltmain.in | 494 +++++++++++++++++++++++-------------------- 7 files changed, 326 insertions(+), 239 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0e3041452..798e070d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +1999-02-21 Thomas Tanner + + * depdemo: moved each library into a subdirectory + to test hardcoding + * ltconfig.in: added hardcode_into_libs (whether library paths + should be hardcoded into the libraries instead of the program), + shlibpath_overrides_runpath, must_relink + * ltmain.in: renamed link-install mode to relink, + save the command line arguments properly, simplified hardcoding, + use relative/absolute paths where appropriate, + take care of shlibpath_overrides_runpath, + relinking works now (for programs as well as for libraries) + hardcode all (even dependency_libs) library paths into a program, + don't add shlibpath/runpath to compile_command, + thousands of bugfixes... + * inter-library dependencies are now _fully_ functional ! + 1999-02-18 Gary V. Vaughan * ltconfig.in (archive{,_sym}_commands): Be careful not to diff --git a/configure.in b/configure.in index 5cb68af03..3232168c7 100644 --- a/configure.in +++ b/configure.in @@ -41,7 +41,7 @@ AC_PROG_AWK dnl all subdirectories that are configured on demand, but that must be dnl included in the distribution -CONF_SUBDIRS="libltdl demo mdemo depdemo cdemo" +CONF_SUBDIRS="libltdl demo mdemo cdemo depdemo" AC_SUBST(CONF_SUBDIRS) ACINCLUDE_M4_LIST="${srcdir}/acinclude.m4 " diff --git a/depdemo/Makefile.am b/depdemo/Makefile.am index 9b5a81eeb..ae544a402 100644 --- a/depdemo/Makefile.am +++ b/depdemo/Makefile.am @@ -2,20 +2,17 @@ # AUTOMAKE_OPTIONS = no-dependencies foreign -lib_LTLIBRARIES = libl1.la libl2.la libl3.la libl4.la -libl1_la_SOURCES = l1.c l1.h sysdep.h -libl2_la_SOURCES = l2.c l2.h sysdep.h -libl2_la_LIBADD = libl1.la -libl3_la_SOURCES = l3.c l3.h sysdep.h -libl3_la_LIBADD = libl1.la libl2.la -libl4_la_SOURCES = l4.c l4.h sysdep.h -libl4_la_LIBADD = libl3.la $(LIBADD_M) +SUBDIRS = l1 l2 l3 l4 +EXTRA_DIST = sysdep.h + bin_PROGRAMS = depdemo depdemo.static depdemo_SOURCES = main.c -depdemo_LDADD = libl1.la libl2.la libl4.la -depdemo_DEPENDENCIES = libl1.la libl2.la libl4.la +depdemo_LDADD = $(top_builddir)/l1/libl1.la $(top_builddir)/l2/libl2.la \ + $(top_builddir)/l4/libl4.la +depdemo_DEPENDENCIES = $(top_builddir)/l1/libl1.la \ + $(top_builddir)/l2/libl2.la $(top_builddir)/l4/libl4.la depdemo_static_SOURCES = $(depdemo_SOURCES) depdemo_static_LDADD = $(depdemo_LDADD) diff --git a/depdemo/configure.in b/depdemo/configure.in index bc71eaef8..9994c3d44 100644 --- a/depdemo/configure.in +++ b/depdemo/configure.in @@ -19,4 +19,10 @@ AC_CHECK_LIB(m, cos, LIBADD_M="-lm", LIBADD_M=) AC_SUBST(LIBADD_M) dnl Output the makefile -AC_OUTPUT(Makefile) +AC_OUTPUT( +Makefile +l1/Makefile +l2/Makefile +l3/Makefile +l4/Makefile +) diff --git a/depdemo/main.c b/depdemo/main.c index 7becd4a64..a27032a30 100644 --- a/depdemo/main.c +++ b/depdemo/main.c @@ -17,9 +17,9 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include "l1.h" -#include "l2.h" -#include "l4.h" +#include "l1/l1.h" +#include "l2/l2.h" +#include "l4/l4.h" #include #include diff --git a/ltconfig.in b/ltconfig.in index 30218d15c..e45b382f7 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -1007,6 +1007,7 @@ old_archive_from_new_cmds= export_dynamic_flag_spec= whole_archive_flag_spec= thread_safe_flag_spec= +hardcode_into_libs=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no @@ -1532,6 +1533,13 @@ else fi echo "$ac_t$hardcode_action" 1>&6 +# Check relinking. +echo $ac_n "checking whether relinking is necessary... $ac_c" 1>&6 +must_relink=no +if test "$hardcode_action" = relink || test "$shlibpath_overrides_runpath" != yes; then + must_relink=yes +fi +echo "$ac_t$must_relink" 1>&6 reload_flag= reload_cmds='$LD$reload_flag -o $output$reload_objs' @@ -1550,6 +1558,7 @@ postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= +shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" @@ -1708,6 +1717,7 @@ linux-gnu*) soname_spec='${libname}${release}.so$major' finish_cmds='PATH="$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' file_magic_command=file @@ -1777,6 +1787,7 @@ solaris*) library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib" @@ -1788,6 +1799,7 @@ sunos4*) library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi @@ -2137,9 +2149,15 @@ runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec @@ -2159,6 +2177,9 @@ hardcode_minus_L=$hardcode_minus_L # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var +# Whether we must relink +must_relink=$must_relink + # System search path for libraries sys_lib_search_path_spec=$sys_lib_search_path_spec diff --git a/ltmain.in b/ltmain.in index 7964aed5f..6149f221c 100644 --- a/ltmain.in +++ b/ltmain.in @@ -603,11 +603,11 @@ compiler." ;; # libtool link mode - link | link-install) + link | relink) modename="$modename: link" - link_install=no - test "$mode" = "link-install" && link_install=yes - link_command="$nonopt" + relink=no + test "$mode" = "relink" && relink=yes + link_command_save="$nonopt" C_compiler="$CC" # save it, to compile generated C sources CC="$nonopt" case "$host" in @@ -835,7 +835,7 @@ compiler." while test $# -gt 0; do arg="$1" shift - link_command="$link_command $arg" + link_command_save="$link_command_save $arg" # If the previous option needs an argument, assign it. if test -n "$prev"; then @@ -968,6 +968,16 @@ compiler." ;; -l*) + case "$host" in + *-*-cygwin*) + # The cygwin environment doesn't actually have -lm, and + # although the linker fakes having one, specifiying it to + # libtool will break ILD! + if test "$arg" = "-lm"; then + continue + fi + ;; + esac deplibs="$deplibs $arg" continue ;; @@ -1206,8 +1216,8 @@ compiler." lib_search_path="$lib_search_path $sys_lib_search_path $shlib_search_path" # Quote the link command for shipping. - link_command=`$echo "X$link_command" | $Xsed -e "$sed_quote_subst"` - link_dir=`pwd | sed -e $sed_quote_subst` + link_command_save=`$echo "X$link_command_save" | $Xsed -e "$sed_quote_subst"` + link_dir_save=`pwd | sed -e $sed_quote_subst` case "$output" in "") @@ -1482,17 +1492,19 @@ compiler." esac fi - # Create the output directory, or remove our outputs if we need to. - if test -d $output_objdir; then - $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" - $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* - else - $show "$mkdir $output_objdir" - $run $mkdir $output_objdir - status=$? - if test $status -ne 0 && test ! -d $output_objdir; then - exit $status - fi + if test "$relink" = no; then + # Create the output directory, or remove our outputs if we need to. + if test -d $output_objdir; then + $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" + $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + else + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi fi # Now set the variables for building old libraries. @@ -1512,13 +1524,12 @@ compiler." release_save=$release versuffix_save=$versuffix major_save=$major - link_command_save=$link_command - link_dir_save=$link_dir # Find libtool libraries and add their dependencies and directories newdeplibs= # libraries to link (used in archive_cmds) newdependency_libs= # all dependency libraries uninst_path= # paths that contain uninstalled libtool libraries + rpath= new_lib_search_path= for deplib in $deplibs; do lib= @@ -1530,15 +1541,6 @@ compiler." continue ;; -l*) - case "$host" in - *-*-cygwin*) - # The cygwin environment doesn't actually have -lm, and - # although the linker fakes having one, specifiying it to - # libtool will break ILD! - case "$deplib" in - -lm) continue ;; - esac - esac name="`expr $deplib : '-l\(.*\)'`" libname=`eval \\$echo \"$libname_spec\"` found=no @@ -1574,18 +1576,16 @@ compiler." test "X$ladir" = "X$lib" && ladir="." # We need an absolute path. case "$ladir" in - /* | [A-Za-z]:[/\\]*) ;; + /* | [A-Za-z]:[/\\]*) abs_ladir="$ladir" ;; *) - absdir=`cd "$ladir" && pwd` - if test -z "$absdir"; then - $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: cannot determine absolute directory name of \`$ladir'" 1>&2 exit 1 fi - ladir="$absdir" ;; esac laname=`echo "X$lib" | $Xsed -e 's%^.*/%%'` - lib="$ladir/$laname" # Check to see that this really is a libtool archive. if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : @@ -1615,64 +1615,35 @@ compiler." # Find the relevant object directory and library name. if test "X$installed" = Xyes; then dir="$libdir" + absdir="$libdir" + else + dir="$ladir/$objdir" case "$dir" in - /* | [A-Za-z]:[/\\]*) ;; + /* | [A-Za-z]:[/\\]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 exit 1 fi - dir="$absdir" ;; esac - else - dir="$ladir/$objdir" # Remove this search path later - uninst_path="$uninst_path $ladir" + uninst_path="$uninst_path $abs_ladir" fi - name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` - if test -z "$libdir"; then - # It is a libtool convenience library. - $echo "$modename: cannot link libtool libraries against convenience libraries" 1>&2 - exit 1 - fi - if test "$build_libtool_libs" = yes && test -n "$library_names"; then - # This is the magic to use -rpath. - if test -n "$hardcode_libdir_flag_spec"; then - saved_libdir="$libdir" - test $link_install = no && libdir="$dir" - - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$libdir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - libdir= - fi - fi - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" - - newdeplibs="$newdeplibs $flag" - fi - # libdir is also use after "$hardcode_action" case - libdir="$saved_libdir" - fi + # Hardcode the library path. + tmpdir="$libdir" + test "$must_relink" = yes && test "$relink" = no && tmpdir="$absdir" + # Make sure the rpath contains only unique directories. + case "$rpath " in + *" $tmpdir "*) ;; + *) rpath="$rpath $tmpdir" ;; + esac - if test $link_install = no; then + if test "$relink" = no; then lib_linked=yes case "$hardcode_action" in immediate | unsupported) @@ -1745,10 +1716,10 @@ compiler." newdeplibs="$newdeplibs $dir/$old_library" fi - new_lib_search_path="$new_lib_search_path $dir" + new_lib_search_path="$new_lib_search_path $absdir" # Link against this library - newdependency_libs="$newdependency_libs $dependency_libs $lib" + newdependency_libs="$newdependency_libs $dependency_libs $abs_ladir/$laname" done # Make sure lib_search_path contains only unique directories. @@ -1782,45 +1753,48 @@ compiler." # If the user specified any rpath flags, then add them. temp_xrpath= for dir in $xrpath; do + temp_xrpath="$temp_xrpath -R$dir" + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + dep_rpath= + if test -n "$rpath$xrpath" && test "$hardcode_into_libs" = yes && test -n "$hardcode_libdir_flag_spec"; then + for dir in $rpath $xrpath; do libdir="$dir" - temp_xrpath="$temp_xrpath -R$libdir" - if test -n "$hardcode_libdir_flag_spec"; then - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$dir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$dir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$dir" - ;; - esac - libdir= - fi + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + # Put the magic libdir with the hardcode flag. + hardcode_libdirs="$dir" + libdir="@HARDCODE_LIBDIRS@" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$dir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$dir" + ;; + esac + libdir= fi + fi - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" + if test -n "$libdir"; then + eval flag=\"$hardcode_libdir_flag_spec\" - deplibs="$deplibs $flag" - fi + dep_rpath="$dep_rpath $flag" fi done - dependency_libs="$temp_xrpath $dependency_libs" fi - # Substitute the hardcoded libdirs into the compile commands. + # Substitute the hardcoded libdirs into the dep_rpath. if test -n "$hardcode_libdir_separator"; then - deplibs=`$echo "X$deplibs" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` + dep_rpath=`$echo "X$dep_rpath" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" # Restore the variables - link_dir=$link_dir_save - link_command=$link_command_save versuffix=$versuffix_save major=$major_save release=$release_save @@ -1900,20 +1874,20 @@ EOF # Did it work? if test $? -eq 0 ; then ldd_output=`ldd conftest` - libname=`eval \\$echo \"$libname_spec\"` - deplib_matches=`eval \\$echo \"$library_names_spec\"` - set dummy $deplib_matches - deplib_match=$2 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then - newdeplibs="$newdeplibs $i" - else - droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $i." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - fi + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $i." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi else droppeddeps=yes echo @@ -2092,6 +2066,11 @@ EOF done fi + # Make a backup of the uninstalled library when relinking + if test "$relink" = yes && test "$hardcode_into_libs" = yes ; then + $run eval '(cd $output_objdir && $rm "$realname"U && $mv $realname "$realname"U)' || exit $? + fi + # Do each of the archive commands. if test -n "$export_symbols" && test -n "$archive_sym_cmds"; then eval cmds=\"$archive_sym_cmds\" @@ -2100,7 +2079,7 @@ EOF fi IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' if test -n "$shlibpath"; then - eval "export $shlibpath_var='$shlibpath\$$shlibpath_var'" + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi for cmd in $cmds; do IFS="$save_ifs" @@ -2109,6 +2088,12 @@ EOF done IFS="$save_ifs" + # Restore the uninstalled library and exit + if test "$relink" = yes && test "$hardcode_into_libs" = yes; then + $run eval '(cd $output_objdir && $rm "$realname"T && $mv $realname "$realname"T && $mv "$realname"U $realname)' || exit $? + exit 0 + fi + # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then @@ -2227,6 +2212,7 @@ EOF # Find libtool libraries and add their dependencies/rpaths newdeplibs= + newdependency_libs= new_lib_search_path= for deplib in $deplibs; do lib= @@ -2294,11 +2280,7 @@ EOF new_lib_search_path="$new_lib_search_path `$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`" newdeplibs="$newdeplibs $lib" - - if test -z "$libdir" || test "$build_libtool_libs" = no || test "$deplibs_check_method" = none; then - # Add in any libraries that this one depends upon. - newdeplibs="$newdeplibs $dependency_libs" - fi + newdependency_libs="$newdependency_libs $dependency_libs" for deplib in $dependency_libs; do case "$deplib" in @@ -2329,10 +2311,24 @@ EOF esac done + # Make sure dependency_libs contains only unique libraries and directories. + dependency_libs= + for deplib in $newdependency_libs; do + case "$dependency_libs " in + *" $deplib "*) ;; + *) dependency_libs="$dependency_libs $deplib" ;; + esac + done + # Find libtool libraries and add their directories newdeplibs= + alldeplibs=no + linkalldeplibs=no + if test "$build_libtool_libs" = no || test "$deplibs_check_method" = none; then + linkalldeplibs=yes + fi link_against_libtool_libs= - for deplib in $deplibs; do + for deplib in $deplibs @DEPLIBS@ $dependency_libs; do lib= case "$deplib" in -L*) @@ -2346,6 +2342,14 @@ EOF *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac + continue + ;; + @DEPLIBS@) + if test "$hardcode_into_libs" = yes; then + break + fi + alldeplibs=yes + continue ;; -l*) name="`expr $deplib : '-l\(.*\)'`" @@ -2406,12 +2410,47 @@ EOF # Find the relevant object directory and library name. if test "X$installed" = Xyes; then dir="$libdir" + absdir="$libdir" else - dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` - test "$dir" = "$deplib" && dir=. - dir="$dir/$objdir" + dir="`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`/" + test "$dir" = "$deplib/" && dir= + dir="$dir$objdir" + case "$dir" in + /* | [A-Za-z]:[/\\]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit 1 + fi + ;; + esac fi + + if test "$build_libtool_libs" = yes && test -n "$library_names"; then + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + # This is the magic to use -rpath. + tmpdir="$libdir" + test "$must_relink" = yes && test "$relink" = no && tmpdir="$absdir" + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $tmpdir "*) ;; + *) xrpath="$xrpath $tmpdir" ;; + esac + fi + + if test "$alldeplibs" = yes && test "$linkalldeplibs" = no; then + continue + fi + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` if test -z "$libdir"; then @@ -2424,51 +2463,8 @@ EOF if test "$build_libtool_libs" = yes && test -n "$library_names"; then link_against_libtool_libs="$link_against_libtool_libs $lib" - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - - # This is the magic to use -rpath. - if test -n "$hardcode_libdir_flag_spec"; then - saved_libdir="$libdir" - test $link_install = no && libdir="$dir" - if test -n "$hardcode_libdir_separator"; then - if test -z "$hardcode_libdirs"; then - # Put the magic libdir with the hardcode flag. - hardcode_libdirs="$libdir" - libdir="@HARDCODE_LIBDIRS@" - else - # Just accumulate the unique libdirs. - case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in - *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) - ;; - *) - hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" - ;; - esac - libdir= - fi - fi - - if test -n "$libdir"; then - eval flag=\"$hardcode_libdir_flag_spec\" - newdeplibs="$newdeplibs $flag" - fi - libdir="$saved_libdir" - elif test -n "$runpath_var"; then - # Do the same for the permanent run path. - case "$perm_rpath " in - *" $libdir "*) ;; - *) perm_rpath="$perm_rpath $libdir" ;; - esac - fi - - if test $link_install = no; then + if test $relink = no; then lib_linked=yes case "$hardcode_action" in immediate | unsupported) @@ -2543,7 +2539,9 @@ EOF done deplibs="$newdeplibs" + dep_rpath= + # Now hardcode the library paths if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do @@ -2569,7 +2567,7 @@ EOF if test -n "$libdir"; then eval flag=\"$hardcode_libdir_flag_spec\" - deplibs="$deplibs $flag" + dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in @@ -2580,10 +2578,11 @@ EOF done fi - # Substitute the hardcoded libdirs into the deplibs. + # Substitute the hardcoded libdirs into the dep_rpath. if test -n "$hardcode_libdir_separator"; then - deplibs=`$echo "X$deplibs" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` + dep_rpath=`$echo "X$dep_rpath" | $Xsed -e "s%@HARDCODE_LIBDIRS@%$hardcode_libdirs%g"` fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" # Add in the deplibs. test -n "$deplibs" && compile_command="$compile_command $deplibs" @@ -2781,10 +2780,10 @@ static const void *lt_preloaded_setup() { fi # Replace the output file specification. - if test $link_install = no; then + if test $relink = no; then compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` else - compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'_lt%g'` + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'T%g'` fi # Create the binary in the object directory, then wrap it. @@ -2815,11 +2814,8 @@ static const void *lt_preloaded_setup() { temp_rpath="$rpath" fi - # Delete the old output file. - $run $rm $output - if test -n "$shlibpath"; then - compile_command="$shlibpath_var=\"$shlibpath\$$shlibpath_var\" $compile_command" + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi if test -n "$runpath_var"; then @@ -2829,11 +2825,11 @@ static const void *lt_preloaded_setup() { for dir in $perm_rpath; do rpath="$rpath$dir:" done - compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command" + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi fi - if test "$hardcode_action" = relink; then + if test "$must_relink" = yes && test "$relink" = no; then # AGH! Flame the AIX and HP-UX people for me, will ya? $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 $echo "$modename: \`$output' will be relinked during installation" 1>&2 @@ -2842,6 +2838,12 @@ static const void *lt_preloaded_setup() { $show "$compile_command" $run eval "$compile_command" || exit $? + # Exit if relinking succeeded + test "$relink" = yes && exit 0 + + # Delete the old output file. + $run $rm $output + # Now create the wrapper script. $show "creating $output" @@ -2891,8 +2893,8 @@ if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: link_against_libtool_libs='$link_against_libtool_libs' - link_command=\"$link_command\" - link_dir=\"$link_dir\" + link_command=\"$link_command_save\" + link_dir=\"$link_dir_save\" else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then @@ -3092,10 +3094,29 @@ installed=no # Directory that this library needs to be installed in: libdir='$install_libdir' -link_command=\"$link_command\" -link_dir=\"$link_dir\"\ +link_command=\"$link_command_save\" +link_dir=\"$link_dir_save\"\ " + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case "$deplib" in + -L* | -R* | -l*) + newdependency_libs="$newdependency_libs $deplib" + ;; + *) + name=`echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + esac + done + $rm "$output_objdir/$outputname"i sed -e 's/^installed=no$/installed=yes/' \ -e "s%^dependency_libs=\(.*\)%dependency_libs='$newdependency_libs'%" \ @@ -3277,6 +3298,39 @@ link_dir=\"$link_dir\"\ exit 1 fi + link_command= + link_dir= + dependency_libs= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$dependency_libs" || test -z "$link_command" || test -z "$link_dir"; then + $echo "$modename: invalid libtool pseudo library \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $dependency_libs; do + case "$lib" in + *.la) + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + . $lib + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + ;; + esac + done + link_command= link_dir= library_names= @@ -3306,23 +3360,20 @@ link_dir=\"$link_dir\"\ test "X$dir" = "X$file/" && dir= dir="$dir$objdir" - if test "$hardcode_action" = relink; then + if test "$must_relink" = yes && test "$hardcode_into_libs" = yes; then if test "$finalize" = yes; then $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 - finalize_command="cd $link_dir; $SHELL $0 -mode=link-install $link_command" + finalize_command="cd $link_dir; $SHELL $0 --mode=relink $link_command" $show "$finalize_command" if $run eval "$finalize_command"; then : else - echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 continue fi - file="$objdir/$file"T else - $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 + $echo "$modename: error: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 + continue fi - else - # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi # See the names of the shared library. @@ -3332,9 +3383,12 @@ link_dir=\"$link_dir\"\ shift shift + srcname="$realname" + test "$must_relink" = yes && test "$hardcode_into_libs" = yes && srcname="$realname"T + # Install the shared library and build the symlinks. - $show "$install_prog $dir/$realname $destdir/$realname" - $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? test "X$dlname" = "X$realname" && dlname= if test $# -gt 0; then @@ -3367,25 +3421,6 @@ link_dir=\"$link_dir\"\ IFS="$save_ifs" fi - # Replace all uninstalled libtool libraries with the installed ones - newdependency_libs= - for deplib in $dependency_libs; do - case "$deplib" in - -L* | -R* | -l*) - newdependency_libs="$newdependency_libs $deplib" - ;; - *) - name=`echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` - if test -z "$libdir"; then - $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 - exit 1 - fi - newdependency_libs="$newdependency_libs $libdir/$name" - ;; - esac - done - # Install the pseudo-library for information purposes. name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` instname="$dir/$name"i @@ -3451,9 +3486,9 @@ link_dir=\"$link_dir\"\ # Do a test to see if this is really a libtool program. if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - link_against_libtool_libs= link_command= link_dir= + link_against_libtool_libs= # If there is no directory component, then add one. case "$file" in @@ -3485,19 +3520,30 @@ link_dir=\"$link_dir\"\ fi done - if test "$hardcode_action" = relink; then + link_command= + link_dir= + link_against_libtool_libs= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + if test "$must_relink" = yes; then if test "$finalize" = yes; then $echo "$modename: warning: relinking \`$file' on behalf of your buggy system linker" 1>&2 - finalize_command="cd $link_dir; $SHELL $0 -mode=link-install $link_command" + finalize_command="cd $link_dir; $SHELL $0 --mode=relink $link_command" $show "$finalize_command" if $run eval "$finalize_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 continue fi - file="$objdir/$file"_lt + file="$objdir/$file"T else - $echo "$modename: warning: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 + $echo "$modename: error: cannot relink \`$file' on behalf of your buggy system linker" 1>&2 + continue fi else # Install the binary that we compiled earlier. -- 2.47.2