📄 kid.pm
字号:
# see if entry is a flag if (/^:\w+$/) { $search = 0 if lc eq ':nosearch'; $search = 1 if lc eq ':search'; warn "Ignoring unknown flag '$thislib'\n" if $verbose and !/^:(no)?(search|default)$/i; next; } # if searching is disabled, do compiler-specific translations unless ($search) { s/^-l(.+)$/$1.lib/ unless $GC; s/^-L/-libpath:/ if $VC; push(@extralibs, $_); $found++; next; } # handle possible linker path arguments if (s/^-L// and not -d) { warn "$thislib ignored, directory does not exist\n" if $verbose; next; } elsif (-d) { unless (File::Spec->file_name_is_absolute($_)) { warn "Warning: '$thislib' changed to '-L$pwd/$_'\n"; $_ = $self->catdir($pwd,$_); } push(@searchpath, $_); next; } # handle possible library arguments if (s/^-l// and $GC and !/^lib/i) { $_ = "lib$_"; } $_ .= $libext if !/\Q$libext\E$/i; my $secondpass = 0; LOOKAGAIN: # look for the file itself if (-f) { warn "'$thislib' found as '$_'\n" if $verbose; $found++; push(@extralibs, $_); next; } my $found_lib = 0; foreach $thispth (@searchpath, @libpath){ unless (-f ($fullname="$thispth\\$_")) { warn "'$thislib' not found as '$fullname'\n" if $verbose; next; } warn "'$thislib' found as '$fullname'\n" if $verbose; $found++; $found_lib++; push(@extralibs, $fullname); push @libs, $fullname unless $libs_seen{$fullname}++; last; } # do another pass with (or without) leading 'lib' if they used -l if (!$found_lib and $thislib =~ /^-l/ and !$secondpass++) { if ($GC) { goto LOOKAGAIN if s/^lib//i; } elsif (!/^lib/i) { $_ = "lib$_"; goto LOOKAGAIN; } } # give up warn "Note (probably harmless): " ."No library found for $thislib\n" unless $found_lib>0; } return ('','','','', ($give_libs ? \@libs : ())) unless $found; # make sure paths with spaces are properly quoted @extralibs = map { (/\s/ && !/^".*"$/) ? qq["$_"] : $_ } @extralibs; @libs = map { (/\s/ && !/^".*"$/) ? qq["$_"] : $_ } @libs; $lib = join(' ',@extralibs); # normalize back to backward slashes (to help braindead tools) # XXX this may break equally braindead GNU tools that don't understand # backslashes, either. Seems like one can't win here. Cursed be CP/M. $lib =~ s,/,\\,g; warn "Result: $lib\n" if $verbose; wantarray ? ($lib, '', $lib, '', ($give_libs ? \@libs : ())) : $lib;}sub _vms_ext { my($self, $potential_libs,$verbose,$give_libs) = @_; $verbose ||= 0; my(@crtls,$crtlstr); @crtls = ( ($Config{'ldflags'} =~ m-/Debug-i ? $Config{'dbgprefix'} : '') . 'PerlShr/Share' ); push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'}); push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'}); # In general, we pass through the basic libraries from %Config unchanged. # The one exception is that if we're building in the Perl source tree, and # a library spec could be resolved via a logical name, we go to some trouble # to insure that the copy in the local tree is used, rather than one to # which a system-wide logical may point. if ($self->{PERL_SRC}) { my($lib,$locspec,$type); foreach $lib (@crtls) { if (($locspec,$type) = $lib =~ m{^([\w\$-]+)(/\w+)?} and $locspec =~ /perl/i) { if (lc $type eq '/share') { $locspec .= $Config{'exe_ext'}; } elsif (lc $type eq '/library') { $locspec .= $Config{'lib_ext'}; } else { $locspec .= $Config{'obj_ext'}; } $locspec = $self->catfile($self->{PERL_SRC},$locspec); $lib = "$locspec$type" if -e $locspec; } } } $crtlstr = @crtls ? join(' ',@crtls) : ''; unless ($potential_libs) { warn "Result:\n\tEXTRALIBS: \n\tLDLOADLIBS: $crtlstr\n" if $verbose; return ('', '', $crtlstr, '', ($give_libs ? [] : ())); } my(@dirs,@libs,$dir,$lib,%found,@fndlibs,$ldlib); my $cwd = cwd(); my($so,$lib_ext,$obj_ext) = @Config{'so','lib_ext','obj_ext'}; # List of common Unix library names and their VMS equivalents # (VMS equivalent of '' indicates that the library is automatically # searched by the linker, and should be skipped here.) my(@flibs, %libs_seen); my %libmap = ( 'm' => '', 'f77' => '', 'F77' => '', 'V77' => '', 'c' => '', 'malloc' => '', 'crypt' => '', 'resolv' => '', 'c_s' => '', 'socket' => '', 'X11' => 'DECW$XLIBSHR', 'Xt' => 'DECW$XTSHR', 'Xm' => 'DECW$XMLIBSHR', 'Xmu' => 'DECW$XMULIBSHR'); if ($Config{'vms_cc_type'} ne 'decc') { $libmap{'curses'} = 'VAXCCURSE'; } warn "Potential libraries are '$potential_libs'\n" if $verbose; # First, sort out directories and library names in the input foreach $lib (split ' ',$potential_libs) { push(@dirs,$1), next if $lib =~ /^-L(.*)/; push(@dirs,$lib), next if $lib =~ /[:>\]]$/; push(@dirs,$lib), next if -d $lib; push(@libs,$1), next if $lib =~ /^-l(.*)/; push(@libs,$lib); } push(@dirs,split(' ',$Config{'libpth'})); # Now make sure we've got VMS-syntax absolute directory specs # (We don't, however, check whether someone's hidden a relative # path in a logical name.) foreach $dir (@dirs) { unless (-d $dir) { warn "Skipping nonexistent Directory $dir\n" if $verbose > 1; $dir = ''; next; } warn "Resolving directory $dir\n" if $verbose; if (File::Spec->file_name_is_absolute($dir)) { $dir = $self->fixpath($dir,1); } else { $dir = $self->catdir($cwd,$dir); } } @dirs = grep { length($_) } @dirs; unshift(@dirs,''); # Check each $lib without additions first LIB: foreach $lib (@libs) { if (exists $libmap{$lib}) { next unless length $libmap{$lib}; $lib = $libmap{$lib}; } my(@variants,$variant,$cand); my($ctype) = ''; # If we don't have a file type, consider it a possibly abbreviated name and # check for common variants. We try these first to grab libraries before # a like-named executable image (e.g. -lperl resolves to perlshr.exe # before perl.exe). if ($lib !~ /\.[^:>\]]*$/) { push(@variants,"${lib}shr","${lib}rtl","${lib}lib"); push(@variants,"lib$lib") if $lib !~ /[:>\]]/; } push(@variants,$lib); warn "Looking for $lib\n" if $verbose; foreach $variant (@variants) { my($fullname, $name); foreach $dir (@dirs) { my($type); $name = "$dir$variant"; warn "\tChecking $name\n" if $verbose > 2; $fullname = VMS::Filespec::rmsexpand($name); if (defined $fullname and -f $fullname) { # It's got its own suffix, so we'll have to figure out the type if ($fullname =~ /(?:$so|exe)$/i) { $type = 'SHR'; } elsif ($fullname =~ /(?:$lib_ext|olb)$/i) { $type = 'OLB'; } elsif ($fullname =~ /(?:$obj_ext|obj)$/i) { warn "Note (probably harmless): " ."Plain object file $fullname found in library list\n"; $type = 'OBJ'; } else { warn "Note (probably harmless): " ."Unknown library type for $fullname; assuming shared\n"; $type = 'SHR'; } } elsif (-f ($fullname = VMS::Filespec::rmsexpand($name,$so)) or -f ($fullname = VMS::Filespec::rmsexpand($name,'.exe'))) { $type = 'SHR'; $name = $fullname unless $fullname =~ /exe;?\d*$/i; } elsif (not length($ctype) and # If we've got a lib already, # don't bother ( -f ($fullname = VMS::Filespec::rmsexpand($name,$lib_ext)) or -f ($fullname = VMS::Filespec::rmsexpand($name,'.olb')))) { $type = 'OLB'; $name = $fullname unless $fullname =~ /olb;?\d*$/i; } elsif (not length($ctype) and # If we've got a lib already, # don't bother ( -f ($fullname = VMS::Filespec::rmsexpand($name,$obj_ext)) or -f ($fullname = VMS::Filespec::rmsexpand($name,'.obj')))) { warn "Note (probably harmless): " ."Plain object file $fullname found in library list\n"; $type = 'OBJ'; $name = $fullname unless $fullname =~ /obj;?\d*$/i; } if (defined $type) { $ctype = $type; $cand = $name; last if $ctype eq 'SHR'; } } if ($ctype) { # This has to precede any other CRTLs, so just make it first if ($cand eq 'VAXCCURSE') { unshift @{$found{$ctype}}, $cand; } else { push @{$found{$ctype}}, $cand; } warn "\tFound as $cand (really $fullname), type $ctype\n" if $verbose > 1; push @flibs, $name unless $libs_seen{$fullname}++; next LIB; } } warn "Note (probably harmless): " ."No library found for $lib\n"; } push @fndlibs, @{$found{OBJ}} if exists $found{OBJ}; push @fndlibs, map { "$_/Library" } @{$found{OLB}} if exists $found{OLB}; push @fndlibs, map { "$_/Share" } @{$found{SHR}} if exists $found{SHR}; $lib = join(' ',@fndlibs); $ldlib = $crtlstr ? "$lib $crtlstr" : $lib; warn "Result:\n\tEXTRALIBS: $lib\n\tLDLOADLIBS: $ldlib\n" if $verbose; wantarray ? ($lib, '', $ldlib, '', ($give_libs ? \@flibs : ())) : $lib;}1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -