Upgrade to ExtUtils-MakeMaker-6.46
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / MM_Unix.pm
index 423c3e9..e79d67d 100644 (file)
@@ -1,46 +1,50 @@
 package ExtUtils::MM_Unix;
 
-require 5.005_03;  # Maybe further back, dunno
+require 5.006;
 
 use strict;
 
-use Exporter ();
 use Carp;
-use Config         qw(%Config);
-use File::Basename qw(basename dirname fileparse);
+use ExtUtils::MakeMaker::Config;
+use File::Basename qw(basename dirname);
 use DirHandle;
 
-use vars qw($VERSION @ISA
-            $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Win95  $Is_Dos $Is_VOS
-            $Is_QNX $Is_AIX $Is_OSF $Is_IRIX  $Is_NetBSD $Is_BSD
-            $Is_SunOS4 $Is_Solaris $Is_SunOS
-            $Verbose %pm %static
-            %Config_Override
-           );
+our %Config_Override;
 
 use ExtUtils::MakeMaker qw($Verbose neatvalue);
 
-$VERSION = '1.41';
+# If we make $VERSION an our variable parse_version() breaks
+use vars qw($VERSION);
+$VERSION = '6.46_01';
 
 require ExtUtils::MM_Any;
-@ISA = qw(ExtUtils::MM_Any);
-
-$Is_OS2     = $^O eq 'os2';
-$Is_Mac     = $^O eq 'MacOS';
-$Is_Win32   = $^O eq 'MSWin32' || $Config{osname} eq 'NetWare';
-$Is_Win95   = $Is_Win32 && Win32::IsWin95();
-$Is_Dos     = $^O eq 'dos';
-$Is_VOS     = $^O eq 'vos';
-$Is_VMS     = $^O eq 'VMS';
-$Is_QNX     = $^O eq 'qnx';
-$Is_AIX     = $^O eq 'aix';
-$Is_OSF     = $^O eq 'dec_osf';
-$Is_IRIX    = $^O eq 'irix';
-$Is_NetBSD  = $^O eq 'netbsd';
-$Is_SunOS4  = $^O eq 'sunos';
-$Is_Solaris = $^O eq 'solaris';
-$Is_SunOS   = $Is_SunOS4 || $Is_Solaris;
-$Is_BSD     = $^O =~ /^(?:free|net|open)bsd|bsdos$/;
+our @ISA = qw(ExtUtils::MM_Any);
+
+my %Is;
+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 NAME
@@ -82,8 +86,10 @@ Better yet, provide a patch.
 
 Not all of the methods below are overridable in a
 Makefile.PL. Overridable methods are marked as (o). All methods are
-overridable by a platform specific MM_*.pm file (See
-L<ExtUtils::MM_VMS>) and L<ExtUtils::MM_OS2>).
+overridable by a platform specific MM_*.pm file.
+
+Cross-platform methods are being moved into MM_Any.  If you can't find
+something that used to be in here, look in MM_Any.
 
 =cut
 
@@ -98,7 +104,7 @@ my $Updir   = __PACKAGE__->updir;
 
 =over 4
 
-=item os_flavor (o)
+=item os_flavor
 
 Simply says that we're Unix.
 
@@ -122,37 +128,42 @@ sub c_o {
     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, '
+        push @m, qq{
 .c.i:
-       '. $cpp_cmd . ' $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.c > $*.i
-';
+       $cpp_cmd $flags \$*.c > \$*.i
+};
     }
-    push @m, '
+
+    push @m, qq{
 .c.s:
-       $(CCCMD) -S $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.c
-';
-    push @m, '
-.c$(OBJ_EXT):
-       $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.c
-';
-    push @m, '
-.C$(OBJ_EXT):
-       $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.C
-' if !$Is_OS2 and !$Is_Win32 and !$Is_Dos; #Case-specific
-    push @m, '
-.cpp$(OBJ_EXT):
-       $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.cpp
+       $command -S $flags \$*.c
 
-.cxx$(OBJ_EXT):
-       $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.cxx
+.c\$(OBJ_EXT):
+       $command $flags \$*.c
 
-.cc$(OBJ_EXT):
-       $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(DEFINE) $(PASTHRU_DEFINE) $*.cc
-';
-    join "", @m;
+.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)
@@ -218,8 +229,7 @@ sub cflags {
          echo perltype=\$perltype
          echo optdebug=\$optdebug
          `;
-       my($line);
-       foreach $line (@o){
+       foreach my $line (@o){
            chomp $line;
            if ($line =~ /(.*?)=\s*(.*)\s*$/){
                $cflags{$1} = $2;
@@ -265,92 +275,6 @@ MPOLLUTE = $pollute
 
 }
 
-=item clean (o)
-
-Defines the clean target.
-
-=cut
-
-sub clean {
-# --- Cleanup and Distribution Sections ---
-
-    my($self, %attribs) = @_;
-    my(@m,$dir);
-    push(@m, '
-# Delete temporary files but do not touch installed files. We don\'t delete
-# the Makefile here so a later make realclean still has a makefile to use.
-
-clean :: clean_subdirs
-');
-
-    my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
-    if ( $Is_QNX ) {
-      my @errfiles = @{$self->{C}};
-      for ( @errfiles ) {
-       s/.c$/.err/;
-      }
-      push( @otherfiles, @errfiles, 'perlmain.err' );
-    }
-    push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
-    push(@otherfiles, qw[./blib $(MAKE_APERL_FILE) 
-                         $(INST_ARCHAUTODIR)/extralibs.all
-                         $(INST_ARCHAUTODIR)/extralibs.ld
-                        perlmain.c tmon.out mon.out so_locations pm_to_blib
-                        *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
-                        $(BOOTSTRAP) $(BASEEXT).bso
-                        $(BASEEXT).def lib$(BASEEXT).def
-                        $(BASEEXT).exp $(BASEEXT).x
-                       ]);
-    if( $Is_VOS ) {
-        push(@otherfiles, qw[*.kp]);
-    }
-    else {
-        push(@otherfiles, qw[core core.*perl.*.? *perl.core]);
-
-        # core.\d+
-        push(@otherfiles, map { "core." . "[0-9]"x$_ } (1..5));
-    }
-
-    push @m, "\t-\$(RM_RF) @otherfiles\n";
-    # See realclean and ext/utils/make_ext for usage of Makefile.old
-    push(@m,
-        "\t-\$(MV) \$(FIRST_MAKEFILE) \$(MAKEFILE_OLD) \$(DEV_NULL)\n");
-    push(@m,
-        "\t$attribs{POSTOP}\n")   if $attribs{POSTOP};
-    join("", @m);
-}
-
-
-=item clean_subdirs_target
-
-  my $make_frag = $MM->clean_subdirs_target;
-
-Returns the clean_subdirs target.  This is used by the clean target to
-call clean on any subdirectories which contain Makefiles.
-
-=cut
-
-sub clean_subdirs_target {
-    my($self) = shift;
-
-    # No subdirectories, no cleaning.
-    return <<'NOOP_FRAG' unless @{$self->{DIR}};
-clean_subdirs :
-       $(NOECHO) $(NOOP)
-NOOP_FRAG
-
-
-    my $clean = "clean_subdirs :\n";
-
-    for my $dir (@{$self->{DIR}}) {
-        $clean .= sprintf <<'MAKE_FRAG', $dir;
-       -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) clean
-MAKE_FRAG
-    }
-
-    return $clean;
-}
-
 
 =item const_cccmd (o)
 
@@ -363,10 +287,8 @@ sub const_cccmd {
     my($self,$libperl)=@_;
     return $self->{CONST_CCCMD} if $self->{CONST_CCCMD};
     return '' unless $self->needs_linking();
-    # PASTHRU_INC is defined explicitly by extensions
-    # wanting to do complex things.
     return $self->{CONST_CCCMD} =
-       q{CCCMD = $(CC) -c $(INC) $(PASTHRU_INC) \\
+       q{CCCMD = $(CC) -c $(PASTHRU_INC) $(INC) \\
        $(CCFLAGS) $(OPTIMIZE) \\
        $(PERLTYPE) $(MPOLLUTE) $(DEFINE_VERSION) \\
        $(XS_DEFINE_VERSION)};
@@ -383,16 +305,19 @@ sub 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 @m = <<"END";
+
+# These definitions are from config.sh (via $INC{'Config.pm'}).
+# They may have been overridden via Makefile.PL or on the command line.
+END
+
     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;
+    foreach my $key (@{$self->{CONFIG}}){
+        # SITE*EXP macros are defined in &constants; avoid duplicates here
+        next if $once_only{$key};
+        $self->{uc $key} = quote_paren($self->{uc $key});
+        push @m, uc($key) , ' = ' , $self->{uc $key}, "\n";
+        $once_only{$key} = 1;
     }
     join('', @m);
 }
@@ -413,12 +338,18 @@ sub const_loadlibs {
 # See ExtUtils::Liblist for details
 #
 };
-    my($tmp);
-    for $tmp (qw/
-        EXTRALIBS LDLOADLIBS BSLOADLIBS LD_RUN_PATH
-        /) {
-       next unless defined $self->{$tmp};
-       push @m, "$tmp = $self->{$tmp}\n";
+    for my $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 my $tmp (qw/
+         LD_RUN_PATH
+         /) {
+        next unless $self->{$tmp};
+        push @m, "$tmp = $self->{$tmp}\n";
     }
     return join "", @m;
 }
@@ -435,17 +366,18 @@ sub constants {
     my($self) = @_;
     my @m = ();
 
+    $self->{DFSEP} = '$(DIRFILESEP)';  # alias for internal use
+
     for my $macro (qw(
 
-              AR_STATIC_ARGS DIRFILESEP
+              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
-              DESTDIR PREFIX
+              INSTALLDIRS INSTALL_BASE DESTDIR PREFIX
               PERLPREFIX      SITEPREFIX      VENDORPREFIX
                    ),
                    (map { ("INSTALL".$_,
@@ -487,8 +419,9 @@ MM_REVISION = $self->{MM_REVISION}
 };
 
     for my $macro (qw/
+              MAKE
              FULLEXT BASEEXT PARENT_NAME DLBASE VERSION_FROM INC DEFINE OBJECT
-             LDFROM LINKTYPE PM_FILTER
+             LDFROM LINKTYPE BOOTDEP
              / ) 
     {
        next unless defined $self->{$macro};
@@ -508,7 +441,7 @@ MAN3PODS = ".$self->wraplist(sort keys %{$self->{MAN3PODS}})."
 
     push @m, q{
 # Where is the Config information that we are using/depend on
-CONFIGDEP = $(PERL_ARCHLIB)$(DIRFILESEP)Config.pm $(PERL_INC)$(DIRFILESEP)config.h
+CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
 };
 
 
@@ -560,49 +493,6 @@ sub depend {
     join "", @m;
 }
 
-=item dir_target (o)
-
-Takes an array of directories that need to exist and returns a
-Makefile entry for a .exists file in these directories. Returns
-nothing, if the entry has already been processed. We're helpless
-though, if the same directory comes as $(FOO) _and_ as "bar". Both of
-them get an entry, that's why we use "::".
-
-=cut
-
-sub dir_target {
-# --- Make-Directories section (internal method) ---
-# dir_target(@array) returns a Makefile entry for the file .exists in each
-# named directory. Returns nothing, if the entry has already been processed.
-# We're helpless though, if the same directory comes as $(FOO) _and_ as "bar".
-# Both of them get an entry, that's why we use "::". I chose '$(PERL)' as the
-# prerequisite, because there has to be one, something that doesn't change
-# too often :)
-
-    my($self,@dirs) = @_;
-    my(@m,$dir,$targdir);
-    foreach $dir (@dirs) {
-       my($src) = $self->catfile($self->{PERL_INC},'perl.h');
-       my($targ) = $self->catfile($dir,'.exists');
-       # catfile may have adapted syntax of $dir to target OS, so...
-       if ($Is_VMS) { # Just remove file name; dirspec is often in macro
-           ($targdir = $targ) =~ s:/?\.exists\z::;
-       }
-       else { # while elsewhere we expect to see the dir separator in $targ
-           $targdir = dirname($targ);
-       }
-       next if $self->{DIR_TARGET}{$self}{$targdir}++;
-       push @m, qq{
-$targ :: $src
-       \$(NOECHO) \$(MKPATH) $targdir
-       \$(NOECHO) \$(EQUALIZE_TIMESTAMP) $src $targ
-};
-       push(@m, qq{
-       -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $targdir
-}) unless $Is_VMS;
-    }
-    join "", @m;
-}
 
 =item init_DEST
 
@@ -747,7 +637,7 @@ manifest :
        $(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
 
 veryclean : realclean
-       $(RM_F) *~ *.orig */*~ */*.orig
+       $(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old 
 
 MAKE_FRAG
 
@@ -941,102 +831,19 @@ shdist : distdir
 MAKE_FRAG
 }
 
-=item distdir
-
-Defines the scratch directory target that will hold the distribution
-before tar-ing (or shar-ing).
-
-=cut
-
-# For backwards compatibility.
-*dist_dir = *distdir;
-
-sub distdir {
-    my($self) = shift;
-
-    return <<'MAKE_FRAG';
-distdir : metafile metafile_addtomanifest
-       $(RM_RF) $(DISTVNAME)
-       $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
-               -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
-
-MAKE_FRAG
-
-}
-
-=item dist_test
-
-Defines a target that produces the distribution in the
-scratchdirectory, and runs 'perl Makefile.PL; make ;make test' in that
-subdirectory.
-
-=cut
-
-sub dist_test {
-    my($self) = shift;
-    my @m;
-    push @m, q{
-disttest : distdir
-       cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
-       cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
-       cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
-};
-    join "", @m;
-}
 
 =item dlsyms (o)
 
-Used by AIX and VMS to define DL_FUNCS and DL_VARS and write the *.exp
-files.
+Used by some OS' to define DL_FUNCS and DL_VARS and write the *.exp files.
+
+Normally just returns an empty string.
 
 =cut
 
 sub dlsyms {
-    my($self,%attribs) = @_;
-
-    return '' unless ($Is_AIX && $self->needs_linking() );
-
-    my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
-    my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
-    my($funclist)  = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
-    my(@m);
-
-    push(@m,"
-dynamic :: $self->{BASEEXT}.exp
-
-") unless $self->{SKIPHASH}{'dynamic'}; # dynamic and static are subs, so...
-
-    push(@m,"
-static :: $self->{BASEEXT}.exp
-
-") unless $self->{SKIPHASH}{'static'};  # we avoid a warning if we tick them
-
-    push(@m,"
-$self->{BASEEXT}.exp: Makefile.PL
-",'    $(PERLRUN) -e \'use ExtUtils::Mksymlists; \\
-       Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
-       neatvalue($funcs), ', "FUNCLIST" => ', neatvalue($funclist),
-       ', "DL_VARS" => ', neatvalue($vars), ');\'
-');
-
-    join('',@m);
+    return '';
 }
 
-=item dynamic (o)
-
-Defines the dynamic target.
-
-=cut
-
-sub dynamic {
-# --- Dynamic Loading Sections ---
-
-    my($self) = shift;
-    '
-dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
-       $(NOECHO) $(NOOP)
-';
-}
 
 =item dynamic_bs (o)
 
@@ -1050,24 +857,26 @@ sub dynamic_bs {
 BOOTSTRAP =
 ' unless $self->has_link_code();
 
-    return <<'MAKE_FRAG';
+    my $target = $Is{VMS} ? '$(MMS$TARGET)' : '$@';
+
+    return sprintf <<'MAKE_FRAG', ($target) x 5;
 BOOTSTRAP = $(BASEEXT).bs
 
 # As Mkbootstrap might not write a file (if none is required)
 # we use touch to prevent make continually trying to remake it.
 # The DynaLoader only reads a non-empty file.
-$(BOOTSTRAP): $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
+$(BOOTSTRAP) : $(FIRST_MAKEFILE) $(BOOTDEP) $(INST_ARCHAUTODIR)$(DFSEP).exists
        $(NOECHO) $(ECHO) "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
        $(NOECHO) $(PERLRUN) \
                "-MExtUtils::Mkbootstrap" \
                -e "Mkbootstrap('$(BASEEXT)','$(BSLOADLIBS)');"
-       $(NOECHO) $(TOUCH) $(BOOTSTRAP)
-       $(CHMOD) $(PERM_RW) $@
+       $(NOECHO) $(TOUCH) %s
+       $(CHMOD) $(PERM_RW) %s
 
-$(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
-       $(NOECHO) $(RM_RF) $(INST_BOOT)
-       -$(CP) $(BOOTSTRAP) $(INST_BOOT)
-       $(CHMOD) $(PERM_RW) $@
+$(INST_BOOT) : $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists
+       $(NOECHO) $(RM_RF) %s
+       - $(CP) $(BOOTSTRAP) %s
+       $(CHMOD) $(PERM_RW) %s
 MAKE_FRAG
 }
 
@@ -1087,10 +896,10 @@ sub dynamic_lib {
     my($inst_dynamic_dep) = $attribs{INST_DYNAMIC_DEP} || "";
     my($armaybe) = $attribs{ARMAYBE} || $self->{ARMAYBE} || ":";
     my($ldfrom) = '$(LDFROM)';
-    $armaybe = 'ar' if ($Is_OSF and $armaybe eq ':');
+    $armaybe = 'ar' if ($Is{OSF} and $armaybe eq ':');
     my(@m);
-    my $ld_opt = $Is_OS2 ? '$(OPTIMIZE) ' : '';        # Useful on other systems too?
-    my $ld_fix = $Is_OS2 ? '|| ( $(RM_F) $@ && sh -c false )' : '';
+    my $ld_opt = $Is{OS2} ? '$(OPTIMIZE) ' : '';       # Useful on other systems too?
+    my $ld_fix = $Is{OS2} ? '|| ( $(RM_F) $@ && sh -c false )' : '';
     push(@m,'
 # This section creates the dynamically loadable $(INST_DYNAMIC)
 # from $(OBJECT) and possibly $(MYEXTLIB).
@@ -1099,17 +908,17 @@ OTHERLDFLAGS = '.$ld_opt.$otherldflags.'
 INST_DYNAMIC_DEP = '.$inst_dynamic_dep.'
 INST_DYNAMIC_FIX = '.$ld_fix.'
 
-$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
+$(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DFSEP).exists $(EXPORT_LIST) $(PERL_ARCHIVE) $(PERL_ARCHIVE_AFTER) $(INST_DYNAMIC_DEP)
 ');
     if ($armaybe ne ':'){
        $ldfrom = 'tmp$(LIB_EXT)';
        push(@m,'       $(ARMAYBE) cr '.$ldfrom.' $(OBJECT)'."\n");
        push(@m,'       $(RANLIB) '."$ldfrom\n");
     }
-    $ldfrom = "-all $ldfrom -none" if $Is_OSF;
+    $ldfrom = "-all $ldfrom -none" if $Is{OSF};
 
     # The IRIX linker doesn't use LD_RUN_PATH
-    my $ldrun = $Is_IRIX && $self->{LD_RUN_PATH} ?         
+    my $ldrun = $Is{IRIX} && $self->{LD_RUN_PATH} ?         
                        qq{-rpath "$self->{LD_RUN_PATH}"} : '';
 
     # For example in AIX the shared objects/libraries from previous builds
@@ -1122,29 +931,34 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)$(DIRFILE
 
     my $libs = '$(LDLOADLIBS)';
 
-    if ($Is_NetBSD) {
+    if (($Is{NetBSD} || $Is{Interix}) && $Config{'useshrplib'} eq 'true') {
        # Use nothing on static perl platforms, and to the flags needed
        # to link against the shared libperl library on shared perl
        # platforms.  We peek at lddlflags to see if we need -Wl,-R
        # or -R to add paths to the run-time library search path.
-       if ($Config{'useshrplib'}) {
-           if ($Config{'lddlflags'} =~ /-Wl,-R/) {
-               $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -lperl';
-           } elsif ($Config{'lddlflags'} =~ /-R/) {
-               $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -lperl';
-           }
-       }
+        if ($Config{'lddlflags'} =~ /-Wl,-R/) {
+            $libs .= ' -L$(PERL_INC) -Wl,-R$(INSTALLARCHLIB)/CORE -Wl,-R$(PERL_ARCHLIB)/CORE -lperl';
+        } elsif ($Config{'lddlflags'} =~ /-R/) {
+            $libs .= ' -L$(PERL_INC) -R$(INSTALLARCHLIB)/CORE -R$(PERL_ARCHLIB)/CORE -lperl';
+        }
     }
 
-    push(@m,
-'      LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
-' $(OTHERLDFLAGS) -o $@ $(MYEXTLIB) $(PERL_ARCHIVE) '.$libs.' $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST) $(INST_DYNAMIC_FIX)');
-    push @m, '
+    my $ld_run_path_shell = "";
+    if ($self->{LD_RUN_PATH} ne "") {
+       $ld_run_path_shell = 'LD_RUN_PATH="$(LD_RUN_PATH)" ';
+    }
+
+    push @m, sprintf <<'MAKE', $ld_run_path_shell, $ldrun, $ldfrom, $libs;
+       %s$(LD) %s $(LDDLFLAGS) %s $(OTHERLDFLAGS) -o $@ $(MYEXTLIB)    \
+         $(PERL_ARCHIVE) %s $(PERL_ARCHIVE_AFTER) $(EXPORT_LIST)       \
+         $(INST_DYNAMIC_FIX)
+MAKE
+
+    push @m, <<'MAKE';
        $(CHMOD) $(PERM_RWX) $@
-';
+MAKE
 
-    push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
-    join('',@m);
+    return join('',@m);
 }
 
 =item exescan
@@ -1179,7 +993,7 @@ Finds the executables PERL and FULLPERL
 
 sub find_perl {
     my($self, $ver, $names, $dirs, $trace) = @_;
-    my($name, $dir);
+
     if ($trace >= 2){
         print "Looking for perl $ver by these names:
 @$names
@@ -1190,8 +1004,10 @@ in these dirs:
 
     my $stderr_duped = 0;
     local *STDERR_COPY;
-    unless ($Is_BSD) {
-        if( open(STDERR_COPY, '>&STDERR') ) {
+
+    unless ($Is{BSD}) {
+        # >& and lexical filehandles together give 5.6.2 indigestion
+        if( open(STDERR_COPY, '>&STDERR') ) {  ## no critic
             $stderr_duped = 1;
         }
         else {
@@ -1202,8 +1018,8 @@ WARNING
         }
     }
 
-    foreach $name (@$names){
-        foreach $dir (@$dirs){
+    foreach my $name (@$names){
+        foreach my $dir (@$dirs){
             next unless defined $dir; # $self->{PERL_SRC} may be undefined
             my ($abs, $val);
             if ($self->file_name_is_absolute($name)) {     # /foo/bar
@@ -1218,26 +1034,32 @@ WARNING
             next unless $self->maybe_command($abs);
             print "Executing $abs\n" if ($trace >= 2);
 
-            my $version_check = qq{$abs -e "require $ver; print qq{VER_OK\n}"};
-            # To avoid using the unportable 2>&1 to supress STDERR,
+            my $version_check = qq{$abs -le "require $ver; print qq{VER_OK}"};
+            $version_check = "$Config{run} $version_check"
+                if defined $Config{run} and length $Config{run};
+
+            # To avoid using the unportable 2>&1 to suppress STDERR,
             # we close it before running the command.
             # However, thanks to a thread library bug in many BSDs
             # ( http://www.freebsd.org/cgi/query-pr.cgi?pr=51535 )
             # we cannot use the fancier more portable way in here
             # but instead need to use the traditional 2>&1 construct.
-            if ($Is_BSD) {
+            if ($Is{BSD}) {
                 $val = `$version_check 2>&1`;
             } else {
                 close STDERR if $stderr_duped;
                 $val = `$version_check`;
-                open STDERR, '>&STDERR_COPY' if $stderr_duped;
+
+                # 5.6.2's 3-arg open doesn't work with >&
+                open STDERR, ">&STDERR_COPY"  ## no critic
+                        if $stderr_duped;
             }
 
-            if ($val =~ /^VER_OK/) {
+            if ($val =~ /^VER_OK/m) {
                 print "Using PERL=$abs\n" if $trace;
                 return $abs;
             } elsif ($trace >= 2) {
-                print "Result: '$val'\n";
+                print "Result: '$val' ".($? >> 8)."\n";
             }
         }
     }
@@ -1245,28 +1067,6 @@ WARNING
     0; # false and not empty
 }
 
-=item find_tests
-
-  my $test = $mm->find_tests;
-
-Returns a string suitable for feeding to the shell to return all
-tests in t/*.t.
-
-=cut
-
-sub find_tests {
-    my($self) = shift;
-    return 't/*.t';
-}
-
-=back
-
-=head2 Methods to actually produce chunks of text for the Makefile
-
-The methods here are called for each MakeMaker object in the order
-specified by @ExtUtils::MakeMaker::MM_Sections.
-
-=over 2
 
 =item fixin
 
@@ -1276,108 +1076,130 @@ Inserts the sharpbang or equivalent magic number to a set of @files.
 
 =cut
 
-sub fixin { # stolen from the pink Camel book, more or less
-    my($self, @files) = @_;
+sub fixin {    # stolen from the pink Camel book, more or less
+    my ( $self, @files ) = @_;
 
-    my($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
+    my ($does_shbang) = $Config{'sharpbang'} =~ /^\s*\#\!/;
     for my $file (@files) {
         my $file_new = "$file.new";
         my $file_bak = "$file.bak";
 
-       local(*FIXIN);
-       local(*FIXOUT);
-       open(FIXIN, $file) or croak "Can't process '$file': $!";
-       local $/ = "\n";
-       chomp(my $line = <FIXIN>);
-       next unless $line =~ s/^\s*\#!\s*//;     # Not a shbang file.
-       # Now figure out the interpreter name.
-       my($cmd,$arg) = split ' ', $line, 2;
-       $cmd =~ s!^.*/!!;
-
-       # Now look (in reverse) for interpreter in absolute PATH (unless perl).
+        open( my $fixin, '<', $file ) or croak "Can't process '$file': $!";
+        local $/ = "\n";
+        chomp( my $line = <$fixin> );
+        next unless $line =~ s/^\s*\#!\s*//;    # Not a shbang file.
+        # Now figure out the interpreter name.
+        my ( $cmd, $arg ) = split ' ', $line, 2;
+        $cmd =~ s!^.*/!!;
+
+        # Now look (in reverse) for interpreter in absolute PATH (unless perl).
         my $interpreter;
-       if ($cmd eq "perl") {
-            if ($Config{startperl} =~ m,^\#!.*/perl,) {
+        if ( $cmd eq "perl" ) {
+            if ( $Config{startperl} =~ m,^\#!.*/perl, ) {
                 $interpreter = $Config{startperl};
                 $interpreter =~ s,^\#!,,;
-            } else {
+            }
+            else {
                 $interpreter = $Config{perlpath};
             }
-       } else {
-           my(@absdirs) = reverse grep {$self->file_name_is_absolute} $self->path;
-           $interpreter = '';
-           my($dir);
-           foreach $dir (@absdirs) {
-               if ($self->maybe_command($cmd)) {
-                   warn "Ignoring $interpreter in $file\n" if $Verbose && $interpreter;
-                   $interpreter = $self->catfile($dir,$cmd);
-               }
-           }
-       }
-       # Figure out how to invoke interpreter on this machine.
-
-       my($shb) = "";
-       if ($interpreter) {
-           print STDOUT "Changing sharpbang in $file to $interpreter" if $Verbose;
-           # this is probably value-free on DOSISH platforms
-           if ($does_shbang) {
-               $shb .= "$Config{'sharpbang'}$interpreter";
-               $shb .= ' ' . $arg if defined $arg;
-               $shb .= "\n";
-           }
-           $shb .= qq{
+        }
+        else {
+            my (@absdirs)
+                = reverse grep { $self->file_name_is_absolute } $self->path;
+            $interpreter = '';
+
+            foreach my $dir (@absdirs) {
+                if ( $self->maybe_command($cmd) ) {
+                    warn "Ignoring $interpreter in $file\n"
+                        if $Verbose && $interpreter;
+                    $interpreter = $self->catfile( $dir, $cmd );
+                }
+            }
+        }
+
+        # Figure out how to invoke interpreter on this machine.
+
+        my ($shb) = "";
+        if ($interpreter) {
+            print STDOUT "Changing sharpbang in $file to $interpreter"
+                if $Verbose;
+
+            # this is probably value-free on DOSISH platforms
+            if ($does_shbang) {
+                $shb .= "$Config{'sharpbang'}$interpreter";
+                $shb .= ' ' . $arg if defined $arg;
+                $shb .= "\n";
+            }
+            $shb .= qq{
 eval 'exec $interpreter $arg -S \$0 \${1+"\$\@"}'
     if 0; # not running under some shell
-} unless $Is_Win32; # this won't work on win32, so don't
-       } else {
-           warn "Can't find $cmd in PATH, $file unchanged"
-               if $Verbose;
-           next;
-       }
+} unless $Is{Win32};    # this won't work on win32, so don't
+        }
+        else {
+            warn "Can't find $cmd in PATH, $file unchanged"
+                if $Verbose;
+            next;
+        }
 
-       unless ( open(FIXOUT,">$file_new") ) {
-           warn "Can't create new $file: $!\n";
-           next;
-       }
-       
-       # Print out the new #! line (or equivalent).
-       local $\;
-       undef $/;
-       print FIXOUT $shb, <FIXIN>;
-       close FIXIN;
-       close FIXOUT;
+        open( my $fixout, ">", "$file_new" ) or do {
+            warn "Can't create new $file: $!\n";
+            next;
+        };
+
+        # Print out the new #! line (or equivalent).
+        local $\;
+        local $/;
+        print $fixout $shb, <$fixin>;
+        close $fixin;
+        close $fixout;
 
         chmod 0666, $file_bak;
         unlink $file_bak;
-       unless ( rename($file, $file_bak) ) {   
-           warn "Can't rename $file to $file_bak: $!";
-           next;
-       }
-       unless ( rename($file_new, $file) ) {   
-           warn "Can't rename $file_new to $file: $!";
-           unless ( rename($file_bak, $file) ) {
-               warn "Can't rename $file_bak back to $file either: $!";
-               warn "Leaving $file renamed as $file_bak\n";
-           }
-           next;
-       }
-       unlink $file_bak;
-    } continue {
-       close(FIXIN) if fileno(FIXIN);
-       system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
+        unless ( _rename( $file, $file_bak ) ) {
+            warn "Can't rename $file to $file_bak: $!";
+            next;
+        }
+        unless ( _rename( $file_new, $file ) ) {
+            warn "Can't rename $file_new to $file: $!";
+            unless ( _rename( $file_bak, $file ) ) {
+                warn "Can't rename $file_bak back to $file either: $!";
+                warn "Leaving $file renamed as $file_bak\n";
+            }
+            next;
+        }
+        unlink $file_bak;
+    }
+    continue {
+        system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
     }
 }
 
+
+sub _rename {
+    my($old, $new) = @_;
+
+    foreach my $file ($old, $new) {
+        if( $Is{VMS} and basename($file) !~ /\./ ) {
+            # rename() in 5.8.0 on VMS will not rename a file if it
+            # does not contain a dot yet it returns success.
+            $file = "$file.";
+        }
+    }
+
+    return rename($old, $new);
+}
+
+
 =item force (o)
 
-Just writes FORCE:
+Writes an empty FORCE: target.
 
 =cut
 
 sub force {
     my($self) = shift;
     '# Phony target to force checking subdirectories.
-FORCE:
+FORCE :
        $(NOECHO) $(NOOP)
 ';
 }
@@ -1424,8 +1246,8 @@ sub has_link_code {
 
 =item init_dirscan
 
-Scans the directory structure and initializes DIR, XS, XS_FILES, PM,
-C, C_FILES, O_FILES, H, H_FILES, PL_FILES, MAN*PODS, EXE_FILES.
+Scans the directory structure and initializes DIR, XS, XS_FILES,
+C, C_FILES, O_FILES, H, H_FILES, PL_FILES, EXE_FILES.
 
 Called by init_main.
 
@@ -1433,18 +1255,17 @@ Called by init_main.
 
 sub init_dirscan {     # --- File and Directory Lists (.xs .pm .pod etc)
     my($self) = @_;
-    my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
-    my %pm;
+    my(%dir, %xs, %c, %h, %pl_files, %pm);
 
-    @ignore{qw(Makefile.PL test.pl t)} = (1,1,1);
+    my %ignore = map {( $_ => 1 )} qw(Makefile.PL Build.PL test.pl t);
 
     # ignore the distdir
-    $Is_VMS ? $ignore{"$self->{DISTVNAME}.dir"} = 1
+    $Is{VMS} ? $ignore{"$self->{DISTVNAME}.dir"} = 1
             : $ignore{$self->{DISTVNAME}} = 1;
 
-    @ignore{map lc, keys %ignore} = values %ignore if $Is_VMS;
+    @ignore{map lc, keys %ignore} = values %ignore if $Is{VMS};
 
-    foreach $name ($self->lsdir($Curdir)){
+    foreach my $name ($self->lsdir($Curdir)){
        next if $name =~ /\#/;
        next if $name eq $Curdir or $name eq $Updir or $ignore{$name};
        next unless $self->libscan($name);
@@ -1463,10 +1284,10 @@ sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
            $h{$name} = 1;
        } elsif ($name =~ /\.PL\z/) {
            ($pl_files{$name} = $name) =~ s/\.PL\z// ;
-       } elsif (($Is_VMS || $Is_Dos) && $name =~ /[._]pl$/i) {
+       } elsif (($Is{VMS} || $Is{Dos}) && $name =~ /[._]pl$/i) {
            # case-insensitive filesystem, one dot per name, so foo.h.PL
            # under Unix appears as foo.h_pl under VMS or fooh.pl on Dos
-           local($/); open(PL,$name); my $txt = <PL>; close PL;
+           local($/); open(my $pl, '<', $name); my $txt = <$pl>; close $pl;
            if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
                ($pl_files{$name} = $name) =~ s/[._]pl\z//i ;
            }
@@ -1478,6 +1299,141 @@ sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
        }
     }
 
+    $self->{PL_FILES}   ||= \%pl_files;
+    $self->{DIR}        ||= [sort keys %dir];
+    $self->{XS}         ||= \%xs;
+    $self->{C}          ||= [sort keys %c];
+    $self->{H}          ||= [sort keys %h];
+    $self->{PM}         ||= \%pm;
+
+    my @o_files = @{$self->{C}};
+    $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
+}
+
+
+=item init_MANPODS
+
+Determines if man pages should be generated and initializes MAN1PODS
+and MAN3PODS as appropriate.
+
+=cut
+
+sub init_MANPODS {
+    my $self = shift;
+
+    # Set up names of manual pages to generate from pods
+    foreach my $man (qw(MAN1 MAN3)) {
+       if ( $self->{"${man}PODS"}
+             or $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/
+        ) {
+            $self->{"${man}PODS"} ||= {};
+        }
+        else {
+            my $init_method = "init_${man}PODS";
+            $self->$init_method();
+       }
+    }
+}
+
+
+sub _has_pod {
+    my($self, $file) = @_;
+
+    my($ispod)=0;
+    if (open( my $fh, '<', $file )) {
+        while (<$fh>) {
+            if (/^=(?:head\d+|item|pod)\b/) {
+                $ispod=1;
+                last;
+            }
+        }
+        close $fh;
+    } else {
+        # If it doesn't exist yet, we assume, it has pods in it
+        $ispod = 1;
+    }
+
+    return $ispod;
+}
+
+
+=item init_MAN1PODS
+
+Initializes MAN1PODS from the list of EXE_FILES.
+
+=cut
+
+sub init_MAN1PODS {
+    my($self) = @_;
+
+    if ( exists $self->{EXE_FILES} ) {
+       foreach my $name (@{$self->{EXE_FILES}}) {
+           next unless $self->_has_pod($name);
+
+           $self->{MAN1PODS}->{$name} =
+               $self->catfile("\$(INST_MAN1DIR)", 
+                              basename($name).".\$(MAN1EXT)");
+       }
+    }
+}
+
+
+=item init_MAN3PODS
+
+Initializes MAN3PODS from the list of PM files.
+
+=cut
+
+sub init_MAN3PODS {
+    my $self = shift;
+
+    my %manifypods = (); # we collect the keys first, i.e. the files
+                         # we have to convert to pod
+
+    foreach my $name (keys %{$self->{PM}}) {
+       if ($name =~ /\.pod\z/ ) {
+           $manifypods{$name} = $self->{PM}{$name};
+       } elsif ($name =~ /\.p[ml]\z/ ) {
+           if( $self->_has_pod($name) ) {
+               $manifypods{$name} = $self->{PM}{$name};
+           }
+       }
+    }
+
+    my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
+
+    # Remove "Configure.pm" and similar, if it's not the only pod listed
+    # To force inclusion, just name it "Configure.pod", or override 
+    # MAN3PODS
+    foreach my $name (keys %manifypods) {
+       if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
+           delete $manifypods{$name};
+           next;
+       }
+       my($manpagename) = $name;
+       $manpagename =~ s/\.p(od|m|l)\z//;
+       # everything below lib is ok
+       unless($manpagename =~ s!^\W*($parentlibs_re)\W+!!s) {
+           $manpagename = $self->catfile(
+               split(/::/,$self->{PARENT_NAME}),$manpagename
+           );
+       }
+       $manpagename = $self->replace_manpage_separator($manpagename);
+       $self->{MAN3PODS}->{$name} =
+           $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
+    }
+}
+
+
+=item init_PM
+
+Initializes PMLIBDIRS and PM from PMLIBDIRS.
+
+=cut
+
+sub init_PM {
+    my $self = shift;
+
     # Some larger extensions often wish to install a number of *.pm/pl
     # files into the library in various locations.
 
@@ -1505,7 +1461,7 @@ sub init_dirscan {        # --- File and Directory Lists (.xs .pm .pod etc)
     # that's important for nested modules.
 
     unless( $self->{PMLIBDIRS} ) {
-        if( $Is_VMS ) {
+        if( $Is{VMS} ) {
             # Avoid logical name vs directory collisions
             $self->{PMLIBDIRS} = ['./lib', "./$self->{BASEEXT}"];
         }
@@ -1519,12 +1475,18 @@ sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
     # Avoid $_ wherever possible:
     # @{$self->{PMLIBDIRS}} = grep -d && !$dir{$_}, @{$self->{PMLIBDIRS}};
     my (@pmlibdirs) = @{$self->{PMLIBDIRS}};
-    my ($pmlibdir);
     @{$self->{PMLIBDIRS}} = ();
-    foreach $pmlibdir (@pmlibdirs) {
+    my %dir = map { ($_ => $_) } @{$self->{DIR}};
+    foreach my $pmlibdir (@pmlibdirs) {
        -d $pmlibdir && !$dir{$pmlibdir} && push @{$self->{PMLIBDIRS}}, $pmlibdir;
     }
 
+    unless( $self->{PMLIBPARENTDIRS} ) {
+       @{$self->{PMLIBPARENTDIRS}} = ('lib');
+    }
+
+    return if $self->{PM} and $self->{ARGS}{PM};
+
     if (@{$self->{PMLIBDIRS}}){
        print "Searching PMLIBDIRS: @{$self->{PMLIBDIRS}}\n"
            if ($Verbose >= 2);
@@ -1544,116 +1506,22 @@ sub init_dirscan {     # --- File and Directory Lists (.xs .pm .pod etc)
             my $prefix = $self->{INST_LIBDIR};
             my $striplibpath;
 
+           my $parentlibs_re = join '|', @{$self->{PMLIBPARENTDIRS}};
            $prefix =  $self->{INST_LIB} 
-                if ($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i;
+                if ($striplibpath = $path) =~ s{^(\W*)($parentlibs_re)\W}
+                                              {$1}i;
 
            my($inst) = $self->catfile($prefix,$striplibpath);
            local($_) = $inst; # for backwards compatibility
            $inst = $self->libscan($inst);
            print "libscan($path) => '$inst'\n" if ($Verbose >= 2);
            return unless $inst;
-           $pm{$path} = $inst;
+           $self->{PM}{$path} = $inst;
        }, @{$self->{PMLIBDIRS}});
     }
-
-    $self->{PM}  ||= \%pm;
-    $self->{PL_FILES} ||= \%pl_files;
-
-    $self->{DIR} ||= [sort keys %dir];
-
-    $self->{XS}  ||= \%xs;
-    $self->{C}   ||= [sort keys %c];
-    my @o_files = @{$self->{C}};
-    $self->{O_FILES} = [grep s/\.c(pp|xx|c)?\z/$self->{OBJ_EXT}/i, @o_files];
-                            
-    $self->{H}   ||= [sort keys %h];
-
-    # Set up names of manual pages to generate from pods
-    my %pods;
-    foreach my $man (qw(MAN1 MAN3)) {
-       unless ($self->{"${man}PODS"}) {
-           $self->{"${man}PODS"} = {};
-           $pods{$man} = 1 unless 
-              $self->{"INSTALL${man}DIR"} =~ /^(none|\s*)$/;
-       }
-    }
-
-    if ($pods{MAN1}) {
-       if ( exists $self->{EXE_FILES} ) {
-           foreach $name (@{$self->{EXE_FILES}}) {
-               local *FH;
-               my($ispod)=0;
-               if (open(FH,"<$name")) {
-                   while (<FH>) {
-                       if (/^=(?:head\d+|item|pod)\b/) {
-                           $ispod=1;
-                           last;
-                       }
-                   }
-                   close FH;
-               } else {
-                   # If it doesn't exist yet, we assume, it has pods in it
-                   $ispod = 1;
-               }
-               next unless $ispod;
-               if ($pods{MAN1}) {
-                   $self->{MAN1PODS}->{$name} =
-                     $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");
-               }
-           }
-       }
-    }
-    if ($pods{MAN3}) {
-       my %manifypods = (); # we collect the keys first, i.e. the files
-                            # we have to convert to pod
-       foreach $name (keys %{$self->{PM}}) {
-           if ($name =~ /\.pod\z/ ) {
-               $manifypods{$name} = $self->{PM}{$name};
-           } elsif ($name =~ /\.p[ml]\z/ ) {
-               local *FH;
-               my($ispod)=0;
-               if (open(FH,"<$name")) {
-                   while (<FH>) {
-                       if (/^=head1\s+\w+/) {
-                           $ispod=1;
-                           last;
-                       }
-                   }
-                   close FH;
-               } else {
-                   $ispod = 1;
-               }
-               if( $ispod ) {
-                   $manifypods{$name} = $self->{PM}{$name};
-               }
-           }
-       }
-
-       # Remove "Configure.pm" and similar, if it's not the only pod listed
-       # To force inclusion, just name it "Configure.pod", or override 
-        # MAN3PODS
-       foreach $name (keys %manifypods) {
-           if ($self->{PERL_CORE} and $name =~ /(config|setup).*\.pm/is) {
-               delete $manifypods{$name};
-               next;
-           }
-           my($manpagename) = $name;
-           $manpagename =~ s/\.p(od|m|l)\z//;
-           # everything below lib is ok
-           unless($manpagename =~ s!^\W*lib\W+!!s) {
-               $manpagename = $self->catfile(
-                                split(/::/,$self->{PARENT_NAME}),$manpagename
-                               );
-           }
-           if ($pods{MAN3}) {
-               $manpagename = $self->replace_manpage_separator($manpagename);
-               $self->{MAN3PODS}->{$name} =
-                 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
-           }
-       }
-    }
 }
 
+
 =item init_DIRFILESEP
 
 Using / for Unix.  Called by init_main.
@@ -1671,7 +1539,7 @@ sub init_DIRFILESEP {
 
 Initializes AR, AR_STATIC_ARGS, BASEEXT, CONFIG, DISTNAME, DLBASE,
 EXE_EXT, FULLEXT, FULLPERL, FULLPERLRUN, FULLPERLRUNINST, INST_*,
-INSTALL*, INSTALLDIRS, LD, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
+INSTALL*, INSTALLDIRS, LIB_EXT, LIBPERL_A, MAP_TARGET, NAME,
 OBJ_EXT, PARENT_NAME, PERL, PERL_ARCHLIB, PERL_INC, PERL_LIB,
 PERL_SRC, PERLRUN, PERLRUNINST, PREFIX, VERSION,
 VERSION_SYM, XS_VERSION.
@@ -1723,24 +1591,17 @@ sub init_main {
     my $inc_carp_dir   = dirname($INC{'Carp.pm'});
 
     unless ($self->{PERL_SRC}){
-       my($dir);
-       foreach $dir ($Updir,
-                  $self->catdir($Updir,$Updir),
-                  $self->catdir($Updir,$Updir,$Updir),
-                  $self->catdir($Updir,$Updir,$Updir,$Updir),
-                  $self->catdir($Updir,$Updir,$Updir,$Updir,$Updir))
-        {
-           if (
-               -f $self->catfile($dir,"config_h.SH")
-               &&
-               -f $self->catfile($dir,"perl.h")
-               &&
-               -f $self->catfile($dir,"lib","Exporter.pm")
-              ) {
-               $self->{PERL_SRC}=$dir ;
-               last;
-           }
-       }
+        foreach my $dir_count (1..8) { # 8 is the VMS limit for nesting
+            my $dir = $self->catdir(($Updir) x $dir_count);
+
+            if (-f $self->catfile($dir,"config_h.SH")   &&
+                -f $self->catfile($dir,"perl.h")        &&
+                -f $self->catfile($dir,"lib","strict.pm")
+            ) {
+                $self->{PERL_SRC}=$dir ;
+                last;
+            }
+        }
     }
 
     warn "PERL_CORE is set but I can't find your PERL_SRC!\n" if
@@ -1754,11 +1615,11 @@ sub init_main {
               $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform);
             $self->{PERL_INC}     = 
               $self->catdir("$self->{PERL_SRC}","xlib",$Cross::platform, 
-                                 $Is_Win32?("CORE"):());
+                                 $Is{Win32}?("CORE"):());
         }
         else {
             $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
-            $self->{PERL_INC}     = ($Is_Win32) ? 
+            $self->{PERL_INC}     = ($Is{Win32}) ? 
               $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
         }
 
@@ -1766,13 +1627,11 @@ sub init_main {
        unless (
                -s $self->catfile($self->{PERL_SRC},'cflags')
                or
-               $Is_VMS
+               $Is{VMS}
                &&
                -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
                or
-               $Is_Mac
-               or
-               $Is_Win32
+               $Is{Win32}
               ){
            warn qq{
 You cannot build extensions below the perl source tree after executing
@@ -1800,41 +1659,26 @@ from the perl source tree.
            and not $old){
            # Maybe somebody tries to build an extension with an
            # uninstalled Perl outside of Perl build tree
-           my $found;
+           my $lib;
            for my $dir (@INC) {
-             $found = $dir, last if -e $self->catdir($dir, "Config.pm");
+             $lib = $dir, last if -e $self->catdir($dir, "Config.pm");
            }
-           if ($found) {
-             my $inc = dirname $found;
+           if ($lib) {
+              # Win32 puts its header files in /perl/src/lib/CORE.
+              # Unix leaves them in /perl/src.
+             my $inc = $Is{Win32} ? $self->catdir($lib, "CORE" )
+                                  : dirname $lib;
              if (-e $self->catdir($inc, "perl.h")) {
-               $self->{PERL_LIB}          = $found;
-               $self->{PERL_ARCHLIB}      = $found;
+               $self->{PERL_LIB}          = $lib;
+               $self->{PERL_ARCHLIB}      = $lib;
                $self->{PERL_INC}          = $inc;
                $self->{UNINSTALLED_PERL}  = 1;
                print STDOUT <<EOP;
 ... Detected uninstalled Perl.  Trying to continue.
 EOP
              }
-           }
-       }
-       
-       unless(-f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h")))
-        {
-           die qq{
-Error: Unable to locate installed Perl libraries or Perl source code.
-
-It is recommended that you install perl in a standard location before
-building extensions. Some precompiled versions of perl do not contain
-these header files, so you cannot build extensions. In such a case,
-please build and install your perl from a fresh perl distribution. It
-usually solves this kind of problem.
-
-\(You get this message, because MakeMaker could not find "$perl_h"\)
-};
-       }
-#       print STDOUT "Using header files found in $self->{PERL_INC}\n"
-#           if $Verbose && $self->needs_linking();
-
+           }
+       }       
     }
 
     # We get SITELIBEXP and SITEARCHEXP directly via
@@ -1849,17 +1693,17 @@ usually solves this kind of problem.
 
     # Get some stuff out of %Config if we haven't yet done so
     print STDOUT "CONFIG must be an array ref\n"
-       if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
+        if ($self->{CONFIG} and ref $self->{CONFIG} ne 'ARRAY');
     $self->{CONFIG} = [] unless (ref $self->{CONFIG});
     push(@{$self->{CONFIG}}, @ExtUtils::MakeMaker::Get_from_Config);
     push(@{$self->{CONFIG}}, 'shellflags') if $Config{shellflags};
     my(%once_only);
     foreach my $m (@{$self->{CONFIG}}){
-       next if $once_only{$m};
-       print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
-               unless exists $Config{$m};
-       $self->{uc $m} ||= $Config{$m};
-       $once_only{$m} = 1;
+        next if $once_only{$m};
+        print STDOUT "CONFIG key '$m' does not exist in Config.pm\n"
+                unless exists $Config{$m};
+        $self->{uc $m} ||= $Config{$m};
+        $once_only{$m} = 1;
     }
 
 # This is too dangerous:
@@ -1872,7 +1716,6 @@ usually solves this kind of problem.
     $self->{AR_STATIC_ARGS} ||= "cr";
 
     # These should never be needed
-    $self->{LD} ||= 'ld';
     $self->{OBJ_EXT} ||= '.o';
     $self->{LIB_EXT} ||= '.a';
 
@@ -1880,16 +1723,16 @@ usually solves this kind of problem.
 
     $self->{LIBPERL_A} ||= "libperl$self->{LIB_EXT}";
 
-    # make a simple check if we find Exporter
+    # make a simple check if we find strict
     warn "Warning: PERL_LIB ($self->{PERL_LIB}) seems not to be a perl library directory
-        (Exporter.pm not found)"
-       unless -f $self->catfile("$self->{PERL_LIB}","Exporter.pm") ||
-        $self->{NAME} eq "ExtUtils::MakeMaker";
+        (strict.pm not found)"
+        unless -f $self->catfile("$self->{PERL_LIB}","strict.pm") ||
+               $self->{NAME} eq "ExtUtils::MakeMaker";
 }
 
 =item init_others
 
-Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH,
+Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
 FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
 TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
@@ -1899,6 +1742,8 @@ TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
 sub init_others {      # --- Initialize Other Attributes
     my($self) = shift;
 
+    $self->{LD} ||= 'ld';
+
     # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
     # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
     # undefined. In any case we turn it into an anon array:
@@ -1908,8 +1753,8 @@ sub init_others { # --- Initialize Other Attributes
 
     $self->{LIBS} = [''] unless @{$self->{LIBS}} && defined $self->{LIBS}[0];
     $self->{LD_RUN_PATH} = "";
-    my($libs);
-    foreach $libs ( @{$self->{LIBS}} ){
+
+    foreach my $libs ( @{$self->{LIBS}} ){
        $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
        my(@libs) = $self->extliblist($libs);
        if ($libs[0] or $libs[1] or $libs[2]){
@@ -1945,10 +1790,18 @@ sub init_others {       # --- Initialize Other Attributes
     $self->{NOOP}               ||= '$(SHELL) -c true';
     $self->{NOECHO}             = '@' unless defined $self->{NOECHO};
 
-    $self->{MAKEFILE}           ||= 'Makefile';
-    $self->{FIRST_MAKEFILE}     ||= $self->{MAKEFILE};
-    $self->{MAKEFILE_OLD}       ||= '$(FIRST_MAKEFILE).old';
-    $self->{MAKE_APERL_FILE}    ||= '$(FIRST_MAKEFILE).aperl';
+    $self->{FIRST_MAKEFILE}     ||= $self->{MAKEFILE} || 'Makefile';
+    $self->{MAKEFILE}           ||= $self->{FIRST_MAKEFILE};
+    $self->{MAKEFILE_OLD}       ||= $self->{MAKEFILE}.'.old';
+    $self->{MAKE_APERL_FILE}    ||= $self->{MAKEFILE}.'.aperl';
+
+    # Some makes require a wrapper around macros passed in on the command 
+    # line.
+    $self->{MACROSTART}         ||= '';
+    $self->{MACROEND}           ||= '';
+
+    # Not everybody uses -f to indicate "use this Makefile instead"
+    $self->{USEMAKEFILE}        ||= '-f';
 
     $self->{SHELL}              ||= $Config{sh} || '/bin/sh';
 
@@ -1961,9 +1814,9 @@ sub init_others { # --- Initialize Other Attributes
     $self->{CP}         ||= "cp";
     $self->{MV}         ||= "mv";
     $self->{CHMOD}      ||= "chmod";
-    $self->{MKPATH}     ||= '$(PERLRUN) "-MExtUtils::Command" -e mkpath';
+    $self->{MKPATH}     ||= '$(ABSPERLRUN) "-MExtUtils::Command" -e mkpath';
     $self->{EQUALIZE_TIMESTAMP} ||= 
-      '$(PERLRUN) "-MExtUtils::Command" -e eqtime';
+      '$(ABSPERLRUN) "-MExtUtils::Command" -e eqtime';
 
     $self->{UNINST}     ||= 0;
     $self->{VERBINST}   ||= 0;
@@ -1971,12 +1824,14 @@ sub init_others {       # --- Initialize Other Attributes
       $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
 install({@ARGV}, '$(VERBINST)', 0, '$(UNINST)');
 CODE
-    $self->{DOC_INSTALL} ||= 
-      '$(PERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
-    $self->{UNINSTALL}   ||= 
-      '$(PERLRUN) "-MExtUtils::Command::MM" -e uninstall';
+    $self->{DOC_INSTALL}        ||= 
+      '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e perllocal_install';
+    $self->{UNINSTALL}          ||= 
+      '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e uninstall';
     $self->{WARN_IF_OLD_PACKLIST} ||= 
-      '$(PERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
+      '$(ABSPERLRUN) "-MExtUtils::Command::MM" -e warn_if_old_packlist';
+    $self->{FIXIN}              ||= 
+      q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
 
     $self->{UMASK_NULL}         ||= "umask 0";
     $self->{DEV_NULL}           ||= "> /dev/null 2>&1";
@@ -1984,255 +1839,6 @@ CODE
     return 1;
 }
 
-=item init_INST
-
-    $mm->init_INST;
-
-Called by init_main.  Sets up all INST_* variables except those related
-to XS code.  Those are handled in init_xs.
-
-=cut
-
-sub 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;
-}
-
-=item init_INSTALL
-
-    $mm->init_INSTALL;
-
-Called by init_main.  Sets up all INSTALL_* variables (except
-INSTALLDIRS) and *PREFIX.
-
-=cut
-
-sub init_INSTALL {
-    my($self) = shift;
-
-    $self->init_lib2arch;
-
-    # Initialize installvendorman*dir if necessary
-    foreach my $num (1, 3) {
-        my $k = 'installvendorman'.$num.'dir';
-
-        unless ($Config{$k}) {
-            $Config_Override{$k} = $Config{usevendorprefix} ?
-                  $self->catdir($Config{vendorprefixexp}, 'man', "man$num") :
-                  '';
-        }
-    }
-
-    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;
-
-    # There are often no Config.pm defaults for these, but we can make
-    # it up.
-    unless( $Config{installsiteman1dir} ) {
-        $Config_Override{installsiteman1dir} = 
-          $self->catdir($sprefix, 'man', 'man1');
-    }
-
-    unless( $Config{installsiteman3dir} ) {
-        $Config_Override{installsiteman3dir} = 
-          $self->catdir($sprefix, 'man', 'man3');
-    }
-
-    unless( $Config{installsitebin} ) {
-        $Config_Override{installsitebin} =
-          $self->catdir($sprefix, 'bin');
-    }
-
-    $self->{PREFIX}       ||= '';
-
-    if( $self->{PREFIX} ) {
-        @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
-          ('$(PREFIX)') x 3;
-    }
-    else {
-        $self->{PERLPREFIX}   ||= $iprefix;
-        $self->{SITEPREFIX}   ||= $sprefix;
-        $self->{VENDORPREFIX} ||= $vprefix;
-    }
-
-    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',
-                         d => 'bin' },
-        sitebin     => { s => $sprefix,
-                         t => 'site',
-                         d => 'bin' },
-        script      => { s => $iprefix,
-                         t => 'perl',
-                         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;
-}
 
 =item init_linker
 
@@ -2323,7 +1929,10 @@ sub init_PERL {
 
     # Build up a set of file names (not command names).
     my $thisperl = $self->canonpath($^X);
-    $thisperl .= $Config{exe_ext} unless $thisperl =~ m/$Config{exe_ext}$/i;
+    $thisperl .= $Config{exe_ext} unless 
+                # VMS might have a file version # at the end
+      $Is{VMS} ? $thisperl =~ m/$Config{exe_ext}(;\d+)?$/i
+              : $thisperl =~ m/$Config{exe_ext}$/i;
 
     # We need a relative path to perl when in the core.
     $thisperl = $self->abs2rel($thisperl) if $self->{PERL_CORE};
@@ -2347,8 +1956,15 @@ sub init_PERL {
     # don't check if perl is executable, maybe they have decided to
     # supply switches with perl
 
+    # When built for debugging, VMS doesn't create perl.exe but ndbgperl.exe.
+    my $perl_name = 'perl';
+    $perl_name = 'ndbgperl' if $Is{VMS} && 
+      defined $Config{usevmsdebug} && $Config{usevmsdebug} eq 'define';
+
+    # XXX This logic is flawed.  If "miniperl" is anywhere in the path
+    # it will get confused.  It should be fixed to work only on the filename.
     # Define 'FULLPERL' to be a non-miniperl (used in test: target)
-    ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/perl/i
+    ($self->{FULLPERL} = $self->{PERL}) =~ s/miniperl/$perl_name/i
        unless $self->{FULLPERL};
 
     # Little hack to get around VMS's find_perl putting "MCR" in front
@@ -2363,8 +1979,12 @@ sub init_PERL {
         $self->{ABSPERL} = 'MCR '.$self->{ABSPERL} if $has_mcr;
     }
 
+    $self->{ABSPERL} = qq{"$self->{ABSPERL}"}
+        if ($self->{ABSPERL} =~ /\s/) && ! $has_mcr;
+
     # Are we building the core?
-    $self->{PERL_CORE} = 0 unless exists $self->{PERL_CORE};
+    $self->{PERL_CORE} = $ENV{PERL_CORE} unless exists $self->{PERL_CORE};
+    $self->{PERL_CORE} = 0               unless defined $self->{PERL_CORE};
 
     # How do we run perl?
     foreach my $perl (qw(PERL FULLPERL ABSPERL)) {
@@ -2384,11 +2004,11 @@ sub init_PERL {
 }
 
 
-=item init_platform (o)
+=item init_platform
 
-Add MM_Unix_VERSION.
+=item platform_constants
 
-=item platform_constants (o)
+Add MM_Unix_VERSION.
 
 =cut
 
@@ -2472,16 +2092,22 @@ sub install {
 
     push @m, q{
 install :: all pure_install doc_install
+       $(NOECHO) $(NOOP)
 
 install_perl :: all pure_perl_install doc_perl_install
+       $(NOECHO) $(NOOP)
 
 install_site :: all pure_site_install doc_site_install
+       $(NOECHO) $(NOOP)
 
 install_vendor :: all pure_vendor_install doc_vendor_install
+       $(NOECHO) $(NOOP)
 
 pure_install :: pure_$(INSTALLDIRS)_install
+       $(NOECHO) $(NOOP)
 
 doc_install :: doc_$(INSTALLDIRS)_install
+       $(NOECHO) $(NOOP)
 
 pure__install : pure_site_install
        $(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
@@ -2510,7 +2136,7 @@ pure_site_install ::
                $(INST_LIB) $(DESTINSTALLSITELIB) \
                $(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
                $(INST_BIN) $(DESTINSTALLSITEBIN) \
-               $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
+               $(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
                $(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
                $(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
        $(NOECHO) $(WARN_IF_OLD_PACKLIST) \
@@ -2523,7 +2149,7 @@ pure_vendor_install ::
                $(INST_LIB) $(DESTINSTALLVENDORLIB) \
                $(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
                $(INST_BIN) $(DESTINSTALLVENDORBIN) \
-               $(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
+               $(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
                $(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
                $(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
 
@@ -2564,6 +2190,7 @@ doc_vendor_install ::
 
     push @m, q{
 uninstall :: uninstall_from_$(INSTALLDIRS)dirs
+       $(NOECHO) $(NOOP)
 
 uninstall_from_perldirs ::
        $(NOECHO) $(UNINSTALL) }.$self->catfile('$(PERL_ARCHLIB)','auto','$(FULLEXT)','.packlist').q{
@@ -2586,51 +2213,56 @@ Defines targets to make and to install EXE_FILES.
 
 sub installbin {
     my($self) = shift;
+
     return "" unless $self->{EXE_FILES} && ref $self->{EXE_FILES} eq "ARRAY";
-    return "" unless @{$self->{EXE_FILES}};
-    my(@m, $from, $to, %fromto, @to);
-    push @m, $self->dir_target(qw[$(INST_SCRIPT)]);
-    for $from (@{$self->{EXE_FILES}}) {
+    my @exefiles = @{$self->{EXE_FILES}};
+    return "" unless @exefiles;
+
+    @exefiles = map vmsify($_), @exefiles if $Is{VMS};
+
+    my %fromto;
+    for my $from (@exefiles) {
        my($path)= $self->catfile('$(INST_SCRIPT)', basename($from));
+
        local($_) = $path; # for backwards compatibility
-       $to = $self->libscan($path);
+       my $to = $self->libscan($path);
        print "libscan($from) => '$to'\n" if ($Verbose >=2);
-       $fromto{$from}=$to;
-    }
-    @to   = values %fromto;
 
-    my $fixin;
-    if( $Is_Win32 ) {
-        $fixin = $self->{PERL_CORE} ? '$(PERLRUN) ../../win32/bin/pl2bat.pl'
-                                    : 'pl2bat.bat';
-    }
-    else {
-        $fixin = q{$(PERLRUN) "-MExtUtils::MY" -e "MY->fixin(shift)"};
+        $to = vmsify($to) if $Is{VMS};
+       $fromto{$from} = $to;
     }
+    my @to   = values %fromto;
 
+    my @m;
     push(@m, qq{
-EXE_FILES = @{$self->{EXE_FILES}}
-
-FIXIN = $fixin
+EXE_FILES = @exefiles
 
 pure_all :: @to
        \$(NOECHO) \$(NOOP)
 
 realclean ::
-       \$(RM_F) @to
 });
 
-    while (($from,$to) = each %fromto) {
+    # realclean can get rather large.
+    push @m, map "\t$_\n", $self->split_command('$(RM_F)', @to);
+    push @m, "\n";
+
+
+    # A target for each exe file.
+    while (my($from,$to) = each %fromto) {
        last unless defined $from;
-       my $todir = dirname($to);
-       push @m, "
-$to: $from \$(FIRST_MAKEFILE) " . $self->catdir($todir,'.exists') . "
-       \$(NOECHO) \$(RM_F) $to
-       \$(CP) $from $to
-       \$(FIXIN) $to
-       -\$(NOECHO) \$(CHMOD) \$(PERM_RWX) $to
-";
+
+       push @m, sprintf <<'MAKE', $to, $from, $to, $from, $to, $to, $to;
+%s : %s $(FIRST_MAKEFILE) $(INST_SCRIPT)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists
+       $(NOECHO) $(RM_F) %s
+       $(CP) %s %s
+       $(FIXIN) %s
+       -$(NOECHO) $(CHMOD) $(PERM_RWX) %s
+
+MAKE
+
     }
+
     join "", @m;
 }
 
@@ -2716,9 +2348,9 @@ FULLPERL      = $self->{FULLPERL}
     unless ($self->{MAKEAPERL}) {
        push @m, q{
 $(MAP_TARGET) :: static $(MAKE_APERL_FILE)
-       $(MAKE) -f $(MAKE_APERL_FILE) $@
+       $(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
 
-$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
+$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
        $(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
        $(NOECHO) $(PERLRUNINST) \
                Makefile.PL DIR=}, $dir, q{ \
@@ -2756,26 +2388,28 @@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
     $linkcmd =~ s,(perl\.exp),\$(PERL_INC)/$1,;
 
     # Which *.a files could we make use of...
-    local(%static);
+    my %static;
     require File::Find;
     File::Find::find(sub {
        return unless m/\Q$self->{LIB_EXT}\E$/;
-       return if m/^libperl/;
-       # Skip purified versions of libraries (e.g., DynaLoader_pure_p1_c0_032.a)
+
+        # Skip perl's libraries.
+        return if m/^libperl/ or m/^perl\Q$self->{LIB_EXT}\E$/;
+
+       # Skip purified versions of libraries 
+        # (e.g., DynaLoader_pure_p1_c0_032.a)
        return if m/_pure_\w+_\w+_\w+\.\w+$/ and -f "$File::Find::dir/.pure";
 
        if( exists $self->{INCLUDE_EXT} ){
                my $found = 0;
-               my $incl;
-               my $xx;
 
-               ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
+               (my $xx = $File::Find::name) =~ s,.*?/auto/,,s;
                $xx =~ s,/?$_,,;
                $xx =~ s,/,::,g;
 
                # Throw away anything not explicitly marked for inclusion.
                # DynaLoader is implied.
-               foreach $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
+               foreach my $incl ((@{$self->{INCLUDE_EXT}},'DynaLoader')){
                        if( $xx eq $incl ){
                                $found++;
                                last;
@@ -2784,15 +2418,12 @@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
                return unless $found;
        }
        elsif( exists $self->{EXCLUDE_EXT} ){
-               my $excl;
-               my $xx;
-
-               ($xx = $File::Find::name) =~ s,.*?/auto/,,s;
+               (my $xx = $File::Find::name) =~ s,.*?/auto/,,s;
                $xx =~ s,/?$_,,;
                $xx =~ s,/,::,g;
 
                # Throw away anything explicitly marked for exclusion
-               foreach $excl (@{$self->{EXCLUDE_EXT}}){
+               foreach my $excl (@{$self->{EXCLUDE_EXT}}){
                        return if( $xx eq $excl );
                }
        }
@@ -2820,7 +2451,7 @@ $(MAKE_APERL_FILE) : $(FIRST_MAKEFILE)
        push @$extra, $_;
     }
 
-    grep(s/^(.*)/"-I$1"/, @{$perlinc || []});
+    s/^(.*)/"-I$1"/ for @{$perlinc || []};
 
     $target ||= "perl";
     $tmp    ||= ".";
@@ -2850,10 +2481,10 @@ MAP_PRELIBS   = $Config{perllibs} $Config{cryptlib}
 
         if (! -f $libperl and ! -f $lperl) {
           # We did not find a static libperl. Maybe there is a shared one?
-          if ($Is_SunOS) {
+          if ($Is{SunOS}) {
             $lperl  = $libperl = "$dir/$Config{libperl}";
             # SUNOS ld does not take the full path to a shared library
-            $libperl = '' if $Is_SunOS4;
+            $libperl = '' if $Is{SunOS4};
           }
         }
 
@@ -2871,14 +2502,13 @@ MAP_LIBPERL = $libperl
 LLIBPERL    = $llibperl
 ";
 
-    push @m, "
-\$(INST_ARCHAUTODIR)/extralibs.all: \$(INST_ARCHAUTODIR)\$(DIRFILESEP).exists ".join(" \\\n\t", @$extra).'
+    push @m, '
+$(INST_ARCHAUTODIR)/extralibs.all : $(INST_ARCHAUTODIR)$(DFSEP).exists '.join(" \\\n\t", @$extra).'
        $(NOECHO) $(RM_F)  $@
        $(NOECHO) $(TOUCH) $@
 ';
 
-    my $catfile;
-    foreach $catfile (@$extra){
+    foreach my $catfile (@$extra){
        push @m, "\tcat $catfile >> \$\@\n";
     }
 
@@ -2886,13 +2516,13 @@ push @m, "
 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
        \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(LDFROM) \$(MAP_STATIC) \$(LLIBPERL) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
        \$(NOECHO) \$(ECHO) 'To install the new \"\$(MAP_TARGET)\" binary, call'
-       \$(NOECHO) \$(ECHO) '    make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
+       \$(NOECHO) \$(ECHO) '    \$(MAKE) \$(USEMAKEFILE) $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
        \$(NOECHO) \$(ECHO) 'To remove the intermediate files say'
-       \$(NOECHO) \$(ECHO) '    make -f $makefilename map_clean'
+       \$(NOECHO) \$(ECHO) '    \$(MAKE) \$(USEMAKEFILE) $makefilename map_clean'
 
 $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
 ";
-    push @m, qq{\tcd $tmp && $cccmd "-I\$(PERL_INC)" perlmain.c\n};
+    push @m, "\t".$self->cd($tmp, qq[$cccmd "-I\$(PERL_INC)" perlmain.c])."\n";
 
     push @m, qq{
 $tmp/perlmain.c: $makefilename}, q{
@@ -2906,7 +2536,7 @@ $tmp/perlmain.c: $makefilename}, q{
 
 
     push @m, q{
-doc_inst_perl:
+doc_inst_perl :
        $(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
        -$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
        -$(NOECHO) $(DOC_INSTALL) \
@@ -2919,9 +2549,9 @@ doc_inst_perl:
 };
 
     push @m, q{
-inst_perl: pure_inst_perl doc_inst_perl
+inst_perl : pure_inst_perl doc_inst_perl
 
-pure_inst_perl: $(MAP_TARGET)
+pure_inst_perl : $(MAP_TARGET)
        }.$self->{CP}.q{ $(MAP_TARGET) }.$self->catfile('$(DESTINSTALLBIN)','$(MAP_TARGET)').q{
 
 clean :: map_clean
@@ -2941,31 +2571,35 @@ Defines how to rewrite the Makefile.
 
 sub makefile {
     my($self) = shift;
-    my @m;
+    my $m;
     # We do not know what target was originally specified so we
     # must force a manual rerun to be sure. But as it should only
     # happen very rarely it is not a significant problem.
-    push @m, '
+    $m = '
 $(OBJECT) : $(FIRST_MAKEFILE)
+
 ' if $self->{OBJECT};
 
-    push @m, q{
+    my $newer_than_target = $Is{VMS} ? '$(MMS$SOURCE_LIST)' : '$?';
+    my $mpl_args = join " ", map qq["$_"], @ARGV;
+
+    $m .= sprintf <<'MAKE_FRAG', $newer_than_target, $mpl_args;
 # We take a very conservative approach here, but it's worth it.
 # We move Makefile to Makefile.old here to avoid gnu make looping.
 $(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
-       $(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
+       $(NOECHO) $(ECHO) "Makefile out-of-date with respect to %s"
        $(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
-       $(NOECHO) $(RM_F) $(MAKEFILE_OLD)
-       $(NOECHO) $(MV)   $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
-       -$(MAKE) -f $(MAKEFILE_OLD) clean $(DEV_NULL) || $(NOOP)
-       $(PERLRUN) Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
+       -$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
+       -$(NOECHO) $(MV)   $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
+       - $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
+       $(PERLRUN) Makefile.PL %s
        $(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
-       $(NOECHO) $(ECHO) "==> Please rerun the make command.  <=="
+       $(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command.  <=="
        false
 
-};
+MAKE_FRAG
 
-    join "", @m;
+    return $m;
 }
 
 
@@ -2991,8 +2625,8 @@ also has_link_code())
 
 sub needs_linking {
     my($self) = shift;
-    my($child,$caller);
-    $caller = (caller(0))[3];
+
+    my $caller = (caller(0))[3];
     confess("needs_linking called too early") if 
       $caller =~ /^ExtUtils::MakeMaker::/;
     return $self->{NEEDS_LINKING} if defined $self->{NEEDS_LINKING};
@@ -3000,7 +2634,7 @@ sub needs_linking {
        $self->{NEEDS_LINKING} = 1;
        return 1;
     }
-    foreach $child (keys %{$self->{CHILDREN}}) {
+    foreach my $child (keys %{$self->{CHILDREN}}) {
        if ($self->{CHILDREN}->{$child}->needs_linking) {
            $self->{NEEDS_LINKING} = 1;
            return 1;
@@ -3009,22 +2643,6 @@ sub needs_linking {
     return $self->{NEEDS_LINKING} = 0;
 }
 
-=item nicetext
-
-misnamed method (will have to be changed). The MM_Unix method just
-returns the argument without further processing.
-
-On VMS used to insure that colons marking targets are preceded by
-space - most Unix Makes don't need this, but it's necessary under VMS
-to distinguish the target delimiter from a colon appearing as part of
-a filespec.
-
-=cut
-
-sub nicetext {
-    my($self,$text) = @_;
-    $text;
-}
 
 =item parse_abstract
 
@@ -3035,13 +2653,13 @@ parse a file and return what you think is the ABSTRACT
 sub parse_abstract {
     my($self,$parsefile) = @_;
     my $result;
-    local *FH;
+
     local $/ = "\n";
-    open(FH,$parsefile) or die "Could not open '$parsefile': $!";
+    open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!";
     my $inpod = 0;
     my $package = $self->{DISTNAME};
     $package =~ s/-/::/g;
-    while (<FH>) {
+    while (<$fh>) {
         $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
         next if !$inpod;
         chop;
@@ -3049,46 +2667,64 @@ sub parse_abstract {
         $result = $2;
         last;
     }
-    close FH;
+    close $fh;
+
     return $result;
 }
 
 =item parse_version
 
-parse a file and return what you think is $VERSION in this file set to.
+    my $version = MM->parse_version($file);
+
+Parse a $file and return what $VERSION is set to by the first assignment.
 It will return the string "undef" if it can't figure out what $VERSION
-is. $VERSION should be for all to see, so our $VERSION or plain $VERSION
-are okay, but my $VERSION is not.
+is. $VERSION should be for all to see, so C<our $VERSION> or plain $VERSION
+are okay, but C<my $VERSION> is not.
+
+parse_version() will try to C<use version> before checking for C<$VERSION> so the following will work.
+
+    $VERSION = qv(1.2.3);
 
 =cut
 
 sub parse_version {
     my($self,$parsefile) = @_;
     my $result;
-    local *FH;
+
     local $/ = "\n";
-    open(FH,$parsefile) or die "Could not open '$parsefile': $!";
+    local $_;
+    open(my $fh, '<', $parsefile) or die "Could not open '$parsefile': $!";
     my $inpod = 0;
-    while (<FH>) {
-       $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
-       next if $inpod || /^\s*#/;
-       chop;
-       next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
-       my $eval = qq{
-           package ExtUtils::MakeMaker::_version;
-           no strict;
-
-           local $1$2;
-           \$$2=undef; do {
-               $_
-           }; \$$2
-       };
+    while (<$fh>) {
+        $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
+        next if $inpod || /^\s*#/;
+        chop;
+        next unless /(?<!\\)([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
+        my $eval = qq{
+            package ExtUtils::MakeMaker::_version;
+            no strict;
+            BEGIN { eval {
+                # Ensure any version() routine which might have leaked
+                # into this package has been deleted.  Interferes with
+                # version->import()
+                undef *version;
+                require version;
+                "version"->import;
+            } }
+
+            local $1$2;
+            \$$2=undef;
+            do {
+                $_
+            };
+            \$$2;
+        };
         local $^W = 0;
-       $result = eval($eval);
-       warn "Could not eval '$eval' in $parsefile: $@" if $@;
-       last;
+        $result = eval($eval);  ## no critic
+        warn "Could not eval '$eval' in $parsefile: $@" if $@;
+        last;
     }
-    close FH;
+    close $fh;
 
     $result = "undef" unless defined $result;
     return $result;
@@ -3104,27 +2740,22 @@ subdirectories.
 
 sub pasthru {
     my($self) = shift;
-    my(@m,$key);
+    my(@m);
 
     my(@pasthru);
-    my($sep) = $Is_VMS ? ',' : '';
+    my($sep) = $Is{VMS} ? ',' : '';
     $sep .= "\\\n\t";
 
-    foreach $key (qw(LIB LIBPERL_A LINKTYPE PREFIX OPTIMIZE INC DEFINE)) {
-       if ($key eq 'INC' && defined(my $inc = $self->{INC})) {
-           # For INC we need to prepend parent directory but
-           # only iff the parent directory is not absolute.
-           my ($o, $i) = $Is_VMS ? ('/Include=', 'i') : ('-I', '');
-           $inc =~ s!(?$i)$o(.+?)!$o.($self->file_name_is_absolute($1)?$1:$self->catdir($self->updir,$1))!eg;
-           push @pasthru, "INC=\"$inc\"";
-       } else {
-           push @pasthru, "$key=\"\$($key)\"";
-       }
+    foreach my $key (qw(LIB LIBPERL_A LINKTYPE OPTIMIZE
+                     PREFIX INSTALL_BASE)
+                 ) 
+    {
+        next unless defined $self->{$key};
+       push @pasthru, "$key=\"\$($key)\"";
     }
 
-    # PASTHRU_DEFINE and PASTHRU_INC are defined explicitly
-    # by extensions wanting to do really complex things.
-    foreach $key (qw(DEFINE INC)) {
+    foreach my $key (qw(DEFINE INC)) {
+        next unless defined $self->{$key};
        push @pasthru, "PASTHRU_$key=\"\$(PASTHRU_$key)\"";
     }
 
@@ -3156,7 +2787,10 @@ distribution.
 sub perldepend {
     my($self) = shift;
     my(@m);
-    push @m, q{
+
+    my $make_config = $self->cd('$(PERL_SRC)', '$(MAKE) lib/Config.pm');
+
+    push @m, sprintf <<'MAKE_FRAG', $make_config if $self->{PERL_SRC};
 # Check for unpropogated config.sh changes. Should never happen.
 # We do NOT just update config.h because that is not sufficient.
 # An out of date config.h is not fatal but complains loudly!
@@ -3165,8 +2799,8 @@ $(PERL_INC)/config.h: $(PERL_SRC)/config.sh
 
 $(PERL_ARCHLIB)/Config.pm: $(PERL_SRC)/config.sh
        $(NOECHO) $(ECHO) "Warning: $(PERL_ARCHLIB)/Config.pm may be out of date with $(PERL_SRC)/config.sh"
-       cd $(PERL_SRC) && $(MAKE) lib/Config.pm
-} if $self->{PERL_SRC};
+       %s
+MAKE_FRAG
 
     return join "", @m unless $self->needs_linking;
 
@@ -3210,7 +2844,6 @@ PERL_HDRS = \
        $(PERL_INC)/regnodes.h          \
        $(PERL_INC)/scope.h             \
        $(PERL_INC)/sv.h                \
-       $(PERL_INC)/thrdvar.h           \
        $(PERL_INC)/thread.h            \
        $(PERL_INC)/unixish.h           \
        $(PERL_INC)/util.h
@@ -3264,7 +2897,7 @@ sub pm_to_blib {
     my $self = shift;
     my($autodir) = $self->catdir('$(INST_LIB)','auto');
     my $r = q{
-pm_to_blib: $(TO_INST_PM)
+pm_to_blib : $(TO_INST_PM)
 };
 
     my $pm_to_blib = $self->oneliner(<<CODE, ['-MExtUtils::Install']);
@@ -3274,7 +2907,7 @@ CODE
     my @cmds = $self->split_command($pm_to_blib, %{$self->{PM}});
 
     $r .= join '', map { "\t\$(NOECHO) $_\n" } @cmds;
-    $r .= q{   $(NOECHO) $(TOUCH) $@};
+    $r .= qq{\t\$(NOECHO) \$(TOUCH) pm_to_blib\n};
 
     return $r;
 }
@@ -3322,12 +2955,6 @@ for a binary distribution.
 sub ppd {
     my($self) = @_;
 
-    if ($self->{ABSTRACT_FROM}){
-        $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
-            carp "WARNING: Setting ABSTRACT via file ".
-                 "'$self->{ABSTRACT_FROM}' failed\n";
-    }
-
     my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0)x4)[0..3];
 
     my $abstract = $self->{ABSTRACT} || '';
@@ -3358,7 +2985,14 @@ PPD_OUT
 
     }
 
-    $ppd_xml .= sprintf <<'PPD_OUT', $Config{archname};
+    my $archname = $Config{archname};
+    if ($] >= 5.008) {
+        # archname did not change from 5.6 to 5.8, but those versions may
+        # not be not binary compatible so now we append the part of the
+        # version that changes when binary compatibility may change
+        $archname .= "-". substr($Config{version},0,3);
+    }
+    $ppd_xml .= sprintf <<'PPD_OUT', $archname;
         <OS NAME="$(OSNAME)" />
         <ARCHITECTURE NAME="%s" />
 PPD_OUT
@@ -3387,7 +3021,7 @@ PPD_XML
 
     return sprintf <<'PPD_OUT', join "\n\t", @ppd_cmds;
 # Creates a PPD (Perl Package Description) for a binary distribution.
-ppd:
+ppd :
        %s
 PPD_OUT
 
@@ -3430,7 +3064,9 @@ sub prefixify {
     print STDERR "  prefixify $var => $path\n" if $Verbose >= 2;
     print STDERR "    from $sprefix to $rprefix\n" if $Verbose >= 2;
 
-    if( $path !~ s{^\Q$sprefix\E\b}{$rprefix}s && $self->{ARGS}{PREFIX} ) {
+    if( $self->{ARGS}{PREFIX} && $self->file_name_is_absolute($path) && 
+        $path !~ s{^\Q$sprefix\E\b}{$rprefix}s ) 
+    {
 
         print STDERR "    cannot prefix, using default.\n" if $Verbose >= 2;
         print STDERR "    no default!\n" if !$default && $Verbose >= 2;
@@ -3450,25 +3086,52 @@ Defines targets to run *.PL files.
 =cut
 
 sub processPL {
-    my($self) = shift;
-    return "" unless $self->{PL_FILES};
-    my(@m, $plfile);
-    foreach $plfile (sort keys %{$self->{PL_FILES}}) {
-        my $list = ref($self->{PL_FILES}->{$plfile})
-               ? $self->{PL_FILES}->{$plfile}
-               : [$self->{PL_FILES}->{$plfile}];
-       my $target;
-       foreach $target (@$list) {
-       push @m, "
+    my $self = shift;
+    my $pl_files = $self->{PL_FILES};
+
+    return "" unless $pl_files;
+
+    my $m = '';
+    foreach my $plfile (sort keys %$pl_files) {
+        my $list = ref($pl_files->{$plfile})
+                     ?  $pl_files->{$plfile}
+                    : [$pl_files->{$plfile}];
+
+       foreach my $target (@$list) {
+            if( $Is{VMS} ) {
+                $plfile = vmsify($self->eliminate_macros($plfile));
+                $target = vmsify($self->eliminate_macros($target));
+            }
+
+           # Normally a .PL file runs AFTER pm_to_blib so it can have
+           # blib in its @INC and load the just built modules.  BUT if
+           # the generated module is something in $(TO_INST_PM) which
+           # pm_to_blib depends on then it can't depend on pm_to_blib
+           # else we have a dependency loop.
+           my $pm_dep;
+           my $perlrun;
+           if( defined $self->{PM}{$target} ) {
+               $pm_dep  = '';
+               $perlrun = 'PERLRUN';
+           }
+           else {
+               $pm_dep  = 'pm_to_blib';
+               $perlrun = 'PERLRUNINST';
+           }
+
+            $m .= <<MAKE_FRAG;
+
 all :: $target
        \$(NOECHO) \$(NOOP)
 
-$target :: $plfile
-       \$(PERLRUNINST) $plfile $target
-";
+$target :: $plfile $pm_dep
+       \$($perlrun) $plfile $target
+MAKE_FRAG
+
        }
     }
-    join "", @m;
+
+    return $m;
 }
 
 =item quote_paren
@@ -3481,92 +3144,12 @@ but handles simple ones.
 
 sub quote_paren {
     my $arg = shift;
-    $arg =~ s/\$\((.+?)\)/\$\\\\($1\\\\)/g;    # protect $(...)
-    $arg =~ s/(?<!\\)([()])/\\$1/g;            # quote unprotected
-    $arg =~ s/\$\\\\\((.+?)\\\\\)/\$($1)/g;    # unprotect $(...)
+    $arg =~ s{\$\((.+?)\)}{\$\\\\($1\\\\)}g;   # protect $(...)
+    $arg =~ s{(?<!\\)([()])}{\\$1}g;           # quote unprotected
+    $arg =~ s{\$\\\\\((.+?)\\\\\)}{\$($1)}g;   # unprotect $(...)
     return $arg;
 }
 
-=item realclean (o)
-
-Defines the realclean target.
-
-=cut
-
-sub realclean {
-    my($self, %attribs) = @_;
-    my(@m);
-
-    push(@m,'
-# Delete temporary files (via clean) and also delete installed files
-realclean purge ::  clean realclean_subdirs
-       $(RM_RF) $(INST_AUTODIR) $(INST_ARCHAUTODIR)
-       $(RM_RF) $(DISTVNAME)
-');
-
-    if( $self->has_link_code ){
-        push(@m, "     \$(RM_F) \$(INST_DYNAMIC) \$(INST_BOOT)\n");
-        push(@m, "     \$(RM_F) \$(INST_STATIC)\n");
-    }
-
-    my @files = values %{$self->{PM}};
-    push @files, $attribs{FILES} if $attribs{FILES};
-    push @files, '$(FIRST_MAKEFILE)', '$(MAKEFILE_OLD)';
-
-    # Occasionally files are repeated several times from different sources
-    { my(%f) = map { ($_,1) } @files; @files = keys %f; }
-
-    # Issue a several little RM_F commands rather than risk creating a
-    # very long command line (useful for extensions such as Encode
-    # that have many files).
-    my $line = "";
-    foreach my $file (@files) {
-        if (length($line) + length($file) > 200) {
-            push @m, "\t\$(RM_F) $line\n";
-            $line = $file;
-        }
-        else {
-            $line .= " $file"; 
-        }
-    }
-    push @m, "\t\$(RM_F) $line\n" if $line;
-    push(@m, "\t$attribs{POSTOP}\n")      if $attribs{POSTOP};
-
-    join("", @m);
-}
-
-
-=item realclean_subdirs_target
-
-  my $make_frag = $MM->realclean_subdirs_target;
-
-Returns the realclean_subdirs target.  This is used by the realclean
-target to call realclean on any subdirectories which contain Makefiles.
-
-=cut
-
-sub 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}}){
-        $rclean .= sprintf <<'RCLEAN', $dir, $dir;
-       -cd %s && $(TEST_F) $(MAKEFILE_OLD) && $(MAKE) -f $(MAKEFILE_OLD) realclean
-       -cd %s && $(TEST_F) $(FIRST_MAKEFILE) && $(MAKE) realclean
-RCLEAN
-
-    }
-
-    return $rclean;
-}
-
-
 =item replace_manpage_separator
 
   my $man_name = $MM->replace_manpage_separator($file_path);
@@ -3585,7 +3168,20 @@ sub replace_manpage_separator {
 }
 
 
-=item oneliner (o)
+=item cd
+
+=cut
+
+sub cd {
+    my($self, $dir, @cmds) = @_;
+
+    # No leading tab and no trailing newline makes for easier embedding
+    my $make_frag = join "\n\t", map { "cd $dir && $_" } @cmds;
+
+    return $make_frag;
+}
+
+=item oneliner
 
 =cut
 
@@ -3598,12 +3194,12 @@ sub oneliner {
     $cmd =~ s{\n+$}{};
 
     my @cmds = split /\n/, $cmd;
-    $cmd = join " \n\t-e ", map $self->quote_literal($_), @cmds;
+    $cmd = join " \n\t  -e ", map $self->quote_literal($_), @cmds;
     $cmd = $self->escape_newlines($cmd);
 
     $switches = join ' ', @$switches;
 
-    return qq{\$(PERLRUN) $switches -e $cmd};   
+    return qq{\$(ABSPERLRUN) $switches -e $cmd --};   
 }
 
 
@@ -3688,7 +3284,7 @@ sub static_lib {
     my(@m);
     push(@m, <<'END');
 
-$(INST_STATIC): $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
+$(INST_STATIC) : $(OBJECT) $(MYEXTLIB) $(INST_ARCHAUTODIR)$(DFSEP).exists
        $(RM_RF) $@
 END
 
@@ -3717,7 +3313,6 @@ MAKE_FRAG
        $(NOECHO) $(ECHO) "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
 MAKE_FRAG
 
-    push @m, "\n", $self->dir_target('$(INST_ARCHAUTODIR)');
     join('', @m);
 }
 
@@ -3771,11 +3366,16 @@ Helper subroutine for subdirs
 
 sub subdir_x {
     my($self, $subdir) = @_;
-    return sprintf <<'EOT', $subdir;
+
+    my $subdir_cmd = $self->cd($subdir, 
+      '$(MAKE) $(USEMAKEFILE) $(FIRST_MAKEFILE) all $(PASTHRU)'
+    );
+    return sprintf <<'EOT', $subdir_cmd;
 
 subdirs ::
-       $(NOECHO)cd %s && $(MAKE) -f $(FIRST_MAKEFILE) all $(PASTHRU)
+       $(NOECHO) %s
 EOT
+
 }
 
 =item subdirs (o)
@@ -3787,11 +3387,11 @@ Defines targets to process subdirectories.
 sub subdirs {
 # --- Sub-directory Sections ---
     my($self) = shift;
-    my(@m,$dir);
+    my(@m);
     # This method provides a mechanism to automatically deal with
     # subdirectories containing further Makefile.PL scripts.
     # It calls the subdir_x() method for each subdirectory.
-    foreach $dir (@{$self->{DIR}}){
+    foreach my $dir (@{$self->{DIR}}){
        push(@m, $self->subdir_x($dir));
 ####   print "Including $dir subdirectory\n";
     }
@@ -3832,14 +3432,21 @@ TESTDB_SW = -d
 
 testdb :: testdb_\$(LINKTYPE)
 
-test :: \$(TEST_TYPE)
+test :: \$(TEST_TYPE) subdirs-test
+
+subdirs-test ::
+       \$(NOECHO) \$(NOOP)
+
 ");
 
-    if ($Is_Win95) {
-        push(@m, map(qq{\t\$(NOECHO) \$(PERLRUN) -e "exit unless -f shift; chdir '$_'; system q{\$(MAKE) test \$(PASTHRU)}" \$(FIRST_MAKEFILE)\n}, @{$self->{DIR}}));
-    }
-    else {
-        push(@m, map("\t\$(NOECHO) cd $_ && \$(TEST_F) \$(FIRST_MAKEFILE) && \$(MAKE) test \$(PASTHRU)\n", @{$self->{DIR}}));
+    foreach my $dir (@{ $self->{DIR} }) {
+        my $test = $self->cd($dir, '$(MAKE) test $(PASTHRU)');
+
+        push @m, <<END
+subdirs-test ::
+       \$(NOECHO) $test
+
+END
     }
 
     push(@m, "\t\$(NOECHO) \$(ECHO) 'No tests defined for \$(NAME) extension.'\n")
@@ -3904,14 +3511,8 @@ sub test_via_script {
 
     my $make_frag = $MM->tools_other;
 
-Returns a make fragment containing definitions for:
-
-SHELL, CHMOD, CP, MV, NOOP, NOECHO, RM_F, RM_RF, TEST_F, TOUCH,
-DEV_NULL, UMASK_NULL, MKPATH, EQUALIZE_TIMESTAMP,
-WARN_IF_OLD_PACKLIST, UNINST, VERBINST, MOD_INSTALL, DOC_INSTALL and
-UNINSTALL
-
-init_others() initializes all these values.
+Returns a make fragment containing definitions for the macros init_others() 
+initializes.
 
 =cut
 
@@ -3919,12 +3520,18 @@ sub tools_other {
     my($self) = shift;
     my @m;
 
+    # We set PM_FILTER as late as possible so it can see all the earlier
+    # on macro-order sensitive makes such as nmake.
     for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH 
                       UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP 
                       ECHO ECHO_N
                       UNINST VERBINST
                       MOD_INSTALL DOC_INSTALL UNINSTALL
                       WARN_IF_OLD_PACKLIST
+                     MACROSTART MACROEND
+                      USEMAKEFILE
+                      PM_FILTER
+                      FIXIN
                     } ) 
     {
         next unless defined $self->{$tool};
@@ -3945,7 +3552,12 @@ sub tool_xsubpp {
     return "" unless $self->needs_linking;
 
     my $xsdir;
-    foreach my $dir (@INC) {
+    my @xsubpp_dirs = @INC;
+
+    # Make sure we pick up the new xsubpp if we're building perl.
+    unshift @xsubpp_dirs, $self->{PERL_LIB} if $self->{PERL_CORE};
+
+    foreach my $dir (@xsubpp_dirs) {
         $xsdir = $self->catdir($dir, 'ExtUtils');
         if( -r $self->catfile($xsdir, "xsubpp") ) {
             last;
@@ -3955,20 +3567,28 @@ sub tool_xsubpp {
     my $tmdir   = File::Spec->catdir($self->{PERL_LIB},"ExtUtils");
     my(@tmdeps) = $self->catfile($tmdir,'typemap');
     if( $self->{TYPEMAPS} ){
-       my $typemap;
-       foreach $typemap (@{$self->{TYPEMAPS}}){
-               if( ! -f  $typemap ){
-                       warn "Typemap $typemap not found.\n";
-               }
-               else{
-                       push(@tmdeps,  $typemap);
-               }
-       }
+        foreach my $typemap (@{$self->{TYPEMAPS}}){
+            if( ! -f  $typemap ) {
+                warn "Typemap $typemap not found.\n";
+            }
+            else {
+                push(@tmdeps,  $typemap);
+            }
+        }
     }
     push(@tmdeps, "typemap") if -f "typemap";
     my(@tmargs) = map("-typemap $_", @tmdeps);
     if( exists $self->{XSOPT} ){
-       unshift( @tmargs, $self->{XSOPT} );
+        unshift( @tmargs, $self->{XSOPT} );
+    }
+
+    if ($Is{VMS}                          &&
+        $Config{'ldflags'}               && 
+        $Config{'ldflags'} =~ m!/Debug!i &&
+        (!exists($self->{XSOPT}) || $self->{XSOPT} !~ /linenumbers/)
+       ) 
+    {
+        unshift(@tmargs,'-nolinenumbers');
     }
 
 
@@ -3976,7 +3596,8 @@ sub tool_xsubpp {
 
     return qq{
 XSUBPPDIR = $xsdir
-XSUBPP = \$(XSUBPPDIR)/xsubpp
+XSUBPP = \$(XSUBPPDIR)\$(DFSEP)xsubpp
+XSUBPPRUN = \$(PERLRUN) \$(XSUBPP)
 XSPROTOARG = $self->{XSPROTOARG}
 XSUBPPDEPS = @tmdeps \$(XSUBPP)
 XSUBPPARGS = @tmargs
@@ -4013,7 +3634,7 @@ sub top_targets {
     my(@m);
 
     push @m, $self->all_target, "\n" unless $self->{SKIPHASH}{'all'};
-    
+
     push @m, '
 pure_all :: config pm_to_blib subdirs linkext
        $(NOECHO) $(NOOP)
@@ -4021,41 +3642,16 @@ pure_all :: config pm_to_blib subdirs linkext
 subdirs :: $(MYEXTLIB)
        $(NOECHO) $(NOOP)
 
-config :: $(FIRST_MAKEFILE) $(INST_LIBDIR)$(DIRFILESEP).exists
-       $(NOECHO) $(NOOP)
-
-config :: $(INST_ARCHAUTODIR)$(DIRFILESEP).exists
-       $(NOECHO) $(NOOP)
-
-config :: $(INST_AUTODIR)$(DIRFILESEP).exists
+config :: $(FIRST_MAKEFILE) blibdirs
        $(NOECHO) $(NOOP)
 ';
 
-    push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
-
-    if (%{$self->{MAN1PODS}}) {
-       push @m, q[
-config :: $(INST_MAN1DIR)$(DIRFILESEP).exists
-       $(NOECHO) $(NOOP)
-
-];
-       push @m, $self->dir_target(qw[$(INST_MAN1DIR)]);
-    }
-    if (%{$self->{MAN3PODS}}) {
-       push @m, q[
-config :: $(INST_MAN3DIR)$(DIRFILESEP).exists
-       $(NOECHO) $(NOOP)
-
-];
-       push @m, $self->dir_target(qw[$(INST_MAN3DIR)]);
-    }
-
     push @m, '
 $(O_FILES): $(H_FILES)
 ' if @{$self->{O_FILES} || []} && @{$self->{H} || []};
 
     push @m, q{
-help:
+help :
        perldoc ExtUtils::MakeMaker
 };
 
@@ -4088,7 +3684,7 @@ sub xs_c {
     return '' unless $self->needs_linking();
     '
 .xs.c:
-       $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
+       $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $(XSUBPP_EXTRA_ARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
 ';
 }
 
@@ -4103,7 +3699,7 @@ sub xs_cpp {
     return '' unless $self->needs_linking();
     '
 .xs.cpp:
-       $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
+       $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
 ';
 }
 
@@ -4119,7 +3715,7 @@ sub xs_o {        # many makes are too dumb to use xs_c then c_o
     return '' unless $self->needs_linking();
     '
 .xs$(OBJ_EXT):
-       $(PERLRUN) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
+       $(XSUBPPRUN) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
        $(CCCMD) $(CCCDLFLAGS) "-I$(PERL_INC)" $(PASTHRU_DEFINE) $(DEFINE) $*.c
 ';
 }