1 # NOTE: Derived from ../../lib/DynaLoader.pm.
2 # Changes made here will be lost when autosplit again.
6 #line 241 "../../lib/DynaLoader.pm (autosplit into ../../lib/auto/DynaLoader/dl_findfile.al)"
8 # Read ext/DynaLoader/DynaLoader.doc for detailed information.
9 # This function does not automatically consider the architecture
10 # or the perl library auto directories.
12 my (@dirs, $dir); # which directories to search
13 my (@found); # full paths to real files we have found
14 my $dl_ext= 'dll'; # $Config::Config{'dlext'} suffix for perl extensions
15 my $dl_so = 'dll'; # $Config::Config{'so'} suffix for shared libraries
17 print STDERR "dl_findfile(@args)\n" if $dl_debug;
19 # accumulate directories but process files as they appear
21 # Special fast case: full filepath requires no search
22 if ($Is_VMS && m%[:>/\]]% && -f $_) {
23 push(@found,dl_expandspec(VMS::Filespec::vmsify($_)));
24 last arg unless wantarray;
30 last arg unless wantarray;
33 elsif (m:/: && -f $_ && !$do_expand) {
35 last arg unless wantarray;
39 # Deal with directories first:
40 # Using a -L prefix is the preferred option (faster and more robust)
41 if (m:^-L:) { s/^-L//; push(@dirs, $_); next; }
44 # Otherwise we try to try to spot directories by a heuristic
45 # (this is a more complicated issue than it first appears)
46 if (m/:/ && -d $_) { push(@dirs, $_); next; }
47 # Only files should get this far...
48 my(@names, $name); # what filenames to look for
51 foreach $dir (@dirs, @dl_library_path) {
53 $dir =~ s/^([^:]+)$/:$1/;
55 foreach $name (@names) {
56 my($file) = "$dir:$name";
57 print STDERR " checking in $dir for $name\n" if $dl_debug;
60 next arg; # no need to look any further
67 # Otherwise we try to try to spot directories by a heuristic
68 # (this is a more complicated issue than it first appears)
69 if (m:/: && -d $_) { push(@dirs, $_); next; }
71 # VMS: we may be using native VMS directory syntax instead of
72 # Unix emulation, so check this as well
73 if ($Is_VMS && /[:>\]]/ && -d $_) { push(@dirs, $_); next; }
75 # Only files should get this far...
76 my(@names, $name); # what filenames to look for
77 if (m:-l: ) { # convert -lname to appropriate library name
79 push(@names,"lib$_.$dl_so");
80 push(@names,"lib$_.a");
81 } else { # Umm, a bare name. Try various alternatives:
82 # these should be ordered with the most likely first
83 push(@names,"$_.$dl_ext") unless m/\.$dl_ext$/o;
84 push(@names,"$_.$dl_so") unless m/\.$dl_so$/o;
85 push(@names,"lib$_.$dl_so") unless m:/:;
86 push(@names,"$_.a") if !m/\.a$/ and $dlsrc eq "dl_dld.xs";
89 foreach $dir (@dirs, @dl_library_path) {
91 chop($dir = VMS::Filespec::unixpath($dir)) if $Is_VMS;
92 foreach $name (@names) {
93 my($file) = "$dir/$name";
94 print STDERR " checking in $dir for $name\n" if $dl_debug;
95 $file = ($do_expand) ? dl_expandspec($file) : (-f $file && $file);
96 #$file = _check_file($file);
99 next arg; # no need to look any further
106 print STDERR " dl_findfile ignored non-existent directory: $_\n" unless -d $_;
108 print STDERR "dl_findfile found: @found\n";
110 return $found[0] unless wantarray;
114 # end of DynaLoader::dl_findfile