blib/lib/ExtUtils/Liblist/Kid.pm untested

filter: Statementstmt 0.0% 0 / 328 Branchbran 0.0% 0 / 238 Conditioncond 0.0% 0 / 112 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 21 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 712 CC 120 SCAR 71.7
CC
120
Cov
0%
_vms_ext
2352.0
_unix_os2_ext
1560.0
_win32_ext
380.0
CRAP 1295.4
1 package ExtUtils::Liblist::Kid;
2  
3 # XXX Splitting this out into its own .pm is a temporary solution.
4  
5 # This kid package is to be used by MakeMaker. It will not work if
6 # $self is not a Makemaker.
7  
8 use 5.006;
9  
10 # Broken out of MakeMaker from version 4.11
11  
12 use strict;
13 use warnings;
14 our $VERSION = '7.13_01';
15 $VERSION = eval $VERSION;
16  
17 use ExtUtils::MakeMaker::Config;
18 use Cwd 'cwd';
19 use File::Basename;
20 use File::Spec;
21  
22 sub ext {
23 if ( $^O eq 'VMS' ) { return &_vms_ext; }
24 elsif ( $^O eq 'MSWin32' ) { return &_win32_ext; }
25 else { return &_unix_os2_ext; }
26 }
27  
28 sub _unix_os2_ext {
29 my ( $self, $potential_libs, $verbose, $give_libs ) = @_;
30 $verbose ||= 0;
31  
32 if ( $^O =~ /os2|android/ and $Config{perllibs} ) {
33  
34 # Dynamic libraries are not transitive, so we may need including
35 # the libraries linked against perl.dll/libperl.so again.
36  
37 $potential_libs .= " " if $potential_libs;
38 $potential_libs .= $Config{perllibs};
39 }
40 return ( "", "", "", "", ( $give_libs ? [] : () ) ) unless $potential_libs;
41 warn "Potential libraries are '$potential_libs':\n" if $verbose;
42  
43 my ( $so ) = $Config{so};
44 my ( $libs ) = defined $Config{perllibs} ? $Config{perllibs} : $Config{libs};
45 my $Config_libext = $Config{lib_ext} || ".a";
46 my $Config_dlext = $Config{dlext};
47  
48 # compute $extralibs, $bsloadlibs and $ldloadlibs from
49 # $potential_libs
50 # this is a rewrite of Andy Dougherty's extliblist in perl
51  
52 my ( @searchpath ); # from "-L/path" entries in $potential_libs
53 my ( @libpath ) = split " ", $Config{'libpth'} || '';
54 my ( @ldloadlibs, @bsloadlibs, @extralibs, @ld_run_path, %ld_run_path_seen );
55 my ( @libs, %libs_seen );
56 my ( $fullname, @fullname );
57 my ( $pwd ) = cwd(); # from Cwd.pm
58 my ( $found ) = 0;
59  
60 foreach my $thislib ( split ' ', $potential_libs ) {
61 my ( $custom_name ) = '';
62  
63 # Handle possible linker path arguments.
64 if ( $thislib =~ s/^(-[LR]|-Wl,-R|-Wl,-rpath,)// ) { # save path flag type
65 my ( $ptype ) = $1;
66 unless ( -d $thislib ) {
67 warn "$ptype$thislib ignored, directory does not exist\n"
68 if $verbose;
69 next;
70 }
71 my ( $rtype ) = $ptype;
72 if ( ( $ptype eq '-R' ) or ( $ptype =~ m!^-Wl,-[Rr]! ) ) {
73 if ( $Config{'lddlflags'} =~ /-Wl,-[Rr]/ ) {
74 $rtype = '-Wl,-R';
75 }
76 elsif ( $Config{'lddlflags'} =~ /-R/ ) {
77 $rtype = '-R';
78 }
79 }
80 unless ( File::Spec->file_name_is_absolute( $thislib ) ) {
81 warn "Warning: $ptype$thislib changed to $ptype$pwd/$thislib\n";
82 $thislib = $self->catdir( $pwd, $thislib );
83 }
84 push( @searchpath, $thislib );
85 push( @extralibs, "$ptype$thislib" );
86 push( @ldloadlibs, "$rtype$thislib" );
87 next;
88 }
89  
90 if ( $thislib =~ m!^-Wl,! ) {
91 push( @extralibs, $thislib );
92 push( @ldloadlibs, $thislib );
93 next;
94 }
95  
96 # Handle possible library arguments.
97 if ( $thislib =~ s/^-l(:)?// ) {
98 # Handle -l:foo.so, which means that the library will
99 # actually be called foo.so, not libfoo.so. This
100 # is used in Android by ExtUtils::Depends to allow one XS
101 # module to link to another.
102 $custom_name = $1 || '';
103 }
104 else {
105 warn "Unrecognized argument in LIBS ignored: '$thislib'\n";
106 next;
107 }
108  
109 my ( $found_lib ) = 0;
110 foreach my $thispth ( @searchpath, @libpath ) {
111  
112 # Try to find the full name of the library. We need this to
113 # determine whether it's a dynamically-loadable library or not.
114 # This tends to be subject to various os-specific quirks.
115 # For gcc-2.6.2 on linux (March 1995), DLD can not load
116 # .sa libraries, with the exception of libm.sa, so we
117 # deliberately skip them.
118 if ((@fullname =
119 $self->lsdir($thispth, "^\Qlib$thislib.$so.\E[0-9]+")) ||
120 (@fullname =
121 $self->lsdir($thispth, "^\Qlib$thislib.\E[0-9]+\Q\.$so"))) {
122 # Take care that libfoo.so.10 wins against libfoo.so.9.
123 # Compare two libraries to find the most recent version
124 # number. E.g. if you have libfoo.so.9.0.7 and
125 # libfoo.so.10.1, first convert all digits into two
126 # decimal places. Then we'll add ".00" to the shorter
127 # strings so that we're comparing strings of equal length
128 # Thus we'll compare libfoo.so.09.07.00 with
129 # libfoo.so.10.01.00. Some libraries might have letters
130 # in the version. We don't know what they mean, but will
131 # try to skip them gracefully -- we'll set any letter to
132 # '0'. Finally, sort in reverse so we can take the
133 # first element.
134  
135 #TODO: iterate through the directory instead of sorting
136  
137 $fullname = "$thispth/" . (
138 sort {
139 my ( $ma ) = $a;
140 my ( $mb ) = $b;
141 $ma =~ tr/A-Za-z/0/s;
142 $ma =~ s/\b(\d)\b/0$1/g;
143 $mb =~ tr/A-Za-z/0/s;
144 $mb =~ s/\b(\d)\b/0$1/g;
145 while ( length( $ma ) < length( $mb ) ) { $ma .= ".00"; }
146 while ( length( $mb ) < length( $ma ) ) { $mb .= ".00"; }
147  
148 # Comparison deliberately backwards
149 $mb cmp $ma;
150 } @fullname
151 )[0];
152 }
153 elsif ( -f ( $fullname = "$thispth/lib$thislib.$so" )
154 && ( ( $Config{'dlsrc'} ne "dl_dld.xs" ) || ( $thislib eq "m" ) ) )
155 {
156 }
157 elsif (-f ( $fullname = "$thispth/lib${thislib}_s$Config_libext" )
158 && ( $Config{'archname'} !~ /RM\d\d\d-svr4/ )
159 && ( $thislib .= "_s" ) )
160 { # we must explicitly use _s version
161 }
162 elsif ( -f ( $fullname = "$thispth/lib$thislib$Config_libext" ) ) {
163 }
164 elsif ( defined( $Config_dlext )
165 && -f ( $fullname = "$thispth/lib$thislib.$Config_dlext" ) )
166 {
167 }
168 elsif ( -f ( $fullname = "$thispth/$thislib$Config_libext" ) ) {
169 }
170 elsif ( -f ( $fullname = "$thispth/lib$thislib.dll$Config_libext" ) ) {
171 }
172 elsif ( $^O eq 'cygwin' && -f ( $fullname = "$thispth/$thislib.dll" ) ) {
173 }
174 elsif ( -f ( $fullname = "$thispth/Slib$thislib$Config_libext" ) ) {
175 }
176 elsif ($^O eq 'dgux'
177 && -l ( $fullname = "$thispth/lib$thislib$Config_libext" )
178 && readlink( $fullname ) =~ /^elink:/s )
179 {
180  
181 # Some of DG's libraries look like misconnected symbolic
182 # links, but development tools can follow them. (They
183 # look like this:
184 #
185 # libm.a -> elink:${SDE_PATH:-/usr}/sde/\
186 # ${TARGET_BINARY_INTERFACE:-m88kdgux}/usr/lib/libm.a
187 #
188 # , the compilation tools expand the environment variables.)
189 }
190 elsif ( $custom_name && -f ( $fullname = "$thispth/$thislib" ) ) {
191 }
192 else {
193 warn "$thislib not found in $thispth\n" if $verbose;
194 next;
195 }
196 warn "'-l$thislib' found at $fullname\n" if $verbose;
197 push @libs, $fullname unless $libs_seen{$fullname}++;
198 $found++;
199 $found_lib++;
200  
201 # Now update library lists
202  
203 # what do we know about this library...
204 my $is_dyna = ( $fullname !~ /\Q$Config_libext\E\z/ );
205 my $in_perl = ( $libs =~ /\B-l:?\Q${thislib}\E\b/s );
206  
207 # include the path to the lib once in the dynamic linker path
208 # but only if it is a dynamic lib and not in Perl itself
209 my ( $fullnamedir ) = dirname( $fullname );
210 push @ld_run_path, $fullnamedir
211 if $is_dyna
212 && !$in_perl
213 && !$ld_run_path_seen{$fullnamedir}++;
214  
215 # Do not add it into the list if it is already linked in
216 # with the main perl executable.
217 # We have to special-case the NeXT, because math and ndbm
218 # are both in libsys_s
219 unless (
220 $in_perl
221 || ( $Config{'osname'} eq 'next'
222 && ( $thislib eq 'm' || $thislib eq 'ndbm' ) )
223 )
224 {
225 push( @extralibs, "-l$custom_name$thislib" );
226 }
227  
228 # We might be able to load this archive file dynamically
229 if ( ( $Config{'dlsrc'} =~ /dl_next/ && $Config{'osvers'} lt '4_0' )
230 || ( $Config{'dlsrc'} =~ /dl_dld/ ) )
231 {
232  
233 # We push -l$thislib instead of $fullname because
234 # it avoids hardwiring a fixed path into the .bs file.
235 # Mkbootstrap will automatically add dl_findfile() to
236 # the .bs file if it sees a name in the -l format.
237 # USE THIS, when dl_findfile() is fixed:
238 # push(@bsloadlibs, "-l$thislib");
239 # OLD USE WAS while checking results against old_extliblist
240 push( @bsloadlibs, "$fullname" );
241 }
242 else {
243 if ( $is_dyna ) {
244  
245 # For SunOS4, do not add in this shared library if
246 # it is already linked in the main perl executable
247 push( @ldloadlibs, "-l$custom_name$thislib" )
248 unless ( $in_perl and $^O eq 'sunos' );
249 }
250 else {
251 push( @ldloadlibs, "-l$custom_name$thislib" );
252 }
253 }
254 last; # found one here so don't bother looking further
255 }
256 warn "Warning (mostly harmless): " . "No library found for -l$thislib\n"
257 unless $found_lib > 0;
258 }
259  
260 unless ( $found ) {
261 return ( '', '', '', '', ( $give_libs ? \@libs : () ) );
262 }
263 else {
264 return ( "@extralibs", "@bsloadlibs", "@ldloadlibs", join( ":", @ld_run_path ), ( $give_libs ? \@libs : () ) );
265 }
266 }
267  
268 sub _win32_ext {
269  
270 require Text::ParseWords;
271  
272 my ( $self, $potential_libs, $verbose, $give_libs ) = @_;
273 $verbose ||= 0;
274  
275 # If user did not supply a list, we punt.
276 # (caller should probably use the list in $Config{libs})
277 return ( "", "", "", "", ( $give_libs ? [] : () ) ) unless $potential_libs;
278  
279 # TODO: make this use MM_Win32.pm's compiler detection
280 my %libs_seen;
281 my @extralibs;
282 my $cc = $Config{cc} || '';
283 my $VC = $cc =~ /\bcl\b/i;
284 my $GC = $cc =~ /\bgcc\b/i;
285  
286 my $libext = _win32_lib_extensions();
287 my @searchpath = ( '' ); # from "-L/path" entries in $potential_libs
288 my @libpath = _win32_default_search_paths( $VC, $GC );
289 my $pwd = cwd(); # from Cwd.pm
290 my $search = 1;
291  
292 # compute @extralibs from $potential_libs
293 my @lib_search_list = _win32_make_lib_search_list( $potential_libs, $verbose );
294 for ( @lib_search_list ) {
295  
296 my $thislib = $_;
297  
298 # see if entry is a flag
299 if ( /^:\w+$/ ) {
300 $search = 0 if lc eq ':nosearch';
301 $search = 1 if lc eq ':search';
302 _debug( "Ignoring unknown flag '$thislib'\n", $verbose ) if !/^:(no)?(search|default)$/i;
303 next;
304 }
305  
306 # if searching is disabled, do compiler-specific translations
307 unless ( $search ) {
308 s/^-l(.+)$/$1.lib/ unless $GC;
309 s/^-L/-libpath:/ if $VC;
310 push( @extralibs, $_ );
311 next;
312 }
313  
314 # handle possible linker path arguments
315 if ( s/^-L// and not -d ) {
316 _debug( "$thislib ignored, directory does not exist\n", $verbose );
317 next;
318 }
319 elsif ( -d ) {
320 unless ( File::Spec->file_name_is_absolute( $_ ) ) {
321 warn "Warning: '$thislib' changed to '-L$pwd/$_'\n";
322 $_ = $self->catdir( $pwd, $_ );
323 }
324 push( @searchpath, $_ );
325 next;
326 }
327  
328 my @paths = ( @searchpath, @libpath );
329 my ( $fullname, $path ) = _win32_search_file( $thislib, $libext, \@paths, $verbose, $GC );
330  
331 if ( !$fullname ) {
332 warn "Warning (mostly harmless): No library found for $thislib\n";
333 next;
334 }
335  
336 _debug( "'$thislib' found as '$fullname'\n", $verbose );
337 push( @extralibs, $fullname );
338 $libs_seen{$fullname} = 1 if $path; # why is this a special case?
339 }
340  
341 my @libs = sort keys %libs_seen;
342  
343 return ( '', '', '', '', ( $give_libs ? \@libs : () ) ) unless @extralibs;
344  
345 # make sure paths with spaces are properly quoted
346 @extralibs = map { qq["$_"] } @extralibs;
347 @libs = map { qq["$_"] } @libs;
348  
349 my $lib = join( ' ', @extralibs );
350  
351 # normalize back to backward slashes (to help braindead tools)
352 # XXX this may break equally braindead GNU tools that don't understand
353 # backslashes, either. Seems like one can't win here. Cursed be CP/M.
354 $lib =~ s,/,\\,g;
355  
356 _debug( "Result: $lib\n", $verbose );
357 wantarray ? ( $lib, '', $lib, '', ( $give_libs ? \@libs : () ) ) : $lib;
358 }
359  
360 sub _win32_make_lib_search_list {
361 my ( $potential_libs, $verbose ) = @_;
362  
363 # If Config.pm defines a set of default libs, we always
364 # tack them on to the user-supplied list, unless the user
365 # specified :nodefault
366 my $libs = $Config{'perllibs'};
367 $potential_libs = join( ' ', $potential_libs, $libs ) if $libs and $potential_libs !~ /:nodefault/i;
368 _debug( "Potential libraries are '$potential_libs':\n", $verbose );
369  
370 $potential_libs =~ s,\\,/,g; # normalize to forward slashes
371  
372 my @list = Text::ParseWords::quotewords( '\s+', 0, $potential_libs );
373  
374 return @list;
375 }
376  
377 sub _win32_default_search_paths {
378 my ( $VC, $GC ) = @_;
379  
380 my $libpth = $Config{'libpth'} || '';
381 $libpth =~ s,\\,/,g; # normalize to forward slashes
382  
383 my @libpath = Text::ParseWords::quotewords( '\s+', 0, $libpth );
384 push @libpath, "$Config{installarchlib}/CORE"; # add "$Config{installarchlib}/CORE" to default search path
385  
386 push @libpath, split /;/, $ENV{LIB} if $VC and $ENV{LIB};
387 push @libpath, split /;/, $ENV{LIBRARY_PATH} if $GC and $ENV{LIBRARY_PATH};
388  
389 return @libpath;
390 }
391  
392 sub _win32_search_file {
393 my ( $thislib, $libext, $paths, $verbose, $GC ) = @_;
394  
395 my @file_list = _win32_build_file_list( $thislib, $GC, $libext );
396  
397 for my $lib_file ( @file_list ) {
398 for my $path ( @{$paths} ) {
399 my $fullname = $lib_file;
400 $fullname = "$path\\$fullname" if $path;
401  
402 return ( $fullname, $path ) if -f $fullname;
403  
404 _debug( "'$thislib' not found as '$fullname'\n", $verbose );
405 }
406 }
407  
408 return;
409 }
410  
411 sub _win32_build_file_list {
412 my ( $lib, $GC, $extensions ) = @_;
413  
414 my @pre_fixed = _win32_build_prefixed_list( $lib, $GC );
415 return map _win32_attach_extensions( $_, $extensions ), @pre_fixed;
416 }
417  
418 sub _win32_build_prefixed_list {
419 my ( $lib, $GC ) = @_;
420  
421 return $lib if $lib !~ s/^-l//;
422 return $lib if $lib =~ /^lib/ and !$GC;
423  
424 ( my $no_prefix = $lib ) =~ s/^lib//i;
425 $lib = "lib$lib" if $no_prefix eq $lib;
426  
427 return ( $lib, $no_prefix ) if $GC;
428 return ( $no_prefix, $lib );
429 }
430  
431 sub _win32_attach_extensions {
432 my ( $lib, $extensions ) = @_;
433 return map _win32_try_attach_extension( $lib, $_ ), @{$extensions};
434 }
435  
436 sub _win32_try_attach_extension {
437 my ( $lib, $extension ) = @_;
438  
439 return $lib if $lib =~ /\Q$extension\E$/i;
440 return "$lib$extension";
441 }
442  
443 sub _win32_lib_extensions {
444 my @extensions;
445 push @extensions, $Config{'lib_ext'} if $Config{'lib_ext'};
446 push @extensions, '.dll.a' if grep { m!^\.a$! } @extensions;
447 push @extensions, '.lib' unless grep { m!^\.lib$! } @extensions;
448 return \@extensions;
449 }
450  
451 sub _debug {
452 my ( $message, $verbose ) = @_;
453 return if !$verbose;
454 warn $message;
455 return;
456 }
457  
458 sub _vms_ext {
459 my ( $self, $potential_libs, $verbose, $give_libs ) = @_;
460 $verbose ||= 0;
461  
462 my ( @crtls, $crtlstr );
463 @crtls = ( ( $Config{'ldflags'} =~ m-/Debug-i ? $Config{'dbgprefix'} : '' ) . 'PerlShr/Share' );
464 push( @crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'} );
465 push( @crtls, grep { not /\(/ } split /\s+/, $Config{'libc'} );
466  
467 # In general, we pass through the basic libraries from %Config unchanged.
468 # The one exception is that if we're building in the Perl source tree, and
469 # a library spec could be resolved via a logical name, we go to some trouble
470 # to insure that the copy in the local tree is used, rather than one to
471 # which a system-wide logical may point.
472 if ( $self->{PERL_SRC} ) {
473 my ( $locspec, $type );
474 foreach my $lib ( @crtls ) {
475 if ( ( $locspec, $type ) = $lib =~ m{^([\w\$-]+)(/\w+)?} and $locspec =~ /perl/i ) {
476 if ( lc $type eq '/share' ) { $locspec .= $Config{'exe_ext'}; }
477 elsif ( lc $type eq '/library' ) { $locspec .= $Config{'lib_ext'}; }
478 else { $locspec .= $Config{'obj_ext'}; }
479 $locspec = $self->catfile( $self->{PERL_SRC}, $locspec );
480 $lib = "$locspec$type" if -e $locspec;
481 }
482 }
483 }
484 $crtlstr = @crtls ? join( ' ', @crtls ) : '';
485  
486 unless ( $potential_libs ) {
487 warn "Result:\n\tEXTRALIBS: \n\tLDLOADLIBS: $crtlstr\n" if $verbose;
488 return ( '', '', $crtlstr, '', ( $give_libs ? [] : () ) );
489 }
490  
491 my ( %found, @fndlibs, $ldlib );
492 my $cwd = cwd();
493 my ( $so, $lib_ext, $obj_ext ) = @Config{ 'so', 'lib_ext', 'obj_ext' };
494  
495 # List of common Unix library names and their VMS equivalents
496 # (VMS equivalent of '' indicates that the library is automatically
497 # searched by the linker, and should be skipped here.)
498 my ( @flibs, %libs_seen );
499 my %libmap = (
500 'm' => '',
501 'f77' => '',
502 'F77' => '',
503 'V77' => '',
504 'c' => '',
505 'malloc' => '',
506 'crypt' => '',
507 'resolv' => '',
508 'c_s' => '',
509 'socket' => '',
510 'X11' => 'DECW$XLIBSHR',
511 'Xt' => 'DECW$XTSHR',
512 'Xm' => 'DECW$XMLIBSHR',
513 'Xmu' => 'DECW$XMULIBSHR'
514 );
515  
516 warn "Potential libraries are '$potential_libs'\n" if $verbose;
517  
518 # First, sort out directories and library names in the input
519 my ( @dirs, @libs );
520 foreach my $lib ( split ' ', $potential_libs ) {
521 push( @dirs, $1 ), next if $lib =~ /^-L(.*)/;
522 push( @dirs, $lib ), next if $lib =~ /[:>\]]$/;
523 push( @dirs, $lib ), next if -d $lib;
524 push( @libs, $1 ), next if $lib =~ /^-l(.*)/;
525 push( @libs, $lib );
526 }
527 push( @dirs, split( ' ', $Config{'libpth'} ) );
528  
529 # Now make sure we've got VMS-syntax absolute directory specs
530 # (We don't, however, check whether someone's hidden a relative
531 # path in a logical name.)
532 foreach my $dir ( @dirs ) {
533 unless ( -d $dir ) {
534 warn "Skipping nonexistent Directory $dir\n" if $verbose > 1;
535 $dir = '';
536 next;
537 }
538 warn "Resolving directory $dir\n" if $verbose;
539 if ( File::Spec->file_name_is_absolute( $dir ) ) {
540 $dir = VMS::Filespec::vmspath( $dir );
541 }
542 else {
543 $dir = $self->catdir( $cwd, $dir );
544 }
545 }
546 @dirs = grep { length( $_ ) } @dirs;
547 unshift( @dirs, '' ); # Check each $lib without additions first
548  
549 LIB: foreach my $lib ( @libs ) {
550 if ( exists $libmap{$lib} ) {
551 next unless length $libmap{$lib};
552 $lib = $libmap{$lib};
553 }
554  
555 my ( @variants, $cand );
556 my ( $ctype ) = '';
557  
558 # If we don't have a file type, consider it a possibly abbreviated name and
559 # check for common variants. We try these first to grab libraries before
560 # a like-named executable image (e.g. -lperl resolves to perlshr.exe
561 # before perl.exe).
562 if ( $lib !~ /\.[^:>\]]*$/ ) {
563 push( @variants, "${lib}shr", "${lib}rtl", "${lib}lib" );
564 push( @variants, "lib$lib" ) if $lib !~ /[:>\]]/;
565 }
566 push( @variants, $lib );
567 warn "Looking for $lib\n" if $verbose;
568 foreach my $variant ( @variants ) {
569 my ( $fullname, $name );
570  
571 foreach my $dir ( @dirs ) {
572 my ( $type );
573  
574 $name = "$dir$variant";
575 warn "\tChecking $name\n" if $verbose > 2;
576 $fullname = VMS::Filespec::rmsexpand( $name );
577 if ( defined $fullname and -f $fullname ) {
578  
579 # It's got its own suffix, so we'll have to figure out the type
580 if ( $fullname =~ /(?:$so|exe)$/i ) { $type = 'SHR'; }
581 elsif ( $fullname =~ /(?:$lib_ext|olb)$/i ) { $type = 'OLB'; }
582 elsif ( $fullname =~ /(?:$obj_ext|obj)$/i ) {
583 warn "Warning (mostly harmless): " . "Plain object file $fullname found in library list\n";
584 $type = 'OBJ';
585 }
586 else {
587 warn "Warning (mostly harmless): " . "Unknown library type for $fullname; assuming shared\n";
588 $type = 'SHR';
589 }
590 }
591 elsif (-f ( $fullname = VMS::Filespec::rmsexpand( $name, $so ) )
592 or -f ( $fullname = VMS::Filespec::rmsexpand( $name, '.exe' ) ) )
593 {
594 $type = 'SHR';
595 $name = $fullname unless $fullname =~ /exe;?\d*$/i;
596 }
597 elsif (
598 not length( $ctype ) and # If we've got a lib already,
599 # don't bother
600 ( -f ( $fullname = VMS::Filespec::rmsexpand( $name, $lib_ext ) ) or -f ( $fullname = VMS::Filespec::rmsexpand( $name, '.olb' ) ) )
601 )
602 {
603 $type = 'OLB';
604 $name = $fullname unless $fullname =~ /olb;?\d*$/i;
605 }
606 elsif (
607 not length( $ctype ) and # If we've got a lib already,
608 # don't bother
609 ( -f ( $fullname = VMS::Filespec::rmsexpand( $name, $obj_ext ) ) or -f ( $fullname = VMS::Filespec::rmsexpand( $name, '.obj' ) ) )
610 )
611 {
612 warn "Warning (mostly harmless): " . "Plain object file $fullname found in library list\n";
613 $type = 'OBJ';
614 $name = $fullname unless $fullname =~ /obj;?\d*$/i;
615 }
616 if ( defined $type ) {
617 $ctype = $type;
618 $cand = $name;
619 last if $ctype eq 'SHR';
620 }
621 }
622 if ( $ctype ) {
623  
624 push @{ $found{$ctype} }, $cand;
625 warn "\tFound as $cand (really $fullname), type $ctype\n"
626 if $verbose > 1;
627 push @flibs, $name unless $libs_seen{$fullname}++;
628 next LIB;
629 }
630 }
631 warn "Warning (mostly harmless): " . "No library found for $lib\n";
632 }
633  
634 push @fndlibs, @{ $found{OBJ} } if exists $found{OBJ};
635 push @fndlibs, map { "$_/Library" } @{ $found{OLB} } if exists $found{OLB};
636 push @fndlibs, map { "$_/Share" } @{ $found{SHR} } if exists $found{SHR};
637 my $lib = join( ' ', @fndlibs );
638  
639 $ldlib = $crtlstr ? "$lib $crtlstr" : $lib;
640 $ldlib =~ s/^\s+|\s+$//g;
641 warn "Result:\n\tEXTRALIBS: $lib\n\tLDLOADLIBS: $ldlib\n" if $verbose;
642 wantarray ? ( $lib, '', $ldlib, '', ( $give_libs ? \@flibs : () ) ) : $lib;
643 }
644  
645 1;