Storable.thaw segv on blessed reference to overloaded object
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MakeMaker.pm
index 7fc9e0a..261808c 100644 (file)
@@ -1,43 +1,37 @@
-# $Id: /mirror/svn.schwern.org/CPAN/ExtUtils-MakeMaker/trunk/lib/ExtUtils/MakeMaker.pm 32261 2007-07-03T08:08:29.826721Z schwern  $
+# $Id: /local/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm 66493 2008-09-27T21:35:25.560547Z schwern  $
 package ExtUtils::MakeMaker;
 
-BEGIN {require 5.005_03;}
+use strict;
+
+BEGIN {require 5.006;}
 
 require Exporter;
 use ExtUtils::MakeMaker::Config;
 use Carp ();
 use File::Path;
 
-use vars qw(
-            @ISA @EXPORT @EXPORT_OK
-            $VERSION $Verbose %Config
-            @Prepend_parent @Parent
-            %Recognized_Att_Keys @Get_from_Config @MM_Sections @Overridable
-            $Filename
-           );
-
-# Has to be on its own line with no $ after it to avoid being noticed by
-# the version control system
-use vars qw($Revision);
-use strict;
+our $Verbose = 0;       # exported
+our @Parent;            # needs to be localized
+our @Get_from_Config;   # referenced by MM_Unix
+our @MM_Sections;
+our @Overridable;
+my @Prepend_parent;
+my %Recognized_Att_Keys;
 
-$VERSION = '6.36';
-($Revision) = q$Revision: 32261 $ =~ /Revision:\s+(\S+)/;
+our $VERSION = '6.46';
+our ($Revision) = q$Revision: 66493 $ =~ /Revision:\s+(\S+)/;
+our $Filename = __FILE__;   # referenced outside MakeMaker
 
-@ISA = qw(Exporter);
-@EXPORT = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
-@EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists
-                &WriteEmptyMakefile);
+our @ISA = qw(Exporter);
+our @EXPORT    = qw(&WriteMakefile &writeMakefile $Verbose &prompt);
+our @EXPORT_OK = qw($VERSION &neatvalue &mkbootstrap &mksymlists
+                    &WriteEmptyMakefile);
 
 # These will go away once the last of the Win32 & VMS specific code is 
 # purged.
 my $Is_VMS     = $^O eq 'VMS';
 my $Is_Win32   = $^O eq 'MSWin32';
 
-# Our filename for diagnostic and debugging purposes.  More reliable
-# than %INC (think caseless filesystems)
-$Filename = __FILE__;
-
 full_setup();
 
 require ExtUtils::MM;  # Things like CPAN assume loading ExtUtils::MakeMaker
@@ -45,7 +39,7 @@ require ExtUtils::MM;  # Things like CPAN assume loading ExtUtils::MakeMaker
 
 require ExtUtils::MY;  # XXX pre-5.8 versions of ExtUtils::Embed expect
                        # loading ExtUtils::MakeMaker will give them MY.
-                       # This will go when Embed is it's own CPAN module.
+                       # This will go when Embed is its own CPAN module.
 
 
 sub WriteMakefile {
@@ -83,6 +77,8 @@ my %Special_Sigs = (
  LIBS               => ['ARRAY',''],
  MAN1PODS           => 'HASH',
  MAN3PODS           => 'HASH',
+ META_ADD           => 'HASH',
+ META_MERGE         => 'HASH',
  PL_FILES           => 'HASH',
  PM                 => 'HASH',
  PMLIBDIRS          => 'ARRAY',
@@ -143,7 +139,7 @@ sub _format_att {
 }
 
 
-sub prompt ($;$) {
+sub prompt ($;$) {  ## no critic
     my($mess, $def) = @_;
     Carp::confess("prompt function called without an argument") 
         unless defined $mess;
@@ -220,7 +216,7 @@ sub full_setup {
 
     AUTHOR ABSTRACT ABSTRACT_FROM BINARY_LOCATION
     C CAPI CCFLAGS CONFIG CONFIGURE DEFINE DIR DISTNAME DL_FUNCS DL_VARS
-    EXCLUDE_EXT EXE_FILES EXTRA_META FIRST_MAKEFILE
+    EXCLUDE_EXT EXE_FILES FIRST_MAKEFILE
     FULLPERL FULLPERLRUN FULLPERLRUNINST
     FUNCLIST H IMPORTS
 
@@ -239,7 +235,8 @@ sub full_setup {
     SITELIBEXP      SITEARCHEXP 
 
     INC INCLUDE_EXT LDFROM LIB LIBPERL_A LIBS LICENSE
-    LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET 
+    LINKTYPE MAKE MAKEAPERL MAKEFILE MAKEFILE_OLD MAN1PODS MAN3PODS MAP_TARGET
+    META_ADD META_MERGE
     MYEXTLIB NAME NEEDS_LINKING NOECHO NO_META NORECURS NO_VC OBJECT OPTIMIZE 
     PERL_MALLOC_OK PERL PERLMAINCC PERLRUN PERLRUNINST PERL_CORE
     PERL_SRC PERM_RW PERM_RWX
@@ -425,6 +422,18 @@ sub new {
               $self->{PREREQ_PM}->{$prereq} : 'unknown version' ;
         }
     }
+    
+     if (%unsatisfied && $self->{PREREQ_FATAL}){
+        my $failedprereqs = join "\n", map {"    $_ $unsatisfied{$_}"} 
+                            sort { $a cmp $b } keys %unsatisfied;
+        die <<"END";
+MakeMaker FATAL: prerequisites not found.
+$failedprereqs
+
+Please install these modules first and rerun 'perl Makefile.PL'.
+END
+    }
+    
     if (defined $self->{CONFIGURE}) {
         if (ref $self->{CONFIGURE} eq 'CODE') {
             %configure_att = %{&{$self->{CONFIGURE}}};
@@ -442,19 +451,19 @@ sub new {
     my $newclass = ++$PACKNAME;
     local @Parent = @Parent;    # Protect against non-local exits
     {
-        no strict 'refs';
         print "Blessing Object into class [$newclass]\n" if $Verbose>=2;
         mv_all_methods("MY",$newclass);
         bless $self, $newclass;
         push @Parent, $self;
         require ExtUtils::MY;
+
+        no strict 'refs';   ## no critic;
         @{"$newclass\:\:ISA"} = 'MM';
     }
 
     if (defined $Parent[-2]){
         $self->{PARENT} = $Parent[-2];
-        my $key;
-        for $key (@Prepend_parent) {
+        for my $key (@Prepend_parent) {
             next unless defined $self->{PARENT}{$key};
 
             # Don't stomp on WriteMakefile() args.
@@ -494,16 +503,6 @@ sub new {
     } else {
         parse_args($self,split(' ', $ENV{PERL_MM_OPT} || ''),@ARGV);
     }
-    if (%unsatisfied && $self->{PREREQ_FATAL}){
-        my $failedprereqs = join "\n", map {"    $_ $unsatisfied{$_}"} 
-                            sort { $a cmp $b } keys %unsatisfied;
-        die <<"END";
-MakeMaker FATAL: prerequisites not found.
-$failedprereqs
-
-Please install these modules first and rerun 'perl Makefile.PL'.
-END
-    }
 
 
     $self->{NAME} ||= $self->guess_name;
@@ -604,8 +603,7 @@ END
     }
 
     # turn the SKIP array into a SKIPHASH hash
-    my (%skip,$skip);
-    for $skip (@{$self->{SKIP} || []}) {
+    for my $skip (@{$self->{SKIP} || []}) {
         $self->{SKIPHASH}{$skip} = 1;
     }
     delete $self->{SKIP}; # free memory
@@ -635,7 +633,9 @@ END
             my(%a) = %{$self->{$section} || {}};
             push @{$self->{RESULT}}, "\n# --- MakeMaker $section section:";
             push @{$self->{RESULT}}, "# " . join ", ", %a if $Verbose && %a;
-            push @{$self->{RESULT}}, $self->nicetext($self->$method( %a ));
+            push @{$self->{RESULT}}, $self->maketext_filter(
+                $self->$method( %a )
+            );
         }
     }
 
@@ -658,20 +658,20 @@ sub WriteEmptyMakefile {
     if ( -f $new ) {
         _rename($new, $old) or warn "rename $new => $old: $!"
     }
-    open MF, '>'.$new or die "open $new for write: $!";
-    print MF <<'EOP';
-all:
+    open my $mfh, '>', $new or die "open $new for write: $!";
+    print $mfh <<'EOP';
+all :
 
-clean:
+clean :
 
-install:
+install :
 
-makemakerdflt:
+makemakerdflt :
 
-test:
+test :
 
 EOP
-    close MF or die "close $new for write: $!";
+    close $mfh or die "close $new for write: $!";
 }
 
 sub check_manifest {
@@ -790,7 +790,7 @@ sub check_hints {
 }
 
 sub _run_hintfile {
-    no strict 'vars';
+    our $self;
     local($self) = shift;       # make $self available to the hint file.
     my($hint_file) = shift;
 
@@ -809,8 +809,6 @@ sub _run_hintfile {
 
 sub mv_all_methods {
     my($from,$to) = @_;
-    no strict 'refs';
-    my($symtab) = \%{"${from}::"};
 
     # Here you see the *current* list of methods that are overridable
     # from Makefile.PL via MY:: subroutines. As of VERSION 5.07 I'm
@@ -833,19 +831,23 @@ sub mv_all_methods {
 
         next unless defined &{"${from}::$method"};
 
-        *{"${to}::$method"} = \&{"${from}::$method"};
-
-        # delete would do, if we were sure, nobody ever called
-        # MY->makeaperl directly
-
-        # delete $symtab->{$method};
-
-        # If we delete a method, then it will be undefined and cannot
-        # be called.  But as long as we have Makefile.PLs that rely on
-        # %MY:: being intact, we have to fill the hole with an
-        # inheriting method:
-
-        eval "package MY; sub $method { shift->SUPER::$method(\@_); }";
+        {
+            no strict 'refs';   ## no critic
+            *{"${to}::$method"} = \&{"${from}::$method"};
+
+            # If we delete a method, then it will be undefined and cannot
+            # be called.  But as long as we have Makefile.PLs that rely on
+            # %MY:: being intact, we have to fill the hole with an
+            # inheriting method:
+
+            {
+                package MY;
+                my $super = "SUPER::".$method;
+                *{$method} = sub {
+                    shift->$super(@_);
+                };
+            }
+        }
     }
 
     # We have to clean out %INC also, because the current directory is
@@ -894,20 +896,19 @@ sub skipcheck {
 
 sub flush {
     my $self = shift;
-    my($chunk);
-    local *FH;
 
     my $finalname = $self->{MAKEFILE};
     print STDOUT "Writing $finalname for $self->{NAME}\n";
 
     unlink($finalname, "MakeMaker.tmp", $Is_VMS ? 'Descrip.MMS' : ());
-    open(FH,">MakeMaker.tmp") or die "Unable to open MakeMaker.tmp: $!";
+    open(my $fh,">", "MakeMaker.tmp")
+        or die "Unable to open MakeMaker.tmp: $!";
 
-    for $chunk (@{$self->{RESULT}}) {
-        print FH "$chunk\n";
+    for my $chunk (@{$self->{RESULT}}) {
+        print $fh "$chunk\n";
     }
 
-    close FH;
+    close $fh;
     _rename("MakeMaker.tmp", $finalname) or
       warn "rename MakeMaker.tmp => $finalname: $!";
     chmod 0644, $finalname unless $Is_VMS;
@@ -1752,7 +1753,7 @@ MakeMaker will turn it into an array with one element.
 The licensing terms of your distribution.  Generally its "perl" for the
 same license as Perl itself.
 
-See L<Module::Build::Authoring> for the list of options.
+See L<Module::Build::API> for the list of options.
 
 Defaults to "unknown".
 
@@ -1809,6 +1810,19 @@ C<make> and will be installed during C<make install>.
 If it is intended, that a new perl binary be produced, this variable
 may hold a name for that binary. Defaults to perl
 
+=item META_ADD
+
+=item META_MERGE
+
+A hashrefs of items to add to the F<META.yml>.
+
+They differ in how they behave if they have the same key as the
+default metadata.  META_ADD will override the default value with it's
+own.  META_MERGE will merge its value with the default.
+
+Unless you want to override the defaults, prefer META_MERGE so as to
+get the advantage of any future defaults.
+
 =item MYEXTLIB
 
 If the extension links to a library that it builds set this to the
@@ -2186,26 +2200,29 @@ will be evaluated with eval() and the value of the named variable
 B<after> the eval() will be assigned to the VERSION attribute of the
 MakeMaker object. The following lines will be parsed o.k.:
 
-    $VERSION = '1.00';
-    *VERSION = \'1.01';
-    ($VERSION) = q$Revision: 32261 $ =~ /(\d+)/g;
+    $VERSION   = '1.00';
+    *VERSION   = \'1.01';
+    ($VERSION) = q$Revision: 66493 $ =~ /(\d+)/g;
     $FOO::VERSION = '1.10';
     *FOO::VERSION = \'1.11';
-    our $VERSION = 1.2.3;       # new for perl5.6.0
 
 but these will fail:
 
-    my $VERSION = '1.01';
-    local $VERSION = '1.02';
+    # Bad
+    my $VERSION         = '1.01';
+    local $VERSION      = '1.02';
     local $FOO::VERSION = '1.30';
 
-L<version> will be loaded, if available, so this will work.
+"Version strings" are incompatible should not be used.
 
-    our $VERSION = qv(1.2.3);   # version.pm will be loaded if available
+    # Bad
+    $VERSION = 1.2.3;
+    $VERSION = v1.2.3;
 
-Its up to you to declare a dependency on C<version>.  Also note that this
-feature was introduced in MakeMaker 6.35.  Earlier versions of MakeMaker
-require this:
+L<version> objects are fine.  As of MakeMaker 6.35 version.pm will be
+automatically loaded, but you must declare the dependency on version.pm.
+For compatibility with older MakeMaker you should load on the same line 
+as $VERSION is declared.
 
     # All on one line
     use version; our $VERSION = qv(1.2.3);