* Thierry Reding wrote: > Hi, > > the following patch adds support for gcc's --sysroot argument to libtool. > I'll post the patch first and will reply to it, giving more details where > needed. > > I've been building a number of packages with variations of this patch > depending on the libtool version. The most tricky packages were those > building multiple libtool libraries with inter-dependencies (like glib and > gtk). But even those build fine with this patch. > > One more important fact is that after installing packages I always delete the > .la files from my sysroot so that any dependencies will never try to link > against the .la file but against the .so directly. This seems to work rather > well. > > I welcome any comments or suggestions. > > Thierry >
> diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh > index 365ba0c..d7453a7 100644 > --- a/libltdl/config/ltmain.m4sh > +++ b/libltdl/config/ltmain.m4sh > @@ -1608,6 +1608,10 @@ func_mode_install () > func_append dir "$objdir" > > if test -n "$relink_command"; then > + if test -n "$sysroot"; then > + libdir=`$ECHO "$libdir" | $SED -e "s%$sysroot%%"` > + relink_command=`$ECHO "$relink_command" | $SED -e "s%(\(.*\))%\1 > -L$destdir)%"` > + fi > # Determine the prefix the user has applied to our future dir. > inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` > This particular hunk is important to make libdir point to the correct library directory (typically /usr/lib) inside the sysroot. Changing the relink_command no longer seems necassary. If I remember correctly, this used to be necessary for building older gtk packages. When removing that link from the hunk, I can currently not reproduce the errors I was encountering at the time. It doesn't seem to break anything either, so I've left it in just in case. > @@ -4227,6 +4231,13 @@ func_mode_link () > prev= > continue > ;; > + sysroot) > + sysroot="$qarg" > + prev= > + func_append compiler_flags " --sysroot $qarg" > + func_append compile_command " --sysroot $qarg" > + continue > + ;; > weak) > func_append weak_libs " $arg" > prev= > @@ -4327,6 +4338,11 @@ func_mode_link () > continue > ;; > > + --sysroot) > + prev=sysroot > + continue > + ;; > + > # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* > # so, if we see these flags be careful not to treat them like -L > -L[A-Z][A-Z]*:*) These two hunks will take the --sysroot argument from the libtool command-line and forward them to the compiler/linker. > @@ -4964,7 +4980,7 @@ func_mode_link () > for searchdir in $searchdirs; do > for search_ext in .la $std_shrext .so .a; do > # Search the libtool library > - lib="$searchdir/lib${name}${search_ext}" > + lib="${sysroot}$searchdir/lib${name}${search_ext}" > if test -f "$lib"; then > if test "$search_ext" = ".la"; then > found=yes This hunk makes libtool look for libraries in the sysroot because those are the only libraries should be linked against. > @@ -5366,7 +5382,7 @@ func_mode_link () > > linkalldeplibs=no > if test "$link_all_deplibs" != no || test -z "$library_names" || > - test "$build_libtool_libs" = no; then > + test "$build_libtool_libs" = no || test -n "$sysroot"; then > linkalldeplibs=yes > fi > I came across this one only recently when trying to build new glib packages. The problem was that when trying to build the various glib binaries, they would depend on a certain .la file (say libgthread-2.0.la) which would pull in another .la file (say libgobject-2.0.la). Without setting linkalldeplibs=yes this would fail for sysroot builds. It didn't fail for non-sysroot builds, possibly because libtool would pick up the previously installed .la files from the build host. > @@ -5677,8 +5693,12 @@ func_mode_link () > add="$libdir/$linklib" > fi > else > - # We cannot seem to hardcode it, guess we'll fake it. > - add_dir="-L$libdir" > + if test -z "$sysroot"; then > + # We cannot seem to hardcode it, guess we'll fake it. > + add_dir="-L$libdir" > + else > + libdir=`$ECHO "$libdir" | $SED -e "s%$sysroot%%"` > + endif > # Try looking first in the location we're being installed to. > if test -n "$inst_prefix_dir"; then > case $libdir in This strips the sysroot from libdir because otherwise the subsequent code will add $inst_prefix_dir in front of the sysroot path, which will obviously not work. > @@ -8077,6 +8097,9 @@ EOF > fi > ;; > esac > + if test -n "$install_libdir"; then > + install_libdir="${sysroot}$install_libdir" > + fi > $ECHO > $output "\ > # $outputname - a libtool library file > # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION By prefixing the install_libdir variable with the sysroot we make sure that the resulting .la file will have the correct libdir path. > @@ -8119,6 +8142,10 @@ dlpreopen='$dlprefiles' > > # Directory that this library needs to be installed in: > libdir='$install_libdir'" > + if test -n "$sysroot"; then > + $ECHO >> $output "\ > +sysroot='$sysroot'" > + fi > if test "$installed" = no && test "$need_relink" = yes; then > $ECHO >> $output "\ > relink_command=\"$relink_command\"" This finally stores the sysroot (as passed to libtool during linking) in the .la file. In cases where a .la file is sourced, this makes sure that the sysroot variable is set correctly. Thierry
signature.asc
Description: Digital signature