📄 mm_unix.pm
字号:
package ExtUtils::MM_Unix;require 5.005_03; # Maybe further back, dunnouse strict;use Carp;use ExtUtils::MakeMaker::Config;use File::Basename qw(basename dirname);use DirHandle;use vars qw($VERSION @ISA $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_OSF $Is_IRIX $Is_NetBSD $Is_BSD $Is_SunOS4 $Is_Solaris $Is_SunOS $Is_Interix %Config_Override );use ExtUtils::MakeMaker qw($Verbose neatvalue);$VERSION = '6.42';require ExtUtils::MM_Any;@ISA = qw(ExtUtils::MM_Any);BEGIN { $Is_OS2 = $^O eq 'os2'; $Is_Win32 = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare'; $Is_Dos = $^O eq 'dos'; $Is_VMS = $^O eq 'VMS'; $Is_OSF = $^O eq 'dec_osf'; $Is_IRIX = $^O eq 'irix'; $Is_NetBSD = $^O eq 'netbsd'; $Is_Interix = $^O eq 'interix'; $Is_SunOS4 = $^O eq 'sunos'; $Is_Solaris = $^O eq 'solaris'; $Is_SunOS = $Is_SunOS4 || $Is_Solaris; $Is_BSD = ($^O =~ /^(?:free|net|open)bsd$/ or grep( $^O eq $_, qw(bsdos interix dragonfly) ) );}BEGIN { if( $Is_VMS ) { # For things like vmsify() require VMS::Filespec; VMS::Filespec->import; }}=head1 NAMEExtUtils::MM_Unix - methods used by ExtUtils::MakeMaker=head1 SYNOPSISC<require ExtUtils::MM_Unix;>=head1 DESCRIPTIONThe methods provided by this package are designed to be used inconjunction with ExtUtils::MakeMaker. When MakeMaker writes aMakefile, it creates one or more objects that inherit their methodsfrom a package C<MM>. MM itself doesn't provide any methods, but itISA ExtUtils::MM_Unix class. The inheritance tree of MM lets operatingspecific packages take the responsibility for all the methods providedby MM_Unix. We are trying to reduce the number of the necessaryoverrides by defining rather primitive operations withinExtUtils::MM_Unix.If you are going to write a platform specific MM package, please tryto limit the necessary overrides to primitive methods, and if it is notpossible to do so, let's work out how to achieve that gain.If you are overriding any of these methods in your Makefile.PL (in theMY class), please report that to the makemaker mailing list. We aretrying to minimize the necessary method overrides and switch to datadriven Makefile.PLs wherever possible. In the long run less methodswill be overridable via the MY class.=head1 METHODSThe following description of methods is still underdevelopment. Please refer to the code for not suitably documentedsections and complain loudly to the makemaker@perl.org mailing list.Better yet, provide a patch.Not all of the methods below are overridable in aMakefile.PL. Overridable methods are marked as (o). All methods areoverridable by a platform specific MM_*.pm file.Cross-platform methods are being moved into MM_Any. If you can't findsomething that used to be in here, look in MM_Any.=cut# So we don't have to keep calling the methods over and over again,# we have these globals to cache the values. Faster and shrtr.my $Curdir = __PACKAGE__->curdir;my $Rootdir = __PACKAGE__->rootdir;my $Updir = __PACKAGE__->updir;=head2 Methods=over 4=item os_flavorSimply says that we're Unix.=cutsub os_flavor { return('Unix');}=item c_o (o)Defines the suffix rules to compile different flavors of C files toobject files.=cutsub c_o {# --- Translation Sections --- my($self) = shift; return '' unless $self->needs_linking(); my(@m); my $command = '$(CCCMD)'; my $flags = '$(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE)'; if (my $cpp = $Config{cpprun}) { my $cpp_cmd = $self->const_cccmd; $cpp_cmd =~ s/^CCCMD\s*=\s*\$\(CC\)/$cpp/; push @m, qq{.c.i: $cpp_cmd $flags \$*.c > \$*.i}; } push @m, qq{.c.s: $command -S $flags \$*.c.c\$(OBJ_EXT): $command $flags \$*.c.cpp\$(OBJ_EXT): $command $flags \$*.cpp.cxx\$(OBJ_EXT): $command $flags \$*.cxx.cc\$(OBJ_EXT): $command $flags \$*.cc}; push @m, qq{.C\$(OBJ_EXT): $command \$*.C} if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific return join "", @m;}=item cflags (o)Does very much the same as the cflags script in the perldistribution. It doesn't return the whole compiler command line, butinitializes all of its parts. The const_cccmd method then actuallyreturns the definition of the CCCMD macro which uses these parts.=cut#'sub cflags { my($self,$libperl)=@_; return $self->{CFLAGS} if $self->{CFLAGS}; return '' unless $self->needs_linking(); my($prog, $uc, $perltype, %cflags); $libperl ||= $self->{LIBPERL_A} || "libperl$self->{LIB_EXT}" ; $libperl =~ s/\.\$\(A\)$/$self->{LIB_EXT}/; @cflags{qw(cc ccflags optimize shellflags)} = @Config{qw(cc ccflags optimize shellflags)}; my($optdebug) = ""; $cflags{shellflags} ||= ''; my(%map) = ( D => '-DDEBUGGING', E => '-DEMBED', DE => '-DDEBUGGING -DEMBED', M => '-DEMBED -DMULTIPLICITY', DM => '-DDEBUGGING -DEMBED -DMULTIPLICITY', ); if ($libperl =~ /libperl(\w*)\Q$self->{LIB_EXT}/){ $uc = uc($1); } else { $uc = ""; # avoid warning } $perltype = $map{$uc} ? $map{$uc} : ""; if ($uc =~ /^D/) { $optdebug = "-g"; } my($name); ( $name = $self->{NAME} . "_cflags" ) =~ s/:/_/g ; if ($prog = $Config{$name}) { # Expand hints for this extension via the shell print STDOUT "Processing $name hint:\n" if $Verbose; my(@o)=`cc=\"$cflags{cc}\" ccflags=\"$cflags{ccflags}\" optimize=\"$cflags{optimize}\" perltype=\"$cflags{perltype}\" optdebug=\"$cflags{optdebug}\" eval '$prog' echo cc=\$cc echo ccflags=\$ccflags echo optimize=\$optimize echo perltype=\$perltype echo optdebug=\$optdebug `; my($line); foreach $line (@o){ chomp $line; if ($line =~ /(.*?)=\s*(.*)\s*$/){ $cflags{$1} = $2; print STDOUT " $1 = $2\n" if $Verbose; } else { print STDOUT "Unrecognised result from hint: '$line'\n"; } } } if ($optdebug) { $cflags{optimize} = $optdebug; } for (qw(ccflags optimize perltype)) { $cflags{$_} ||= ''; $cflags{$_} =~ s/^\s+//; $cflags{$_} =~ s/\s+/ /g; $cflags{$_} =~ s/\s+$//; $self->{uc $_} ||= $cflags{$_}; } if ($self->{POLLUTE}) { $self->{CCFLAGS} .= ' -DPERL_POLLUTE '; } my $pollute = ''; if ($Config{usemymalloc} and not $Config{bincompat5005} and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/ and $self->{PERL_MALLOC_OK}) { $pollute = '$(PERL_MALLOC_DEF)'; } $self->{CCFLAGS} = quote_paren($self->{CCFLAGS}); $self->{OPTIMIZE} = quote_paren($self->{OPTIMIZE}); return $self->{CFLAGS} = qq{CCFLAGS = $self->{CCFLAGS}OPTIMIZE = $self->{OPTIMIZE}PERLTYPE = $self->{PERLTYPE}MPOLLUTE = $pollute};}=item const_cccmd (o)Returns the full compiler call for C programs and stores thedefinition in CONST_CCCMD.=cutsub const_cccmd { my($self,$libperl)=@_; return $self->{CONST_CCCMD} if $self->{CONST_CCCMD}; return '' unless $self->needs_linking(); return $self->{CONST_CCCMD} = q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\ $(CCFLAGS) $(OPTIMIZE) \\ $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\ $(XS_DEFINE_VERSION)};}=item const_config (o)Defines a couple of constants in the Makefile that are imported from%Config.=cutsub const_config {# --- Constants Sections --- my($self) = shift; my(@m,$m); push(@m,"\n# These definitions are from config.sh (via $INC{'Config.pm'})\n"); push(@m,"\n# They may have been overridden via Makefile.PL or on the command line\n"); my(%once_only); foreach $m (@{$self->{CONFIG}}){ # SITE*EXP macros are defined in &constants; avoid duplicates here next if $once_only{$m}; $self->{uc $m} = quote_paren($self->{uc $m}); push @m, uc($m) , ' = ' , $self->{uc $m}, "\n"; $once_only{$m} = 1; } join('', @m);}=item const_loadlibs (o)Defines EXTRALIBS, LDLOADLIBS, BSLOADLIBS, LD_RUN_PATH. SeeL<ExtUtils::Liblist> for details.=cutsub const_loadlibs { my($self) = shift; return "" unless $self->needs_linking; my @m; push @m, qq{# $self->{NAME} might depend on some other libraries:# See ExtUtils::Liblist for details#}; my($tmp); for $tmp (qw/ EXTRALIBS LDLOADLIBS BSLOADLIBS /) { next unless defined $self->{$tmp}; push @m, "$tmp = $self->{$tmp}\n"; } # don't set LD_RUN_PATH if empty for $tmp (qw/ LD_RUN_PATH /) { next unless $self->{$tmp}; push @m, "$tmp = $self->{$tmp}\n"; } return join "", @m;}=item constants (o) my $make_frag = $mm->constants;Prints out macros for lots of constants.=cutsub constants { my($self) = @_; my @m = (); $self->{DFSEP} = '$(DIRFILESEP)'; # alias for internal use for my $macro (qw( AR_STATIC_ARGS DIRFILESEP DFSEP NAME NAME_SYM VERSION VERSION_MACRO VERSION_SYM DEFINE_VERSION XS_VERSION XS_VERSION_MACRO XS_DEFINE_VERSION INST_ARCHLIB INST_SCRIPT INST_BIN INST_LIB INST_MAN1DIR INST_MAN3DIR MAN1EXT MAN3EXT INSTALLDIRS INSTALL_BASE DESTDIR PREFIX PERLPREFIX SITEPREFIX VENDORPREFIX ), (map { ("INSTALL".$_, "DESTINSTALL".$_) } $self->installvars), qw( PERL_LIB PERL_ARCHLIB LIBPERL_A MYEXTLIB FIRST_MAKEFILE MAKEFILE_OLD MAKE_APERL_FILE PERLMAINCC PERL_SRC PERL_INC PERL FULLPERL ABSPERL PERLRUN FULLPERLRUN ABSPERLRUN PERLRUNINST FULLPERLRUNINST ABSPERLRUNINST PERL_CORE PERM_RW PERM_RWX ) ) { next unless defined $self->{$macro}; # pathnames can have sharp signs in them; escape them so # make doesn't think it is a comment-start character. $self->{$macro} =~ s/#/\\#/g; push @m, "$macro = $self->{$macro}\n"; } push @m, qq{MAKEMAKER = $self->{MAKEMAKER}MM_VERSION = $self->{MM_VERSION}MM_REVISION = $self->{MM_REVISION}}; push @m, q{# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.}; for my $macro (qw/ MAKE FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT LDFROM LINKTYPE BOOTDEP / ) { next unless defined $self->{$macro}; push @m, "$macro = $self->{$macro}\n"; } push @m, "# Handy lists of source code files:XS_FILES = ".$self->wraplist(sort keys %{$self->{XS}})."C_FILES = ".$self->wraplist(@{$self->{C}})."O_FILES = ".$self->wraplist(@{$self->{O_FILES}})."H_FILES = ".$self->wraplist(@{$self->{H}})."MAN1PODS = ".$self->wraplist(sort keys %{$self->{MAN1PODS}})."MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}}).""; push @m, q{# Where is the Config information that we are using/depend onCONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h}; push @m, qq{# Where to build thingsINST_LIBDIR = $self->{INST_LIBDIR}INST_ARCHLIBDIR = $self->{INST_ARCHLIBDIR}INST_AUTODIR = $self->{INST_AUTODIR}INST_ARCHAUTODIR = $self->{INST_ARCHAUTODIR}INST_STATIC = $self->{INST_STATIC}INST_DYNAMIC = $self->{INST_DYNAMIC}INST_BOOT = $self->{INST_BOOT}}; push @m, qq{# Extra linker infoEXPORT_LIST = $self->{EXPORT_LIST}PERL_ARCHIVE = $self->{PERL_ARCHIVE}PERL_ARCHIVE_AFTER = $self->{PERL_ARCHIVE_AFTER}}; push @m, "TO_INST_PM = ".$self->wraplist(sort keys %{$self->{PM}})."PM_TO_BLIB = ".$self->wraplist(%{$self->{PM}}).""; join('',@m);}=item depend (o)Same as macro for the depend attribute.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -