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

📄 makemaker.pm

📁 ARM上的如果你对底层感兴趣
💻 PM
📖 第 1 页 / 共 4 页
字号:
BEGIN {require 5.002;} # MakeMaker 5.17 was the last MakeMaker that was compatible with perl5.001m

package ExtUtils::MakeMaker;

$Version = $VERSION = "5.4301";
$Version_OK = "5.17";	# Makefiles older than $Version_OK will die
			# (Will be checked from MakeMaker version 4.13 onwards)
($Revision = substr(q$Revision: 1.222 $, 10)) =~ s/\s+$//;



require Exporter;
use Config;
use Carp ();
#use FileHandle ();

use vars qw(

	    @ISA @EXPORT @EXPORT_OK $AUTOLOAD
	    $ISA_TTY $Is_Mac $Is_OS2 $Is_VMS $Revision $Setup_done
	    $VERSION $Verbose $Version_OK %Config %Keep_after_flush
	    %MM_Sections %Prepend_dot_dot %Recognized_Att_Keys
	    @Get_from_Config @MM_Sections @Overridable @Parent

	   );
# use strict;

# &DynaLoader::mod2fname should be available to miniperl, thus 
# should be a pseudo-builtin (cmp. os2.c).
#eval {require DynaLoader;};

#
# Set up the inheritance before we pull in the MM_* packages, because they
# import variables and functions from here
#
@ISA = qw(Exporter);
@EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
@EXPORT_OK = qw($VERSION &Version_check &neatvalue &mkbootstrap &mksymlists
		$Version);
		# $Version in mixed case will go away!

#
# Dummy package MM inherits actual methods from OS-specific
# default packages.  We use this intermediate package so
# MY::XYZ->func() can call MM->func() and get the proper
# default routine without having to know under what OS
# it's running.
#
@MM::ISA = qw[ExtUtils::MM_Unix ExtUtils::Liblist ExtUtils::MakeMaker];

#
# Setup dummy package:
# MY exists for overriding methods to be defined within
#
{
    package MY;
    @MY::ISA = qw(MM);
###    sub AUTOLOAD { use Devel::Symdump; print Devel::Symdump->rnew->as_string; Carp::confess "hey why? $AUTOLOAD" }
    package MM;
    sub DESTROY {}
}

# "predeclare the package: we only load it via AUTOLOAD
# but we have already mentioned it in @ISA
package ExtUtils::Liblist;

package ExtUtils::MakeMaker;
#
# Now we can pull in the friends
#
$Is_VMS   = $^O eq 'VMS';
$Is_OS2   = $^O eq 'os2';
$Is_Mac   = $^O eq 'MacOS';
$Is_Win32 = $^O eq 'MSWin32';

# This is for module authors to query, so they can enable 'CAPI' => 'TRUE'
# in their Makefile.pl
$CAPI_support = 1;

require ExtUtils::MM_Unix;

if ($Is_VMS) {
    require ExtUtils::MM_VMS;
    require VMS::Filespec; # is a noop as long as we require it within MM_VMS
}
if ($Is_OS2) {
    require ExtUtils::MM_OS2;
}
if ($Is_Mac) {
    require ExtUtils::MM_Mac;
}
if ($Is_Win32) {
    require ExtUtils::MM_Win32;
}

# The SelfLoader would bring a lot of overhead for MakeMaker, because
# we know for sure we will use most of the autoloaded functions once
# we have to use one of them. So we write our own loader

sub AUTOLOAD {
    my $code;
    if (defined fileno(DATA)) {
	my $fh = select DATA;
	my $o = $/;			# For future reads from the file.
	$/ = "\n__END__\n";
	$code = <DATA>;
	$/ = $o;
	select $fh;
	close DATA;
	eval $code;
	if ($@) {
	    $@ =~ s/ at .*\n//;
	    Carp::croak $@;
	}
    } else {
	warn "AUTOLOAD called unexpectedly for $AUTOLOAD"; 
    }
    defined(&$AUTOLOAD) or die "Myloader inconsistency error";
    goto &$AUTOLOAD;
}

# The only subroutine we do not SelfLoad is Version_Check because it's
# called so often. Loading this minimum still requires 1.2 secs on my
# Indy :-(

sub Version_check {
    my($checkversion) = @_;
    die "Your Makefile was built with ExtUtils::MakeMaker v $checkversion.
Current Version is $ExtUtils::MakeMaker::VERSION. There have been considerable
changes in the meantime.
Please rerun 'perl Makefile.PL' to regenerate the Makefile.\n"
    if $checkversion < $Version_OK;
    printf STDOUT "%s %s %s %s.\n", "Makefile built with ExtUtils::MakeMaker v",
    $checkversion, "Current Version is", $VERSION
	unless $checkversion == $VERSION;
}

sub warnhandler {
    $_[0] =~ /^Use of uninitialized value/ && return;
    $_[0] =~ /used only once/ && return;
    $_[0] =~ /^Subroutine\s+[\w:]+\s+redefined/ && return;
    warn @_;
}

sub ExtUtils::MakeMaker::eval_in_subdirs ;
sub ExtUtils::MakeMaker::eval_in_x ;
sub ExtUtils::MakeMaker::full_setup ;
sub ExtUtils::MakeMaker::writeMakefile ;
sub ExtUtils::MakeMaker::new ;
sub ExtUtils::MakeMaker::check_manifest ;
sub ExtUtils::MakeMaker::parse_args ;
sub ExtUtils::MakeMaker::check_hints ;
sub ExtUtils::MakeMaker::mv_all_methods ;
sub ExtUtils::MakeMaker::skipcheck ;
sub ExtUtils::MakeMaker::flush ;
sub ExtUtils::MakeMaker::mkbootstrap ;
sub ExtUtils::MakeMaker::mksymlists ;
sub ExtUtils::MakeMaker::neatvalue ;
sub ExtUtils::MakeMaker::selfdocument ;
sub ExtUtils::MakeMaker::WriteMakefile ;
sub ExtUtils::MakeMaker::prompt ($;$) ;

1;

__DATA__

package ExtUtils::MakeMaker;

sub WriteMakefile {
    Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
    local $SIG{__WARN__} = \&warnhandler;

    unless ($Setup_done++){
	full_setup();
	undef &ExtUtils::MakeMaker::full_setup; #safe memory
    }
    my %att = @_;
    MM->new(\%att)->flush;
}

sub prompt ($;$) {
    my($mess,$def)=@_;
    $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ;	# Pipe?
    Carp::confess("prompt function called without an argument") unless defined $mess;
    my $dispdef = defined $def ? "[$def] " : " ";
    $def = defined $def ? $def : "";
    my $ans;
    local $|=1;
    print "$mess $dispdef";
    if ($ISA_TTY) {
	chomp($ans = <STDIN>);
    } else {
	print "$def\n";
    }
    return $ans || $def;
}

sub eval_in_subdirs {
    my($self) = @_;
    my($dir);
    use Cwd 'cwd';
    my $pwd = cwd();

    foreach $dir (@{$self->{DIR}}){
	my($abs) = $self->catdir($pwd,$dir);
	$self->eval_in_x($abs);
    }
    chdir $pwd;
}

sub eval_in_x {
    my($self,$dir) = @_;
    package main;
    chdir $dir or Carp::carp("Couldn't change to directory $dir: $!");
#    use FileHandle ();
#    my $fh = new FileHandle;
#    $fh->open("Makefile.PL") or Carp::carp("Couldn't open Makefile.PL in $dir");
    local *FH;
    open(FH,"Makefile.PL") or Carp::carp("Couldn't open Makefile.PL in $dir");
#    my $eval = join "", <$fh>;
    my $eval = join "", <FH>;
#    $fh->close;
    close FH;
    eval $eval;
    if ($@) {
# 	  if ($@ =~ /prerequisites/) {
# 	      die "MakeMaker WARNING: $@";
# 	  } else {
# 	      warn "WARNING from evaluation of $dir/Makefile.PL: $@";
# 	  }
	warn "WARNING from evaluation of $dir/Makefile.PL: $@";
    }
}

sub full_setup {
    $Verbose ||= 0;
    $^W=1;

    # package name for the classes into which the first object will be blessed
    $PACKNAME = "PACK000";

    @Attrib_help = qw/

    AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION LICENSE_HREF CAPI
    C CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS
    EXE_FILES EXCLUDE_EXT INCLUDE_EXT NO_VC FIRST_MAKEFILE FULLPERL H
    INC INSTALLARCHLIB INSTALLBIN INSTALLDIRS INSTALLMAN1DIR
    INSTALLMAN3DIR INSTALLPRIVLIB INSTALLSCRIPT INSTALLSITEARCH
    INSTALLSITELIB INST_ARCHLIB INST_BIN INST_EXE INST_LIB
    INST_MAN1DIR INST_MAN3DIR INST_SCRIPT LDFROM LIBPERL_A LIB LIBS
    LINKTYPE MAKEAPERL MAKEFILE MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB
    NAME NEEDS_LINKING NOECHO NORECURS OBJECT OPTIMIZE PERL PERLMAINCC
    PERL_ARCHLIB PERL_LIB PERL_SRC PERM_RW PERM_RWX
    PL_FILES PM PMLIBDIRS PREFIX
    PREREQ_PM SKIP TYPEMAPS VERSION VERSION_FROM XS XSOPT XSPROTOARG
    XS_VERSION clean depend dist dynamic_lib linkext macro realclean
    tool_autosplit PPM_INSTALL_SCRIPT PPM_INSTALL_EXEC

    IMPORTS

    installpm
	/;

    # IMPORTS is used under OS/2

    # ^^^ installpm is deprecated, will go about Summer 96

    # @Overridable is close to @MM_Sections but not identical.  The
    # order is important. Many subroutines declare macros. These
    # depend on each other. Let's try to collect the macros up front,
    # then pasthru, then the rules.

    # MM_Sections are the sections we have to call explicitly
    # in Overridable we have subroutines that are used indirectly


    @MM_Sections = 
	qw(

 post_initialize const_config constants tool_autosplit tool_xsubpp
 tools_other dist macro depend cflags const_loadlibs const_cccmd
 post_constants

 pasthru

 c_o xs_c xs_o top_targets linkext dlsyms dynamic dynamic_bs
 dynamic_lib static static_lib manifypods processPL installbin subdirs
 clean realclean dist_basics dist_core dist_dir dist_test dist_ci
 install force perldepend makefile staticmake test ppd

	  ); # loses section ordering

    @Overridable = @MM_Sections;
    push @Overridable, qw[

 dir_target libscan makeaperl needs_linking perm_rw perm_rwx
 subdir_x test_via_harness test_via_script

			 ];

    push @MM_Sections, qw[

 pm_to_blib selfdocument

			 ];

    # Postamble needs to be the last that was always the case
    push @MM_Sections, "postamble";
    push @Overridable, "postamble";

    # All sections are valid keys.
    @Recognized_Att_Keys{@MM_Sections} = (1) x @MM_Sections;

    # we will use all these variables in the Makefile
    @Get_from_Config = 
	qw(
	   ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc
	   lib_ext obj_ext osname osvers ranlib sitelibexp sitearchexp so exe_ext
	  );

    my $item;
    foreach $item (@Attrib_help){
	$Recognized_Att_Keys{$item} = 1;
    }
    foreach $item (@Get_from_Config) {
	$Recognized_Att_Keys{uc $item} = $Config{$item};
	print "Attribute '\U$item\E' => '$Config{$item}'\n"
	    if ($Verbose >= 2);
    }

    #
    # When we eval a Makefile.PL in a subdirectory, that one will ask
    # us (the parent) for the values and will prepend "..", so that
    # all files to be installed end up below OUR ./blib
    #
    %Prepend_dot_dot = 
	qw(

	   INST_BIN 1 INST_EXE 1 INST_LIB 1 INST_ARCHLIB 1 INST_SCRIPT
	   1 MAP_TARGET 1 INST_MAN1DIR 1 INST_MAN3DIR 1 PERL_SRC 1
	   PERL 1 FULLPERL 1

	  );

    my @keep = qw/
	NEEDS_LINKING HAS_LINK_CODE
	/;
    @Keep_after_flush{@keep} = (1) x @keep;
}

sub writeMakefile {
    die <<END;

The extension you are trying to build apparently is rather old and
most probably outdated. We detect that from the fact, that a
subroutine "writeMakefile" is called, and this subroutine is not
supported anymore since about October 1994.

Please contact the author or look into CPAN (details about CPAN can be
found in the FAQ and at http:/www.perl.com) for a more recent version
of the extension. If you're really desperate, you can try to change
the subroutine name from writeMakefile to WriteMakefile and rerun
'perl Makefile.PL', but you're most probably left alone, when you do
so.

The MakeMaker team

END
}

sub ExtUtils::MakeMaker::new {
    my($class,$self) = @_;
    my($key);

    print STDOUT "MakeMaker (v$VERSION)\n" if $Verbose;
    if (-f "MANIFEST" && ! -f "Makefile"){
	check_manifest();
    }

    $self = {} unless (defined $self);

    check_hints($self);

    my(%initial_att) = %$self; # record initial attributes

    my($prereq);
    foreach $prereq (sort keys %{$self->{PREREQ_PM}}) {
	my $eval = "use $prereq $self->{PREREQ_PM}->{$prereq}";
	eval $eval;
	if ($@){
	    warn "Warning: prerequisite $prereq $self->{PREREQ_PM}->{$prereq} not found";
# Why is/was this 'delete' here?  We need PREREQ_PM later to make PPDs.
#	} else {
#	    delete $self->{PREREQ_PM}{$prereq};
	}
    }
#    if (@unsatisfied){
# 	  unless (defined $ExtUtils::MakeMaker::useCPAN) {
# 	      print qq{MakeMaker WARNING: prerequisites not found (@unsatisfied)
# Please install these modules first and rerun 'perl Makefile.PL'.\n};
# 	      if ($ExtUtils::MakeMaker::hasCPAN) {
# 		  $ExtUtils::MakeMaker::useCPAN = prompt(qq{Should I try to use the CPAN module to fetch them for you?},"yes");
# 	      } else {
# 		  print qq{Hint: You may want to install the CPAN module to autofetch the needed modules\n};
# 		  $ExtUtils::MakeMaker::useCPAN=0;
# 	      }
# 	  }
# 	  if ($ExtUtils::MakeMaker::useCPAN) {
# 	      require CPAN;
# 	      CPAN->import(@unsatisfied);
# 	  } else {
# 	      die qq{prerequisites not found (@unsatisfied)};
# 	  }
#	warn qq{WARNING: prerequisites not found (@unsatisfied)};
#    }

    if (defined $self->{CONFIGURE}) {
	if (ref $self->{CONFIGURE} eq 'CODE') {
	    $self = { %$self, %{&{$self->{CONFIGURE}}}};
	} else {
	    Carp::croak "Attribute 'CONFIGURE' to WriteMakefile() not a code reference\n";
	}
    }

    # This is for old Makefiles written pre 5.00, will go away
    if ( Carp::longmess("") =~ /runsubdirpl/s ){
	Carp::carp("WARNING: Please rerun 'perl Makefile.PL' to regenerate your Makefiles\n");
    }

    my $newclass = ++$PACKNAME;
    {
#	no strict;
	print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
	mv_all_methods("MY",$newclass);
	bless $self, $newclass;
	push @Parent, $self;
	@{"$newclass\:\:ISA"} = 'MM';
    }

    if (defined $Parent[-2]){
	$self->{PARENT} = $Parent[-2];
	my $key;
	for $key (keys %Prepend_dot_dot) {
	    next unless defined $self->{PARENT}{$key};
	    $self->{$key} = $self->{PARENT}{$key};
		# PERL and FULLPERL may be command verbs instead of full
		# file specifications under VMS.  If so, don't turn them
		# into a filespec.
	    $self->{$key} = $self->catdir("..",$self->{$key})
		unless $self->file_name_is_absolute($self->{$key})
		|| ($^O eq 'VMS' and ($key =~ /PERL$/ && $self->{$key} =~ /^[\w\-\$]+$/));
	}
	$self->{PARENT}->{CHILDREN}->{$newclass} = $self if $self->{PARENT};
    } else {
	parse_args($self,@ARGV);
    }

    $self->{NAME} ||= $self->guess_name;

    ($self->{NAME_SYM} = $self->{NAME}) =~ s/\W+/_/g;

    $self->init_main();

    if (! $self->{PERL_SRC} ) {
	my($pthinks) = $self->canonpath($INC{'Config.pm'});
	my($cthinks) = $self->catfile($Config{'archlibexp'},'Config.pm');
	$pthinks = VMS::Filespec::vmsify($pthinks) if $Is_VMS;
	if ($pthinks ne $cthinks &&
	    !($Is_Win32 and lc($pthinks) eq lc($cthinks))) {
            print "Have $pthinks expected $cthinks\n";
	    if ($Is_Win32) {
		$pthinks =~ s![/\\]Config\.pm$!!i; $pthinks =~ s!.*[/\\]!!;
	    }
	    else {
		$pthinks =~ s!/Config\.pm$!!; $pthinks =~ s!.*/!!;
	    }
	    print STDOUT <<END;
Your perl and your Config.pm seem to have different ideas about the architecture
they are running on.
Perl thinks: [$pthinks]
Config says: [$Config{archname}]
This may or may not cause problems. Please check your installation of perl if you
have problems building this extension.
END

⌨️ 快捷键说明

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