libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH RFC] Add sysroot support.


From: Thierry Reding
Subject: [PATCH RFC] Add sysroot support.
Date: Wed, 7 Jul 2010 11:51:58 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

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\$%%"`
 
@@ -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]*:*)
@@ -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
@@ -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
 
@@ -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
@@ -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
@@ -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\""

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]