📄 mm_any.pm
字号:
d => 'bin' }, sitebin => { s => $sprefix, t => 'site', d => 'bin' }, script => { s => $iprefix, t => 'perl', d => 'bin' }, vendorscript=> { s => $vprefix, t => 'vendor', d => 'bin' }, sitescript => { s => $sprefix, t => 'site', d => 'bin' }, ); my %man_layouts = ( man1dir => { s => $iprefix, t => 'perl', d => 'man/man1', style => $manstyle, }, siteman1dir => { s => $sprefix, t => 'site', d => 'man/man1', style => $manstyle, }, vendorman1dir => { s => $vprefix, t => 'vendor', d => 'man/man1', style => $manstyle, }, man3dir => { s => $iprefix, t => 'perl', d => 'man/man3', style => $manstyle, }, siteman3dir => { s => $sprefix, t => 'site', d => 'man/man3', style => $manstyle, }, vendorman3dir => { s => $vprefix, t => 'vendor', d => 'man/man3', style => $manstyle, }, ); my %lib_layouts = ( privlib => { s => $iprefix, t => 'perl', d => '', style => $libstyle, }, vendorlib => { s => $vprefix, t => 'vendor', d => '', style => $libstyle, }, sitelib => { s => $sprefix, t => 'site', d => 'site_perl', style => $libstyle, }, archlib => { s => $iprefix, t => 'perl', d => "$version/$arch", style => $libstyle }, vendorarch => { s => $vprefix, t => 'vendor', d => "$version/$arch", style => $libstyle }, sitearch => { s => $sprefix, t => 'site', d => "site_perl/$version/$arch", style => $libstyle }, ); # Special case for LIB. if( $self->{LIB} ) { foreach my $var (keys %lib_layouts) { my $Installvar = uc "install$var"; if( $var =~ /arch/ ) { $self->{$Installvar} ||= $self->catdir($self->{LIB}, $Config{archname}); } else { $self->{$Installvar} ||= $self->{LIB}; } } } my %type2prefix = ( perl => 'PERLPREFIX', site => 'SITEPREFIX', vendor => 'VENDORPREFIX' ); my %layouts = (%bin_layouts, %man_layouts, %lib_layouts); while( my($var, $layout) = each(%layouts) ) { my($s, $t, $d, $style) = @{$layout}{qw(s t d style)}; my $r = '$('.$type2prefix{$t}.')'; print STDERR "Prefixing $var\n" if $Verbose >= 2; my $installvar = "install$var"; my $Installvar = uc $installvar; next if $self->{$Installvar}; $d = "$style/$d" if $style; $self->prefixify($installvar, $s, $r, $d); print STDERR " $Installvar == $self->{$Installvar}\n" if $Verbose >= 2; } # Generate these if they weren't figured out. $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH}; $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB}; return 1;}=head3 init_from_INSTALL_BASE $mm->init_from_INSTALL_BASE=cutmy %map = ( lib => [qw(lib perl5)], arch => [('lib', 'perl5', $Config{archname})], bin => [qw(bin)], man1dir => [qw(man man1)], man3dir => [qw(man man3)] );$map{script} = $map{bin};sub init_INSTALL_from_INSTALL_BASE { my $self = shift; @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} = '$(INSTALL_BASE)'; my %install; foreach my $thing (keys %map) { foreach my $dir (('', 'SITE', 'VENDOR')) { my $uc_thing = uc $thing; my $key = "INSTALL".$dir.$uc_thing; $install{$key} ||= $self->catdir('$(INSTALL_BASE)', @{$map{$thing}}); } } # Adjust for variable quirks. $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH}; $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB}; foreach my $key (keys %install) { $self->{$key} ||= $install{$key}; } return 1;}=head3 init_VERSION I<Abstract> $mm->init_VERSIONInitialize macros representing versions of MakeMaker and other toolsMAKEMAKER: path to the MakeMaker module.MM_VERSION: ExtUtils::MakeMaker VersionMM_REVISION: ExtUtils::MakeMaker version control revision (for backwards compat)VERSION: version of your moduleVERSION_MACRO: which macro represents the version (usually 'VERSION')VERSION_SYM: like version but safe for use as an RCS revision numberDEFINE_VERSION: -D line to set the module version when compilingXS_VERSION: version in your .xs file. Defaults to $(VERSION)XS_VERSION_MACRO: which macro represents the XS version.XS_DEFINE_VERSION: -D line to set the xs version when compiling.Called by init_main.=cutsub init_VERSION { my($self) = shift; $self->{MAKEMAKER} = $ExtUtils::MakeMaker::Filename; $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION; $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision; $self->{VERSION_FROM} ||= ''; if ($self->{VERSION_FROM}){ $self->{VERSION} = $self->parse_version($self->{VERSION_FROM}); if( $self->{VERSION} eq 'undef' ) { carp("WARNING: Setting VERSION via file ". "'$self->{VERSION_FROM}' failed\n"); } } # strip blanks if (defined $self->{VERSION}) { $self->{VERSION} =~ s/^\s+//; $self->{VERSION} =~ s/\s+$//; } else { $self->{VERSION} = ''; } $self->{VERSION_MACRO} = 'VERSION'; ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g; $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"'; # Graham Barr and Paul Marquess had some ideas how to ensure # version compatibility between the *.pm file and the # corresponding *.xs file. The bottomline was, that we need an # XS_VERSION macro that defaults to VERSION: $self->{XS_VERSION} ||= $self->{VERSION}; $self->{XS_VERSION_MACRO} = 'XS_VERSION'; $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';}=head3 init_others I<Abstract> $MM->init_others();Initializes the macro definitions used by tools_other() and places themin the $MM object.If there is no description, its the same as the parameter toWriteMakefile() documented in ExtUtils::MakeMaker.Defines at least these macros. Macro Description NOOP Do nothing NOECHO Tell make not to display the command itself MAKEFILE FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE File used by MAKE_APERL SHELL Program used to run shell commands ECHO Print text adding a newline on the end RM_F Remove a file RM_RF Remove a directory TOUCH Update a file's timestamp TEST_F Test for a file's existence CP Copy a file MV Move a file CHMOD Change permissions on a file UMASK_NULL Nullify umask DEV_NULL Suppress all command output=head3 init_DIRFILESEP I<Abstract> $MM->init_DIRFILESEP; my $dirfilesep = $MM->{DIRFILESEP};Initializes the DIRFILESEP macro which is the seperator between thedirectory and filename in a filepath. ie. / on Unix, \ on Win32 andnothing on VMS.For example: # instead of $(INST_ARCHAUTODIR)/extralibs.ld $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ldSomething of a hack but it prevents a lot of code duplication betweenMM_* variants.Do not use this as a seperator between directories. Some operatingsystems use different seperators between subdirectories as betweendirectories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).=head3 init_linker I<Abstract> $mm->init_linker;Initialize macros which have to do with linking.PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamicextensions.PERL_ARCHIVE_AFTER: path to a library which should be put on thelinker command line I<after> the external libraries to be linked todynamic extensions. This may be needed if the linker is one-pass, andPerl includes some overrides for C RTL functions, such as malloc().EXPORT_LIST: name of a file that is passed to linker to define symbolsto be exported.Some OSes do not need these in which case leave it blank.=head3 init_platform $mm->init_platformInitialize any macros which are for platform specific use only.A typical one is the version number of your OS specific mocule.(ie. MM_Unix_VERSION or MM_VMS_VERSION).=cutsub init_platform { return '';}=head3 init_MAKE $mm->init_MAKEInitialize MAKE from either a MAKE environment variable or $Config{make}.=cutsub init_MAKE { my $self = shift; $self->{MAKE} ||= $ENV{MAKE} || $Config{make};}=head2 ToolsA grab bag of methods to generate specific macros and commands.=head3 manifypodsDefines targets and routines to translate the pods into manpages andput them into the INST_* directories.=cutsub manifypods { my $self = shift; my $POD2MAN_macro = $self->POD2MAN_macro(); my $manifypods_target = $self->manifypods_target(); return <<END_OF_TARGET;$POD2MAN_macro$manifypods_targetEND_OF_TARGET}=head3 POD2MAN_macro my $pod2man_macro = $self->POD2MAN_macroReturns a definition for the POD2MAN macro. This is a programwhich emulates the pod2man utility. You can add more switches to thecommand by simply appending them on the macro.Typical usage: $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...=cutsub POD2MAN_macro { my $self = shift;# Need the trailing '--' so perl stops gobbling arguments and - happens# to be an alternative end of line seperator on VMS so we quote it return <<'END_OF_DEF';POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"POD2MAN = $(POD2MAN_EXE)END_OF_DEF}=head3 test_via_harness my $command = $mm->test_via_harness($perl, $tests);Returns a $command line which runs the given set of $tests withTest::Harness and the given $perl.Used on the t/*.t files.=cutsub test_via_harness { my($self, $perl, $tests) = @_; return qq{\t$perl "-MExtUtils::Command::MM" }. qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};}=head3 test_via_script my $command = $mm->test_via_script($perl, $script);Returns a $command line which just runs a single test withoutTest::Harness. No checks are done on the results, they're justprinted.Used for test.pl, since they don't always follow Test::Harnessformatting.=cutsub test_via_script { my($self, $perl, $script) = @_; return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};}=head3 tool_autosplitDefines a simple perl call that runs autosplit. May be deprecated bypm_to_blib soon.=cutsub tool_autosplit { my($self, %attribs) = @_; my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};' : ''; my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)PERL_CODE return sprintf <<'MAKE_FRAG', $asplit;# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitIntoAUTOSPLITFILE = %sMAKE_FRAG}=head2 File::Spec wrappersExtUtils::MM_Any is a subclass of File::Spec. The methods noted hereoverride File::Spec.=head3 catfileFile::Spec <= 0.83 has a bug where the file part of catfile is notcanonicalized. This override fixes that bug.=cutsub catfile { my $self = shift; return $self->canonpath($self->SUPER::catfile(@_));}=head2 MiscMethods I can't really figure out where they should go yet.=head3 find_tests my $test = $mm->find_tests;Returns a string suitable for feeding to the shell to return alltests in t/*.t.=cutsub find_tests { my($self) = shift; return -d 't' ? 't/*.t' : '';}=head3 extra_clean_files my @files_to_clean = $MM->extra_clean_files;Returns a list of OS specific files to be removed in the clean target inaddition to the usual set.=cut# An empty method here tickled a perl 5.8.1 bug and would return its object.sub extra_clean_files { return;}=head3 installvars my @installvars = $mm->installvars;A list of all the INSTALL* variables without the INSTALL prefix. Usefulfor iteration or building related variable sets.=cutsub installvars { return qw(PRIVLIB SITELIB VENDORLIB ARCHLIB SITEARCH VENDORARCH BIN SITEBIN VENDORBIN SCRIPT SITESCRIPT VENDORSCRIPT MAN1DIR SITEMAN1DIR VENDORMAN1DIR MAN3DIR SITEMAN3DIR VENDORMAN3DIR );}=head3 libscan my $wanted = $self->libscan($path);Takes a path to a file or dir and returns an empty string if we don'twant to include this file in the library. Otherwise it returns thethe $path unchanged.Mainly used to exclude version control administrative directories frominstallation.=cutsub libscan { my($self,$path) = @_; my($dirs,$file) = ($self->splitpath($path))[1,2]; return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/, $self->splitdir($dirs), $file; return $path;}=head3 platform_constants my $make_frag = $mm->platform_constantsReturns a make fragment defining all the macros initialized ininit_platform() rather than put them in constants().=cutsub platform_constants { return '';}=head1 AUTHORMichael G Schwern <schwern@pobox.com> and the denizens ofmakemaker@perl.org with code from ExtUtils::MM_Unix andExtUtils::MM_Win32.=cut1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -