I seem to be getting into the habit of replying to my own messages....
Here's another patch that attempts to do the right thing when tracking
down libraries.... now when you specify -l somelib, pp will (hopefully)
pick the runtime library name for the lib (libsomelib.so.N).

-Rob

P.S.  What I had originally asked for below was incorrect based on
what I've recently learned about shared library naming conventions.

Robert Wyrick wrote:

<snip>

1. When I use '-l somelib' with pp, pp currently adds libsomelib.so to the par.
On linux, at least, libsomelib.so is probably a symlink to libsomelib.so.1 which
is probably a symlink to libsomelib.so.1.2.... Shouldn't pp follow these symlinks
and add the real file (libsomelib.so.1.2) to the par rather than libsomelib.so?
I had to use '-l libsomelib.so.1.2' as a work around, but it'd be nice if pp chased
these symlinks for us....



*** PAR-0.85/lib/PAR/Packer.pm  Fri Jul  2 03:05:36 2004
--- PAR-0.85-rew/lib/PAR/Packer.pm      Thu Nov 18 20:43:19 2004
***************
*** 1274,1283 ****
      return (readline($handle) eq "PK\x03\x04");
  }
  
  sub _find_shlib {
      my ($self, $file, $script_name) = @_;
  
!     return $file if -e $file;
  
      if (not exists $ENV{ $Config{ldlibpthname} }) {
          print "Can't find $file. Environment variable "
--- 1274,1310 ----
      return (readline($handle) eq "PK\x03\x04");
  }
  
+ # _chase_lib - find the runtime link of a shared library
+ # Logic based on info found at the following sites:
+ # http://lists.debian.org/lsb-spec/1999/05/msg00011.html
+ # http://docs.sun.com/app/docs/doc/806-0641/6j9vuqujh?a=view#chapter5-97360
+ sub _chase_lib {
+     my ($self, $file) = @_;
+     while(-l $file)
+     {
+         if($file =~ /^(.*?\.$Config{dlext}\.\d+)\..*/)
+         {
+             return $1 if -e $1;
+         }
+         return $file if $file =~ /\.$Config{dlext}\.\d+$/;
+         my $dir = File::Basename::dirname($file);
+         $file = readlink $file;
+         unless(File::Spec->file_name_is_absolute($file))
+         {
+             $file = File::Spec->rel2abs($file, $dir);
+         }
+     }
+     if($file =~ /^(.*?\.$Config{dlext}\.\d+)\..*/)
+     {
+         return $1 if -e $1;
+     }
+     return $file;
+ }
+ 
  sub _find_shlib {
      my ($self, $file, $script_name) = @_;
  
!     return $self->_chase_lib($file) if -e $file;
  
      if (not exists $ENV{ $Config{ldlibpthname} }) {
          print "Can't find $file. Environment variable "
***************
*** 1289,1297 ****
          split(/\Q$Config{path_sep}\E/, $ENV{ $Config{ldlibpthname} }))
      {
          my $abs = File::Spec->catfile($dir, $file);
!         return $abs if -e $abs;
          $abs = File::Spec->catfile($dir, "$file.$Config{dlext}");
!         return $abs if -e $abs;
      }
  
      # be extra magical and prepend "lib" to the filename
--- 1316,1324 ----
          split(/\Q$Config{path_sep}\E/, $ENV{ $Config{ldlibpthname} }))
      {
          my $abs = File::Spec->catfile($dir, $file);
!         return $self->_chase_lib($abs) if -e $abs;
          $abs = File::Spec->catfile($dir, "$file.$Config{dlext}");
!         return $self->_chase_lib($abs) if -e $abs;
      }
  
      # be extra magical and prepend "lib" to the filename

Reply via email to