📄 mm_any.pm
字号:
return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;create_distdir : $(RM_RF) $(DISTVNAME) $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \ -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"distdir : create_distdir %s %s $(NOECHO) $(NOOP)MAKE_FRAG}=head3 dist_testDefines a target that produces the distribution in thescratchdirectory, and runs 'perl Makefile.PL; make ;make test' in thatsubdirectory.=cutsub dist_test { my($self) = shift; my $mpl_args = join " ", map qq["$_"], @ARGV; my $test = $self->cd('$(DISTVNAME)', '$(ABSPERLRUN) Makefile.PL '.$mpl_args, '$(MAKE) $(PASTHRU)', '$(MAKE) test $(PASTHRU)' ); return sprintf <<'MAKE_FRAG', $test;disttest : distdir %sMAKE_FRAG}=head3 dynamic (o)Defines the dynamic target.=cutsub dynamic {# --- Dynamic Loading Sections --- my($self) = shift; 'dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT) $(NOECHO) $(NOOP)';}=head3 makemakerdflt_target my $make_frag = $mm->makemakerdflt_targetReturns a make fragment with the makemakerdeflt_target specified.This target is the first target in the Makefile, is the default targetand simply points off to 'all' just in case any make variant getsconfused or something gets snuck in before the real 'all' target.=cutsub makemakerdflt_target { return <<'MAKE_FRAG';makemakerdflt : all $(NOECHO) $(NOOP)MAKE_FRAG}=head3 manifypods_target my $manifypods_target = $self->manifypods_target;Generates the manifypods target. This target generates man pages fromall POD files in MAN1PODS and MAN3PODS.=cutsub manifypods_target { my($self) = shift; my $man1pods = ''; my $man3pods = ''; my $dependencies = ''; # populate manXpods & dependencies: foreach my $name (keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}) { $dependencies .= " \\\n\t$name"; } my $manify = <<END;manifypods : pure_all $dependenciesEND my @man_cmds; foreach my $section (qw(1 3)) { my $pods = $self->{"MAN${section}PODS"}; push @man_cmds, $self->split_command(<<CMD, %$pods); \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)CMD } $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds; $manify .= join '', map { "$_\n" } @man_cmds; return $manify;}=head3 metafile_target my $target = $mm->metafile_target;Generate the metafile target.Writes the file META.yml YAML encoded meta-data about the module inthe distdir. The format follows Module::Build's as closely aspossible.=cutsub metafile_target { my $self = shift; return <<'MAKE_FRAG' if $self->{NO_META};metafile : $(NOECHO) $(NOOP)MAKE_FRAG my $prereq_pm = ''; foreach my $mod ( sort { lc $a cmp lc $b } keys %{$self->{PREREQ_PM}} ) { my $ver = $self->{PREREQ_PM}{$mod}; $prereq_pm .= sprintf "\n %-30s %s", "$mod:", $ver; } my $author_value = defined $self->{AUTHOR} ? "\n - $self->{AUTHOR}" : undef; # Use a list to preserve order. my @meta_to_mm = ( name => $self->{DISTNAME}, version => $self->{VERSION}, abstract => $self->{ABSTRACT}, license => $self->{LICENSE}, author => $author_value, generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION", distribution_type => $self->{PM} ? 'module' : 'script', ); my $meta = "--- #YAML:1.0\n"; while( @meta_to_mm ) { my($key, $val) = splice @meta_to_mm, 0, 2; $val = '~' unless defined $val; $meta .= sprintf "%-20s %s\n", "$key:", $val; }; $meta .= <<"YAML";requires: $prereq_pmmeta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3YAML $meta .= $self->{EXTRA_META} if $self->{EXTRA_META}; my @write_meta = $self->echo($meta, 'META_new.yml'); return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta);metafile : create_distdir $(NOECHO) $(ECHO) Generating META.yml %s -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.ymlMAKE_FRAG}=head3 distmeta_target my $make_frag = $mm->distmeta_target;Generates the distmeta target to add META.yml to the MANIFEST in thedistdir.=cutsub distmeta_target { my $self = shift; my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } or print "Could not add META.yml to MANIFEST: $${'@'}\n"CODE my $add_meta_to_distdir = $self->cd('$(DISTVNAME)', $add_meta); return sprintf <<'MAKE', $add_meta_to_distdir;distmeta : create_distdir metafile $(NOECHO) %sMAKE}=head3 realclean (o)Defines the realclean target.=cutsub realclean { my($self, %attribs) = @_; my @dirs = qw($(DISTVNAME)); my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD)); # Special exception for the perl core where INST_* is not in blib. # This cleans up the files built from the ext/ directory (all XS). if( $self->{PERL_CORE} ) { push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR)); push @files, values %{$self->{PM}}; } if( $self->has_link_code ){ push @files, qw($(OBJECT)); } if( $attribs{FILES} ) { if( ref $attribs{FILES} ) { push @dirs, @{ $attribs{FILES} }; } else { push @dirs, split /\s+/, $attribs{FILES}; } } # Occasionally files are repeated several times from different sources { my(%f) = map { ($_ => 1) } @files; @files = keys %f; } { my(%d) = map { ($_ => 1) } @dirs; @dirs = keys %d; } my $rm_cmd = join "\n\t", map { "$_" } $self->split_command('- $(RM_F)', @files); my $rmf_cmd = join "\n\t", map { "$_" } $self->split_command('- $(RM_RF)', @dirs); my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;# Delete temporary files (via clean) and also delete dist filesrealclean purge :: clean realclean_subdirs %s %sMAKE $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP}; return $m;}=head3 realclean_subdirs_target my $make_frag = $MM->realclean_subdirs_target;Returns the realclean_subdirs target. This is used by the realcleantarget to call realclean on any subdirectories which contain Makefiles.=cutsub realclean_subdirs_target { my $self = shift; return <<'NOOP_FRAG' unless @{$self->{DIR}};realclean_subdirs : $(NOECHO) $(NOOP)NOOP_FRAG my $rclean = "realclean_subdirs :\n"; foreach my $dir (@{$self->{DIR}}) { foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) { my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);chdir '%s'; system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';CODE $rclean .= sprintf <<'RCLEAN', $subrclean; - %sRCLEAN } } return $rclean;}=head3 signature_target my $target = $mm->signature_target;Generate the signature target.Writes the file SIGNATURE with "cpansign -s".=cutsub signature_target { my $self = shift; return <<'MAKE_FRAG';signature : cpansign -sMAKE_FRAG}=head3 distsignature_target my $make_frag = $mm->distsignature_target;Generates the distsignature target to add SIGNATURE to the MANIFEST in thedistdir.=cutsub distsignature_target { my $self = shift; my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"CODE my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s'); # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not # exist my $touch_sig = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE'); my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign ); return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_distdistsignature : create_distdir $(NOECHO) %s $(NOECHO) %s %sMAKE}=head3 special_targets my $make_frag = $mm->special_targetsReturns a make fragment containing any targets which have specialmeaning to make. For example, .SUFFIXES and .PHONY.=cutsub special_targets { my $make_frag = <<'MAKE_FRAG';.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT).PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdirMAKE_FRAG $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};.NO_CONFIG_REC: MakefileMAKE_FRAG return $make_frag;}=head2 Init methodsMethods which help initialize the MakeMaker object and macros.=head3 init_ABSTRACT $mm->init_ABSTRACT=cutsub init_ABSTRACT { my $self = shift; if( $self->{ABSTRACT_FROM} and $self->{ABSTRACT} ) { warn "Both ABSTRACT_FROM and ABSTRACT are set. ". "Ignoring ABSTRACT_FROM.\n"; return; } if ($self->{ABSTRACT_FROM}){ $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or carp "WARNING: Setting ABSTRACT via file ". "'$self->{ABSTRACT_FROM}' failed\n"; }}=head3 init_INST $mm->init_INST;Called by init_main. Sets up all INST_* variables except those relatedto XS code. Those are handled in init_xs.=cutsub init_INST { my($self) = shift; $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch"); $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin'); # INST_LIB typically pre-set if building an extension after # perl has been built and installed. Setting INST_LIB allows # you to build directly into, say $Config{privlibexp}. unless ($self->{INST_LIB}){ if ($self->{PERL_CORE}) { if (defined $Cross::platform) { $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->catdir($self->{PERL_LIB},"..","xlib", $Cross::platform); } else { $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB}; } } else { $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib"); } } my @parentdir = split(/::/, $self->{PARENT_NAME}); $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir); $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir); $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto', '$(FULLEXT)'); $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto', '$(FULLEXT)'); $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script'); $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1'); $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3'); return 1;}=head3 init_INSTALL $mm->init_INSTALL;Called by init_main. Sets up all INSTALL_* variables (exceptINSTALLDIRS) and *PREFIX.=cutsub init_INSTALL { my($self) = shift; if( $self->{ARGS}{INSTALL_BASE} and $self->{ARGS}{PREFIX} ) { die "Only one of PREFIX or INSTALL_BASE can be given. Not both.\n"; } if( $self->{ARGS}{INSTALL_BASE} ) { $self->init_INSTALL_from_INSTALL_BASE; } else { $self->init_INSTALL_from_PREFIX; }}=head3 init_INSTALL_from_PREFIX $mm->init_INSTALL_from_PREFIX;=cutsub init_INSTALL_from_PREFIX { my $self = shift; $self->init_lib2arch; # There are often no Config.pm defaults for these new man variables so # we fall back to the old behavior which is to use installman*dir foreach my $num (1, 3) { my $k = 'installsiteman'.$num.'dir'; $self->{uc $k} ||= uc "\$(installman${num}dir)" unless $Config{$k}; } foreach my $num (1, 3) { my $k = 'installvendorman'.$num.'dir'; unless( $Config{$k} ) { $self->{uc $k} ||= $Config{usevendorprefix} ? uc "\$(installman${num}dir)" : ''; } } $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)' unless $Config{installsitebin}; $self->{INSTALLSITESCRIPT} ||= '$(INSTALLSCRIPT)' unless $Config{installsitescript}; unless( $Config{installvendorbin} ) { $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix} ? $Config{installbin} : ''; } unless( $Config{installvendorscript} ) { $self->{INSTALLVENDORSCRIPT} ||= $Config{usevendorprefix} ? $Config{installscript} : ''; } my $iprefix = $Config{installprefixexp} || $Config{installprefix} || $Config{prefixexp} || $Config{prefix} || ''; my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : ''; my $sprefix = $Config{siteprefixexp} || ''; # 5.005_03 doesn't have a siteprefix. $sprefix = $iprefix unless $sprefix; $self->{PREFIX} ||= ''; if( $self->{PREFIX} ) { @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} = ('$(PREFIX)') x 3; } else { $self->{PERLPREFIX} ||= $iprefix; $self->{SITEPREFIX} ||= $sprefix; $self->{VENDORPREFIX} ||= $vprefix; # Lots of MM extension authors like to use $(PREFIX) so we # put something sensible in there no matter what. $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)'; } my $arch = $Config{archname}; my $version = $Config{version}; # default style my $libstyle = $Config{installstyle} || 'lib/perl5'; my $manstyle = ''; if( $self->{LIBSTYLE} ) { $libstyle = $self->{LIBSTYLE}; $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : ''; } # Some systems, like VOS, set installman*dir to '' if they can't # read man pages. for my $num (1, 3) { $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none' unless $Config{'installman'.$num.'dir'}; } my %bin_layouts = ( bin => { s => $iprefix, t => 'perl', d => 'bin' }, vendorbin => { s => $vprefix, t => 'vendor',
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -