]> git.imager.perl.org - imager.git/commitdiff
[rt #75869] make sure EU::MM can find libraries found via pkg-config
authorTony Cook <tony@develop-help.com>
Fri, 27 Apr 2012 11:56:10 +0000 (21:56 +1000)
committerTony Cook <tony@develop-help.com>
Fri, 27 Apr 2012 11:56:10 +0000 (21:56 +1000)
lib/Imager/Probe.pm

index f44a66f6e8a8df2cb4de57cc43a00bd22f6f31b9..228c67c82cb60c3188714b4280cf4e2154f72247 100644 (file)
@@ -122,6 +122,21 @@ sub _probe_pkg {
   defines: $defines
   lflags: $lflags
 EOS
+      # rt 75869
+      # if Win32 doesn't provide this information, too bad
+      if (!grep(/^-L/, split " ", $lflags)
+         && $^O ne 'MSWin32') {
+       # pkg-config told us about the library, make sure it's
+       # somewhere EU::MM can find it
+       print "Checking if EU::MM can find $lflags\n" if $req->{verbose};
+       my ($extra, $bs_load, $ld_load, $ld_run_path) =
+         ExtUtils::Liblist->ext($lflags, $req->{verbose});
+       unless ($ld_run_path) {
+         # search our standard places
+         $lflags = _resolve_libs($req, $lflags);
+       }
+      }
+
       return
        {
         INC => $cflags,
@@ -314,6 +329,27 @@ sub _probe_test {
   return $result;
 }
 
+sub _resolve_libs {
+  my ($req, $lflags) = @_;
+
+  my @libs = grep /^-l/, split ' ', $lflags;
+  my %paths;
+  my @paths = _lib_paths($req);
+  my $so = $Config{so};
+  my $libext = $Config{_a};
+  for my $lib (@libs) {
+    $lib =~ s/^-l/lib/;
+
+    for my $path (@paths) {
+      if (-e "$path/$lib.$so" || -e "$path/$lib$libext") {
+       $paths{$path} = 1;
+      }
+    }
+  }
+
+  return join(" ", ( map "-L$_", keys %paths ), $lflags );
+}
+
 sub _lib_paths {
   my ($req) = @_;