Explorar o código

dpkg-shlibdeps: add cross-compilation support

* scripts/Dpkg/Shlibs.pm: Support cross-compilation by adding
directories containing libraries for the architecture that is
being crossbuilt.
Raphael Hertzog %!s(int64=18) %!d(string=hai) anos
pai
achega
626dda6f55
Modificáronse 3 ficheiros con 36 adicións e 1 borrados
  1. 6 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 27 1
      scripts/Dpkg/Shlibs.pm

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-03-27  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Shlibs.pm: Support cross-compilation by adding
+	directories containing libraries for the architecture that is
+	being crossbuilt.
+
 2008-03-27  Raphael Hertzog  <hertzog@debian.org>
             Frank Lichtenheld  <djpig@debian.org>
             Joey Hess  <joeyh@debian.org>

+ 3 - 0
debian/changelog

@@ -116,6 +116,9 @@ dpkg (1.14.17) UNRELEASED; urgency=low
       respectively.
   * dpkg-source has a new --no-check option. It disables GPG check and
     checksums checks. Closes: #220758
+  * dpkg-shlibdeps is now able to look into directories containing libraries
+    used by cross-built binaries provided that the right environment variable
+    are set. Closes: #453267
 
   [ Frank Lichtenheld ]
   * Add a warning in dpkg-buildpackage if the build-dependencies are not

+ 27 - 1
scripts/Dpkg/Shlibs.pm

@@ -28,11 +28,37 @@ use Dpkg::Gettext;
 use Dpkg::ErrorHandling qw(syserr);
 use Dpkg::Shlibs::Objdump;
 use Dpkg::Path qw(resolve_symlink canonpath);
+use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch);
 
 use constant DEFAULT_LIBRARY_PATH =>
     qw(/lib /usr/lib /lib32 /usr/lib32 /lib64 /usr/lib64
        /emul/ia32-linux/lib /emul/ia32-linux/usr/lib);
-our @librarypaths = (DEFAULT_LIBRARY_PATH);
+
+# Adjust set of directories to consider when we're in a situation of a
+# cross-build or a build of a cross-compiler
+my @crosslibrarypaths;
+my $crossprefix;
+# Detect cross compiler builds
+if ($ENV{GCC_TARGET}) {
+    $crossprefix = debarch_to_gnutriplet($ENV{GCC_TARGET});
+}
+if ($ENV{DEB_TARGET_GNU_TYPE} and
+    ($ENV{DEB_TARGET_GNU_TYPE} ne $ENV{DEB_BUILD_GNU_TYPE}))
+{
+    $crossprefix = $ENV{DEB_TARGET_GNU_TYPE};
+}
+# host for normal cross builds.
+if (get_build_arch() ne get_host_arch()) {
+    $crossprefix = debarch_to_gnutriplet(get_host_arch());
+}
+# Define list of directories containing crossbuilt libraries
+if ($crossprefix) {
+    push @crosslibrarypaths, "/$crossprefix/lib", "/usr/$crossprefix/lib",
+            "/$crossprefix/lib32", "/usr/$crossprefix/lib32",
+            "/$crossprefix/lib64", "/usr/$crossprefix/lib64";
+}
+
+our @librarypaths = (DEFAULT_LIBRARY_PATH, @crosslibrarypaths);
 
 # Update library paths with LD_LIBRARY_PATH
 if ($ENV{LD_LIBRARY_PATH}) {