⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mm_unix.pm

📁 UNIX下perl实现代码
💻 PM
📖 第 1 页 / 共 5 页
字号:
sub guess_name {    my($self) = @_;    use Cwd 'cwd';    my $name = basename(cwd());    $name =~ s|[\-_][\d\.\-]+\z||;  # this is new with MM 5.00, we                                    # strip minus or underline                                    # followed by a float or some such    print "Warning: Guessing NAME [$name] from current directory name.\n";    $name;}=item has_link_codeReturns true if C, XS, MYEXTLIB or similar objects exist within thisobject that need a compiler. Does not descend into subdirectories asneeds_linking() does.=cutsub has_link_code {    my($self) = shift;    return $self->{HAS_LINK_CODE} if defined $self->{HAS_LINK_CODE};    if ($self->{OBJECT} or @{$self->{C} || []} or $self->{MYEXTLIB}){	$self->{HAS_LINK_CODE} = 1;	return 1;    }    return $self->{HAS_LINK_CODE} = 0;}=item htmlifypods (o)Defines targets and routines to translate the pods into HTML manpagesand put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIRdirectories.=cutsub htmlifypods {    my($self, %attribs) = @_;    return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless	%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}};    my($dist);    my($pod2html_exe);    if (defined $self->{PERL_SRC}) {	$pod2html_exe = $self->catfile($self->{PERL_SRC},'pod','pod2html');    } else {	$pod2html_exe = $self->catfile($Config{scriptdirexp},'pod2html');    }    unless ($pod2html_exe = $self->perl_script($pod2html_exe)) {	# No pod2html but some HTMLxxxPODS to be installed	print <<END;Warning: I could not locate your pod2html program. Please make sure,         your pod2html program is in your PATH before you execute 'make'END        $pod2html_exe = "-S pod2html";    }    my(@m);    push @m,qq[POD2HTML_EXE = $pod2html_exe\n],qq[POD2HTML = \$(PERL) -we 'use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){' \\\n],q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "], $self->{MAKEFILE}, q[";' \\-e 'print "Htmlifying $$m{$$_}\n";' \\-e '$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;' \\-e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\-e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'];    push @m, "\nhtmlifypods : pure_all ";    push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}};    push(@m,"\n");    if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) {	push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";	push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}};    }    join('', @m);}=item init_dirscanInitializes DIR, XS, PM, C, O_FILES, H, PL_FILES, HTML*PODS, MAN*PODS, EXE_FILES.=cutsub init_dirscan {	# --- File and Directory Lists (.xs .pm .pod etc)    my($self) = @_;    my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);    local(%pm); #the sub in find() has to see this hash    @ignore{qw(Makefile.PL test.pl)} = (1,1);    $ignore{'makefile.pl'} = 1 if $Is_VMS;    foreach $name ($self->lsdir($self->curdir)){	next if $name =~ /\#/;	next if $name eq $self->curdir or $name eq $self->updir or $ignore{$name};	next unless $self->libscan($name);	if (-d $name){	    next if -l $name; # We do not support symlinks at all	    $dir{$name} = $name if (-f $self->catfile($name,"Makefile.PL"));	} elsif ($name =~ /\.xs\z/){	    my($c); ($c = $name) =~ s/\.xs\z/.c/;	    $xs{$name} = $c;	    $c{$c} = 1;	} elsif ($name =~ /\.c(pp|xx|c)?\z/i){  # .c .C .cpp .cxx .cc	    $c{$name} = 1		unless $name =~ m/perlmain\.c/; # See MAP_TARGET	} elsif ($name =~ /\.h\z/i){	    $h{$name} = 1;	} elsif ($name =~ /\.PL\z/) {	    ($pl_files{$name} = $name) =~ s/\.PL\z// ;	} elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {	    # case-insensitive filesystem, one dot per name, so foo.h.PL	    # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos	    local($/); open(PL,$name); my $txt = <PL>; close PL;	    if ($txt =~ /Extracting \S+ \(with variable substitutions/) {		($pl_files{$name} = $name) =~ s/[._]pl\z//i ;	    }	    else { $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name); }	} elsif ($name =~ /\.(p[ml]|pod)\z/){	    $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);	}    }    # Some larger extensions often wish to install a number of *.pm/pl    # files into the library in various locations.    # The attribute PMLIBDIRS holds an array reference which lists    # subdirectories which we should search for library files to    # install. PMLIBDIRS defaults to [ 'lib', $self->{BASEEXT} ].  We    # recursively search through the named directories (skipping any    # which don't exist or contain Makefile.PL files).    # For each *.pm or *.pl file found $self->libscan() is called with    # the default installation path in $_[1]. The return value of    # libscan defines the actual installation location.  The default    # libscan function simply returns the path.  The file is skipped    # if libscan returns false.    # The default installation location passed to libscan in $_[1] is:    #    #  ./*.pm		=> $(INST_LIBDIR)/*.pm    #  ./xyz/...	=> $(INST_LIBDIR)/xyz/...    #  ./lib/...	=> $(INST_LIB)/...    #    # In this way the 'lib' directory is seen as the root of the actual    # perl library whereas the others are relative to INST_LIBDIR    # (which includes PARENT_NAME). This is a subtle distinction but one    # that's important for nested modules.    $self->{PMLIBDIRS} = ['lib', $self->{BASEEXT}]	unless $self->{PMLIBDIRS};    #only existing directories that aren't in $dir are allowed    # Avoid $_ wherever possible:    # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};    my (@pmlibdirs) = @{$self->{PMLIBDIRS}};    my ($pmlibdir);    @{$self->{PMLIBDIRS}} = ();    foreach $pmlibdir (@pmlibdirs) {	-d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;    }    if (@{$self->{PMLIBDIRS}}){	print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"	    if ($Verbose >= 2);	require File::Find;	File::Find::find(sub {	    if (-d $_){		if ($_ eq "CVS" || $_ eq "RCS"){		    $File::Find::prune = 1;		}		return;	    }	    return if /\#/;	    my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');	    my($striplibpath,$striplibname);	    $prefix =  '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);	    ($striplibname,$striplibpath) = fileparse($striplibpath);	    my($inst) = $self->catfile($prefix,$striplibpath,$striplibname);	    local($_) = $inst; # for backwards compatibility	    $inst = $self->libscan($inst);	    print "libscan($path) => '$inst'\n" if ($Verbose >= 2);	    return unless $inst;	    $pm{$path} = $inst;	}, @{$self->{PMLIBDIRS}});    }    $self->{DIR} = [sort keys %dir] unless $self->{DIR};    $self->{XS}  = \%xs             unless $self->{XS};    $self->{PM}  = \%pm             unless $self->{PM};    $self->{C}   = [sort keys %c]   unless $self->{C};    my(@o_files) = @{$self->{C}};    $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files] ;    $self->{H}   = [sort keys %h]   unless $self->{H};    $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};    # Set up names of manual pages to generate from pods    my %pods;    foreach my $man (qw(MAN1 MAN3 HTMLLIB HTMLSCRIPT)) {	unless ($self->{"${man}PODS"}) {	    $self->{"${man}PODS"} = {};	    $pods{$man} = 1 unless $self->{"INST_${man}DIR"} =~ /^(none|\s*)$/;	}    }    if ($pods{MAN1} || $pods{HTMLSCRIPT}) {	if ( exists $self->{EXE_FILES} ) {	    foreach $name (@{$self->{EXE_FILES}}) {		local *FH;		my($ispod)=0;		if (open(FH,"<$name")) {		    while (<FH>) {			if (/^=head1\s+\w+/) {			    $ispod=1;			    last;			}		    }		    close FH;		} else {		    # If it doesn't exist yet, we assume, it has pods in it		    $ispod = 1;		}		next unless $ispod;		if ($pods{HTMLSCRIPT}) {		    $self->{HTMLSCRIPTPODS}->{$name} =		      $self->catfile("\$(INST_HTMLSCRIPTDIR)", basename($name).".\$(HTMLEXT)");		}		if ($pods{MAN1}) {		    $self->{MAN1PODS}->{$name} =		      $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");		}	    }	}    }    if ($pods{MAN3} || $pods{HTMLLIB}) {	my %manifypods = (); # we collect the keys first, i.e. the files			     # we have to convert to pod	foreach $name (keys %{$self->{PM}}) {	    if ($name =~ /\.pod\z/ ) {		$manifypods{$name} = $self->{PM}{$name};	    } elsif ($name =~ /\.p[ml]\z/ ) {		local *FH;		my($ispod)=0;		if (open(FH,"<$name")) {		    while (<FH>) {			if (/^=head1\s+\w+/) {			    $ispod=1;			    last;			}		    }		    close FH;		} else {		    $ispod = 1;		}		if( $ispod ) {		    $manifypods{$name} = $self->{PM}{$name};		}	    }	}	# Remove "Configure.pm" and similar, if it's not the only pod listed	# To force inclusion, just name it "Configure.pod", or override MAN3PODS	foreach $name (keys %manifypods) {	    if ($name =~ /(config|setup).*\.pm/is) {		delete $manifypods{$name};		next;	    }	    my($manpagename) = $name;	    $manpagename =~ s/\.p(od|m|l)\z//;	    if ($pods{HTMLLIB}) {		$self->{HTMLLIBPODS}->{$name} =		  $self->catfile("\$(INST_HTMLLIBDIR)", "$manpagename.\$(HTMLEXT)");	    }	    unless ($manpagename =~ s!^\W*lib\W+!!s) { # everything below lib is ok		$manpagename = $self->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename);	    }	    if ($pods{MAN3}) {		$manpagename = $self->replace_manpage_separator($manpagename);		$self->{MAN3PODS}->{$name} =		  $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");	    }	}    }}=item init_mainInitializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC,PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*,PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, EXE_EXT, MAP_TARGET,LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM.=cutsub init_main {    my($self) = @_;    # --- Initialize Module Name and Paths    # NAME    = Foo::Bar::Oracle    # FULLEXT = Foo/Bar/Oracle    # BASEEXT = Oracle    # ROOTEXT = Directory part of FULLEXT with leading /. !!! Deprecated from MM 5.32 !!!    # PARENT_NAME = Foo::Bar### Only UNIX:###    ($self->{FULLEXT} =###     $self->{NAME}) =~ s!::!/!g ; #eg. BSD/Foo/Socket    $self->{FULLEXT} = $self->catdir(split /::/, $self->{NAME});    # Copied from DynaLoader:    my(@modparts) = split(/::/,$self->{NAME});    my($modfname) = $modparts[-1];    # Some systems have restrictions on files names for DLL's etc.    # mod2fname returns appropriate file base name (typically truncated)    # It may also edit @modparts if required.    if (defined &DynaLoader::mod2fname) {        $modfname = &DynaLoader::mod2fname(\@modparts);    }    ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)\z! ;    if (defined &DynaLoader::mod2fname) {	# As of 5.001m, dl_os2 appends '_'	$self->{DLBASE} = $modfname;    } else {	$self->{DLBASE} = '$(BASEEXT)';    }    ### ROOTEXT deprecated from MM 5.32###    ($self->{ROOTEXT} =###     $self->{FULLEXT}) =~ s#/?\Q$self->{BASEEXT}\E$## ;      #eg. /BSD/Foo###    $self->{ROOTEXT} = ($Is_VMS ? '' : '/') . $self->{ROOTEXT} if $self->{ROOTEXT};    # --- Initialize PERL_LIB, INST_LIB, PERL_SRC    # *Real* information: where did we get these two from? ...    my $inc_config_dir = dirname($INC{'Config.pm'});    my $inc_carp_dir   = dirname($INC{'Carp.pm'});    unless ($self->{PERL_SRC}){	my($dir);	foreach $dir ($self->updir(),$self->catdir($self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir()),$self->catdir($self->updir(),$self->updir(),$self->updir(),$self->updir())){	    if (		-f $self->catfile($dir,"config.sh")		&&		-f $self->catfile($dir,"perl.h")		&&		-f $self->catfile($dir,"lib","Exporter.pm")	       ) {		$self->{PERL_SRC}=$dir ;		last;	    }	}    }    if ($self->{PERL_SRC}){	$self->{PERL_LIB}     ||= $self->catdir("$self->{PERL_SRC}","lib");	$self->{PERL_ARCHLIB} = $self->{PERL_LIB};	$self->{PERL_INC}     = ($Is_Win32) ? $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};	# catch a situation that has occurred a few times in the past:	unless (		-s $self->catfile($self->{PERL_SRC},'cflags')		or		$Is_VMS		&&		-s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')		or		$Is_Mac		or		$Is_Win32	       ){	    warn qq{You cannot build extensions below the perl source tree after executinga 'make clean' in the perl source tree.To rebuild extensions distributed with the perl source you shouldsimply Configure (to include those extensions) and then build perl asnormal. After installing perl the source tree can be deleted. It isnot needed for building extensions by running 'perl Makefile.PL'usually without extra arguments.It is recommended that you unpack and build additional extensions awayfrom the perl source tree.};	}    } else {	# we should also consider $ENV{PERL5LIB} here        my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};	$self->{PERL_LIB}     ||= $Config::Config{privlibexp};	$self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};	$self->{PERL_INC}     = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now	my $perl_h;	if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))	    and not $old){	    # Maybe somebody tries to build an extension with an	    # uninstalled Perl outside of Perl build tree	    my $found;	    for my $dir (@INC) {	      $found = $dir, last if -e $self->catdir($dir, "Config.pm");	    }	    if ($found) {	      my $inc = dirname $found;	      if (-e $self->catdir($inc, "perl.h")) {		$self->{PERL_LIB}	   = $found;		$self->{PERL_ARCHLIB}	   = $found;		$self->{PERL_INC}	   = $inc;		$self->{UNINSTALLED_PERL}  = 1;		print STDOUT <<EOP;... Detected uninstalled Perl.  Trying to continue.EOP	      }	    }	}		unless (-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))){	    die qq{Error: Unable to locate installed Perl libraries or Perl source code.It is recommended that you install perl in a standard location beforebuilding extensions. Some precompiled versions of perl do not containthese header files, so you cannot build extensions. In such a case,please build and install your perl from a fresh perl distribution. Itusually solves this kind of problem.\(You get this message, because MakeMaker could not find "$perl_h"\)};	}#	 print STDOUT "Using header files found in $self->{PERL_INC}\n"#	     if $Verbose && $self->needs_linking();    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -