This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Continue what #4494 started; introduce uid and gid formats.
[perl5.git] / lib / ExtUtils / MM_Unix.pm
index e64423f..9a8aefb 100644 (file)
@@ -5,17 +5,20 @@ use Config;
 use File::Basename qw(basename dirname fileparse);
 use DirHandle;
 use strict;
-use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS
+use vars qw($VERSION $Is_Mac $Is_OS2 $Is_VMS $Is_Win32 $Is_Dos $Is_PERL_OBJECT
            $Verbose %pm %static $Xsubpp_Version);
 
-$VERSION = substr q$Revision: 1.109 $, 10;
-# $Id: MM_Unix.pm,v 1.109 1996/12/17 00:42:32 k Exp k $
+$VERSION = substr q$Revision: 1.12602 $, 10;
+# $Id: MM_Unix.pm,v 1.126 1998/06/28 21:32:49 k Exp k $
 
-Exporter::import('ExtUtils::MakeMaker',
-       qw( $Verbose &neatvalue));
+Exporter::import('ExtUtils::MakeMaker', qw($Verbose &neatvalue));
 
 $Is_OS2 = $^O eq 'os2';
-$Is_Mac = $^O eq "MacOS";
+$Is_Mac = $^O eq 'MacOS';
+$Is_Win32 = $^O eq 'MSWin32';
+$Is_Dos = $^O eq 'dos';
+
+$Is_PERL_OBJECT = $Config{'ccflags'} =~ /-DPERL_OBJECT/;
 
 if ($Is_VMS = $^O eq 'VMS') {
     require VMS::Filespec;
@@ -76,11 +79,15 @@ path. On UNIX eliminated successive slashes and successive "/.".
 
 sub canonpath {
     my($self,$path) = @_;
-    $path =~ s|/+|/|g ;                            # xx////xx  -> xx/xx
+    my $node = '';
+    if ( $^O eq 'qnx' && $path =~ s|^(//\d+)/|/| ) {
+      $node = $1;
+    }
+    $path =~ s|(?<=[^/])/+|/|g ;                   # xx////xx  -> xx/xx
     $path =~ s|(/\.)+/|/|g ;                       # xx/././xx -> xx/xx
     $path =~ s|^(\./)+|| unless $path eq "./";     # ./xx      -> xx
-    $path =~ s|/$|| unless $path eq "/";           # xx/       -> xx
-    $path;
+    $path =~ s|(?<=[^/])/$|| ;                     # xx/       -> xx
+    "$node$path";
 }
 
 =item catdir
@@ -96,17 +103,13 @@ trailing slash :-)
 # ';
 
 sub catdir {
-    shift;
+    my $self = shift @_;
     my @args = @_;
     for (@args) {
        # append a slash to each argument unless it has one there
        $_ .= "/" if $_ eq '' or substr($_,-1) ne "/";
     }
-    my $result = join('', @args);
-    # remove a trailing slash unless we are root
-    substr($result,-1) = ""
-       if length($result) > 1 && substr($result,-1) eq "/";
-    $result;
+    $self->canonpath(join('', @args));
 }
 
 =item catfile
@@ -119,12 +122,12 @@ complete path ending with a filename
 sub catfile {
     my $self = shift @_;
     my $file = pop @_;
-    return $file unless @_;
+    return $self->canonpath($file) unless @_;
     my $dir = $self->catdir(@_);
     for ($dir) {
        $_ .= "/" unless substr($_,length($_)-1,1) eq "/";
     }
-    return $dir.$file;
+    return $self->canonpath($dir.$file);
 }
 
 =item curdir
@@ -176,12 +179,15 @@ sub ExtUtils::MM_Unix::dynamic ;
 sub ExtUtils::MM_Unix::dynamic_bs ;
 sub ExtUtils::MM_Unix::dynamic_lib ;
 sub ExtUtils::MM_Unix::exescan ;
+sub ExtUtils::MM_Unix::export_list ;
 sub ExtUtils::MM_Unix::extliblist ;
 sub ExtUtils::MM_Unix::file_name_is_absolute ;
 sub ExtUtils::MM_Unix::find_perl ;
+sub ExtUtils::MM_Unix::fixin ;
 sub ExtUtils::MM_Unix::force ;
 sub ExtUtils::MM_Unix::guess_name ;
 sub ExtUtils::MM_Unix::has_link_code ;
+sub ExtUtils::MM_Unix::htmlifypods ;
 sub ExtUtils::MM_Unix::init_dirscan ;
 sub ExtUtils::MM_Unix::init_main ;
 sub ExtUtils::MM_Unix::init_others ;
@@ -201,12 +207,14 @@ sub ExtUtils::MM_Unix::nicetext ;
 sub ExtUtils::MM_Unix::parse_version ;
 sub ExtUtils::MM_Unix::pasthru ;
 sub ExtUtils::MM_Unix::path ;
+sub ExtUtils::MM_Unix::perl_archive;
 sub ExtUtils::MM_Unix::perl_script ;
 sub ExtUtils::MM_Unix::perldepend ;
 sub ExtUtils::MM_Unix::pm_to_blib ;
 sub ExtUtils::MM_Unix::post_constants ;
 sub ExtUtils::MM_Unix::post_initialize ;
 sub ExtUtils::MM_Unix::postamble ;
+sub ExtUtils::MM_Unix::ppd ;
 sub ExtUtils::MM_Unix::prefixify ;
 sub ExtUtils::MM_Unix::processPL ;
 sub ExtUtils::MM_Unix::realclean ;
@@ -225,6 +233,7 @@ sub ExtUtils::MM_Unix::tools_other ;
 sub ExtUtils::MM_Unix::top_targets ;
 sub ExtUtils::MM_Unix::writedoc ;
 sub ExtUtils::MM_Unix::xs_c ;
+sub ExtUtils::MM_Unix::xs_cpp ;
 sub ExtUtils::MM_Unix::xs_o ;
 sub ExtUtils::MM_Unix::xsubpp_version ;
 
@@ -262,7 +271,7 @@ sub c_o {
     push @m, '
 .C$(OBJ_EXT):
        $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.C
-' if $^O ne 'os2';                     # Case-specific
+' if $^O ne 'os2' and $^O ne 'MSWin32' and $^O ne 'dos'; #Case-specific
     push @m, '
 .cpp$(OBJ_EXT):
        $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.cpp
@@ -366,12 +375,33 @@ sub cflags {
        $self->{uc $_} ||= $cflags{$_}
     }
 
+    if ($Is_PERL_OBJECT) {
+        $self->{CCFLAGS} =~ s/-DPERL_OBJECT(\b|$)/-DPERL_CAPI/g;
+        if ($Is_Win32 && $Config{'cc'} =~ /^cl/i) {
+            # Turn off C++ mode of the MSC compiler
+            $self->{CCFLAGS} =~ s/-TP(\s|$)//;
+            $self->{OPTIMIZE} =~ s/-TP(\s|$)//;
+        }
+    }
+
+    if ($self->{POLLUTE}) {
+       $self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
+    }
+
+    my $pollute = '';
+    if ($Config{usemymalloc} and not $Config{bincompat5005}
+       and not $Config{ccflags} =~ /-DPERL_POLLUTE_MALLOC\b/
+       and $self->{PERL_MALLOC_OK}) {
+       $pollute = '$(PERL_MALLOC_DEF)';
+    }
+
     return $self->{CFLAGS} = qq{
 CCFLAGS = $self->{CCFLAGS}
 OPTIMIZE = $self->{OPTIMIZE}
 PERLTYPE = $self->{PERLTYPE}
 LARGE = $self->{LARGE}
 SPLIT = $self->{SPLIT}
+MPOLLUTE = $pollute
 };
 
 }
@@ -395,7 +425,19 @@ clean ::
 ');
     # clean subdirectories first
     for $dir (@{$self->{DIR}}) {
-       push @m, "\t-cd $dir && test -f $self->{MAKEFILE} && \$(MAKE) clean\n";
+       if ($Is_Win32  &&  Win32::IsWin95()) {
+           push @m, <<EOT;
+       cd $dir
+       \$(TEST_F) $self->{MAKEFILE}
+       \$(MAKE) clean
+       cd ..
+EOT
+       }
+       else {
+           push @m, <<EOT;
+       -cd $dir && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) clean
+EOT
+       }
     }
 
     my(@otherfiles) = values %{$self->{XS}}; # .c files from *.xs files
@@ -409,7 +451,7 @@ clean ::
     push @m, "\t-$self->{RM_RF} @otherfiles\n";
     # See realclean and ext/utils/make_ext for usage of Makefile.old
     push(@m,
-        "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old 2>/dev/null\n");
+        "\t-$self->{MV} $self->{MAKEFILE} $self->{MAKEFILE}.old \$(DEV_NULL)\n");
     push(@m,
         "\t$attribs{POSTOP}\n")   if $attribs{POSTOP};
     join("", @m);
@@ -428,7 +470,7 @@ sub const_cccmd {
     return '' unless $self->needs_linking();
     return $self->{CONST_CCCMD} =
        q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\
-       $(PERLTYPE) $(LARGE) $(SPLIT) $(DEFINE_VERSION) \\
+       $(PERLTYPE) $(LARGE) $(SPLIT) $(MPOLLUTE) $(DEFINE_VERSION) \\
        $(XS_DEFINE_VERSION)};
 }
 
@@ -513,6 +555,7 @@ VERSION_MACRO = VERSION
 DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
 XS_VERSION_MACRO = XS_VERSION
 XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
+PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
 };
 
     push @m, qq{
@@ -542,17 +585,33 @@ XS_FILES= ".join(" \\\n\t", sort keys %{$self->{XS}})."
 C_FILES = ".join(" \\\n\t", @{$self->{C}})."
 O_FILES = ".join(" \\\n\t", @{$self->{O_FILES}})."
 H_FILES = ".join(" \\\n\t", @{$self->{H}})."
+HTMLLIBPODS    = ".join(" \\\n\t", sort keys %{$self->{HTMLLIBPODS}})."
+HTMLSCRIPTPODS = ".join(" \\\n\t", sort keys %{$self->{HTMLSCRIPTPODS}})."
 MAN1PODS = ".join(" \\\n\t", sort keys %{$self->{MAN1PODS}})."
 MAN3PODS = ".join(" \\\n\t", sort keys %{$self->{MAN3PODS}})."
 ";
 
     for $tmp (qw/
-             INST_MAN1DIR INSTALLMAN1DIR MAN1EXT INST_MAN3DIR INSTALLMAN3DIR MAN3EXT
+             INST_HTMLPRIVLIBDIR INSTALLHTMLPRIVLIBDIR
+             INST_HTMLSITELIBDIR INSTALLHTMLSITELIBDIR
+             INST_HTMLSCRIPTDIR  INSTALLHTMLSCRIPTDIR
+             INST_HTMLLIBDIR                    HTMLEXT
+             INST_MAN1DIR        INSTALLMAN1DIR MAN1EXT
+             INST_MAN3DIR        INSTALLMAN3DIR MAN3EXT
              /) {
        next unless defined $self->{$tmp};
        push @m, "$tmp = $self->{$tmp}\n";
     }
 
+    for $tmp (qw(
+               PERM_RW PERM_RWX
+               )
+            ) {
+        my $method = lc($tmp);
+       # warn "self[$self] method[$method]";
+        push @m, "$tmp = ", $self->$method(), "\n";
+    }
+
     push @m, q{
 .NO_CONFIG_REC: Makefile
 } if $ENV{CLEARCASE_ROOT};
@@ -600,20 +659,11 @@ INST_BOOT    =
 ';
     }
 
-    if ($Is_OS2) {
-       $tmp = "$self->{BASEEXT}.def";
-    } else {
-       $tmp = "";
-    }
+    $tmp = $self->export_list;
     push @m, "
 EXPORT_LIST = $tmp
 ";
-
-    if ($Is_OS2) {
-       $tmp = "\$(PERL_INC)/libperl\$(LIB_EXT)";
-    } else {
-       $tmp = "";
-    }
+    $tmp = $self->perl_archive;
     push @m, "
 PERL_ARCHIVE = $tmp
 ";
@@ -669,20 +719,25 @@ sub dir_target {
 # too often :)
 
     my($self,@dirs) = @_;
-    my(@m,$dir);
+    my(@m,$dir,$targdir);
     foreach $dir (@dirs) {
        my($src) = $self->catfile($self->{PERL_INC},'perl.h');
        my($targ) = $self->catfile($dir,'.exists');
-       my($targdir) = $targ;       # Necessary because catfile may have
-       $targdir =~ s:/?.exists$::; # adapted syntax of $dir to target OS
+       # 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$::;
+       }
+       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
        $self->{NOECHO}\$(MKPATH) $targdir
        $self->{NOECHO}\$(EQUALIZE_TIMESTAMP) $src $targ
 };
-       push(@m,qq{
-       -$self->{NOECHO}\$(CHMOD) 755 $targdir
+       push(@m, qq{
+       -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $targdir
 }) unless $Is_VMS;
     }
     join "", @m;
@@ -705,15 +760,15 @@ sub dist {
     my($tarflags) = $attribs{TARFLAGS} || 'cvf';
     my($zip)      = $attribs{ZIP}      || 'zip';        # eg pkzip Yuck!
     my($zipflags) = $attribs{ZIPFLAGS} || '-r';
-    my($compress) = $attribs{COMPRESS} || 'compress';   # eg gzip
-    my($suffix)   = $attribs{SUFFIX}   || '.Z';          # eg .gz
+    my($compress) = $attribs{COMPRESS} || 'gzip --best';
+    my($suffix)   = $attribs{SUFFIX}   || '.gz';          # eg .gz
     my($shar)     = $attribs{SHAR}     || 'shar';       # eg "shar --gzip"
     my($preop)    = $attribs{PREOP}    || "$self->{NOECHO}\$(NOOP)"; # eg update MANIFEST
     my($postop)   = $attribs{POSTOP}   || "$self->{NOECHO}\$(NOOP)"; # eg remove the distdir
 
     my($to_unix)  = $attribs{TO_UNIX} || ($Is_OS2
                                          ? "$self->{NOECHO}"
-                                         . 'test -f tmp.zip && $(RM) tmp.zip;'
+                                         . '$(TEST_F) tmp.zip && $(RM) tmp.zip;'
                                          . ' $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip'
                                          : "$self->{NOECHO}\$(NOOP)");
 
@@ -757,20 +812,20 @@ distclean :: realclean distcheck
 
     push @m, q{
 distcheck :
-       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&fullcheck";' \\
-               -e 'fullcheck();'
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=fullcheck \\
+               -e fullcheck
 };
 
     push @m, q{
 skipcheck :
-       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&skipcheck";' \\
-               -e 'skipcheck();'
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=skipcheck \\
+               -e skipcheck
 };
 
     push @m, q{
 manifest :
-       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&mkmanifest";' \\
-               -e 'mkmanifest();'
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=mkmanifest \\
+               -e mkmanifest
 };
     join "", @m;
 }
@@ -786,8 +841,8 @@ sub dist_ci {
     my @m;
     push @m, q{
 ci :
-       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use ExtUtils::Manifest "&maniread";' \\
-               -e '@all = keys %{ maniread() };' \\
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=maniread \\
+               -e "@all = keys %{ maniread() };" \\
                -e 'print("Executing $(CI) @all\n"); system("$(CI) @all");' \\
                -e 'print("Executing $(RCS_LABEL) ...\n"); system("$(RCS_LABEL) @all");'
 };
@@ -796,7 +851,7 @@ ci :
 
 =item dist_core (o)
 
-Defeines the targets dist, tardist, zipdist, uutardist, shdist
+Defines the targets dist, tardist, zipdist, uutardist, shdist
 
 =cut
 
@@ -854,7 +909,7 @@ sub dist_dir {
 distdir :
        $(RM_RF) $(DISTVNAME)
        $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Manifest=manicopy,maniread \\
-               -e 'manicopy(maniread(),"$(DISTVNAME)", "$(DIST_CP)");'
+               -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
 };
     join "", @m;
 }
@@ -893,6 +948,7 @@ sub dlsyms {
 
     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,"
@@ -909,7 +965,8 @@ static :: $self->{BASEEXT}.exp
 $self->{BASEEXT}.exp: Makefile.PL
 ",'    $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
        Mksymlists("NAME" => "',$self->{NAME},'", "DL_FUNCS" => ',
-       neatvalue($funcs),', "DL_VARS" => ', neatvalue($vars), ');\'
+       neatvalue($funcs), ', "FUNCLIST" => ', neatvalue($funclist),
+       ', "DL_VARS" => ', neatvalue($vars), ');\'
 ');
 
     join('',@m);
@@ -955,15 +1012,15 @@ BOOTSTRAP = '."$self->{BASEEXT}.bs".'
 $(BOOTSTRAP): '."$self->{MAKEFILE} $self->{BOOTDEP}".' $(INST_ARCHAUTODIR)/.exists
        '.$self->{NOECHO}.'echo "Running Mkbootstrap for $(NAME) ($(BSLOADLIBS))"
        '.$self->{NOECHO}.'$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" \
-               -e \'use ExtUtils::Mkbootstrap;\' \
-               -e \'Mkbootstrap("$(BASEEXT)","$(BSLOADLIBS)");\'
+               -MExtUtils::Mkbootstrap \
+               -e "Mkbootstrap(\'$(BASEEXT)\',\'$(BSLOADLIBS)\');"
        '.$self->{NOECHO}.'$(TOUCH) $(BOOTSTRAP)
-       $(CHMOD) 644 $@
+       $(CHMOD) $(PERM_RW) $@
 
 $(INST_BOOT): $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
        '."$self->{NOECHO}$self->{RM_RF}".' $(INST_BOOT)
        -'.$self->{CP}.' $(BOOTSTRAP) $(INST_BOOT)
-       $(CHMOD) 644 $@
+       $(CHMOD) $(PERM_RW) $@
 ';
 }
 
@@ -1000,10 +1057,21 @@ $(INST_DYNAMIC): $(OBJECT) $(MYEXTLIB) $(BOOTSTRAP) $(INST_ARCHAUTODIR)/.exists
        push(@m,'       $(RANLIB) '."$ldfrom\n");
     }
     $ldfrom = "-all $ldfrom -none" if ($^O eq 'dec_osf');
-    push(@m,'  LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ $(LDDLFLAGS) '.$ldfrom.
+
+    # Brain dead solaris linker does not use LD_RUN_PATH?
+    # This fixes dynamic extensions which need shared libs
+    my $ldrun = '';
+    $ldrun = join ' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}
+       if ($^O eq 'solaris');
+
+    # The IRIX linker also doesn't use LD_RUN_PATH
+    $ldrun = qq{-rpath "$self->{LD_RUN_PATH}"}
+       if ($^O eq 'irix' && $self->{LD_RUN_PATH});
+
+    push(@m,'  LD_RUN_PATH="$(LD_RUN_PATH)" $(LD) -o $@ '.$ldrun.' $(LDDLFLAGS) '.$ldfrom.
                ' $(OTHERLDFLAGS) $(MYEXTLIB) $(PERL_ARCHIVE) $(LDLOADLIBS) $(EXPORT_LIST)');
     push @m, '
-       $(CHMOD) 755 $@
+       $(CHMOD) $(PERM_RWX) $@
 ';
 
     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
@@ -1042,7 +1110,12 @@ Takes as argument a path and returns true, if it is an absolute path.
 
 sub file_name_is_absolute {
     my($self,$file) = @_;
-    $file =~ m:^/: ;
+    if ($Is_Dos){
+        $file =~ m{^([a-z]:)?[\\/]}i ;
+    }
+    else {
+        $file =~ m:^/: ;
+    }
 }
 
 =item find_perl
@@ -1097,6 +1170,105 @@ specified by @ExtUtils::MakeMaker::MM_Sections.
 
 =over 2
 
+=item fixin
+
+Inserts the sharpbang or equivalent magic number to a script
+
+=cut
+
+sub fixin { # stolen from the pink Camel book, more or less
+    my($self,@files) = @_;
+    my($does_shbang) = $Config::Config{'sharpbang'} =~ /^\s*\#\!/;
+    my($file,$interpreter);
+    for $file (@files) {
+       local(*FIXIN);
+       local(*FIXOUT);
+       open(FIXIN, $file) or Carp::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).
+       if ($cmd eq "perl") {
+            if ($Config{startperl} =~ m,^\#!.*/perl,) {
+                $interpreter = $Config{startperl};
+                $interpreter =~ s,^\#!,,;
+            } 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{
+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 ( open(FIXOUT,">$file.new") ) {
+           warn "Can't create new $file: $!\n";
+           next;
+       }
+       my($dev,$ino,$mode) = stat FIXIN;
+       # If they override perm_rwx, we won't notice it during fixin,
+       # because fixin is run through a new instance of MakeMaker.
+       # That is why we must run another CHMOD later.
+       $mode = oct($self->perm_rwx) unless $dev;
+       chmod $mode, $file;
+       
+       # Print out the new #! line (or equivalent).
+       local $\;
+       undef $/;
+       print FIXOUT $shb, <FIXIN>;
+       close FIXIN;
+       close FIXOUT;
+       # can't rename open files on some DOSISH platforms
+       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 {
+       chmod oct($self->perm_rwx), $file or
+         die "Can't reset permissions for $file: $!\n";
+       system("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';;
+    }
+}
+
 =item force (o)
 
 Just writes FORCE:
@@ -1107,6 +1279,7 @@ sub force {
     my($self) = shift;
     '# Phony target to force checking subdirectories.
 FORCE:
+       '.$self->{NOECHO}.'$(NOOP)
 ';
 }
 
@@ -1149,9 +1322,60 @@ sub has_link_code {
     return $self->{HAS_LINK_CODE} = 0;
 }
 
+=item htmlifypods (o)
+
+Defines targets and routines to translate the pods into HTML manpages
+and put them into the INST_HTMLLIBDIR and INST_HTMLSCRIPTDIR
+directories.
+
+=cut
+
+sub htmlifypods {
+    my($self, %attribs) = @_;
+    return "\nhtmlifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
+       %{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}};
+    my($dist);
+    my($pod2html_exe);
+    if (defined $self->{PERL_SRC}) {
+       $pod2html_exe = $self->catfile($self->{PERL_SRC},'pod','pod2html');
+    } else {
+       $pod2html_exe = $self->catfile($Config{scriptdirexp},'pod2html');
+    }
+    unless ($pod2html_exe = $self->perl_script($pod2html_exe)) {
+       # No pod2html but some HTMLxxxPODS to be installed
+       print <<END;
+
+Warning: I could not locate your pod2html program. Please make sure,
+         your pod2html program is in your PATH before you execute 'make'
+
+END
+        $pod2html_exe = "-S pod2html";
+    }
+    my(@m);
+    push @m,
+qq[POD2HTML_EXE = $pod2html_exe\n],
+qq[POD2HTML = \$(PERL) -we 'use File::Basename; use File::Path qw(mkpath); %m=\@ARGV;for (keys %m){' \\\n],
+q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
+ $self->{MAKEFILE}, q[";' \\
+-e 'print "Htmlifying $$m{$$_}\n";' \\
+-e '$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;' \\
+-e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
+-e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
+];
+    push @m, "\nhtmlifypods : pure_all ";
+    push @m, join " \\\n\t", keys %{$self->{HTMLLIBPODS}}, keys %{$self->{HTMLSCRIPTPODS}};
+
+    push(@m,"\n");
+    if (%{$self->{HTMLLIBPODS}} || %{$self->{HTMLSCRIPTPODS}}) {
+       push @m, "\t$self->{NOECHO}\$(POD2HTML) \\\n\t";
+       push @m, join " \\\n\t", %{$self->{HTMLLIBPODS}}, %{$self->{HTMLSCRIPTPODS}};
+    }
+    join('', @m);
+}
+
 =item init_dirscan
 
-Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, MAN*PODS, EXE_FILES.
+Initializes DIR, XS, PM, C, O_FILES, H, PL_FILES, HTML*PODS, MAN*PODS, EXE_FILES.
 
 =cut
 
@@ -1159,9 +1383,10 @@ sub init_dirscan {       # --- File and Directory Lists (.xs .pm .pod etc)
     my($self) = @_;
     my($name, %dir, %xs, %c, %h, %ignore, %pl_files, %manifypods);
     local(%pm); #the sub in find() has to see this hash
-    $ignore{'test.pl'} = 1;
+    @ignore{qw(Makefile.PL test.pl)} = (1,1);
     $ignore{'makefile.pl'} = 1 if $Is_VMS;
     foreach $name ($self->lsdir($self->curdir)){
+       next if $name =~ /\#/;
        next if $name eq $self->curdir or $name eq $self->updir or $ignore{$name};
        next unless $self->libscan($name);
        if (-d $name){
@@ -1176,13 +1401,18 @@ sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
                unless $name =~ m/perlmain\.c/; # See MAP_TARGET
        } elsif ($name =~ /\.h$/i){
            $h{$name} = 1;
+       } elsif ($name =~ /\.PL$/) {
+           ($pl_files{$name} = $name) =~ s/\.PL$// ;
+       } 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;
+           if ($txt =~ /Extracting \S+ \(with variable substitutions/) {
+               ($pl_files{$name} = $name) =~ s/[._]pl$//i ;
+           }
+           else { $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name); }
        } elsif ($name =~ /\.(p[ml]|pod)$/){
            $pm{$name} = $self->catfile('$(INST_LIBDIR)',$name);
-       } elsif ($name =~ /\.PL$/ && $name ne "Makefile.PL") {
-           ($pl_files{$name} = $name) =~ s/\.PL$// ;
-       } elsif ($Is_VMS && $name =~ /\.pl$/ && $name ne 'makefile.pl' &&
-                $name ne 'test.pl') {  # case-insensitive filesystem
-           ($pl_files{$name} = $name) =~ s/\.pl$// ;
        }
     }
 
@@ -1237,6 +1467,7 @@ sub init_dirscan {        # --- File and Directory Lists (.xs .pm .pod etc)
                }
                return;
            }
+           return if /\#/;
            my($path, $prefix) = ($File::Find::name, '$(INST_LIBDIR)');
            my($striplibpath,$striplibname);
            $prefix =  '$(INST_LIB)' if (($striplibpath = $path) =~ s:^(\W*)lib\W:$1:i);
@@ -1260,64 +1491,59 @@ sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
     $self->{PL_FILES} = \%pl_files unless $self->{PL_FILES};
 
     # Set up names of manual pages to generate from pods
-    if ($self->{MAN1PODS}) {
-    } elsif ( $self->{INST_MAN1DIR} =~ /^(none|\s*)$/ ) {
-       $self->{MAN1PODS} = {};
-    } else {
-       my %manifypods = ();
+    my %pods;
+    foreach my $man (qw(MAN1 MAN3 HTMLLIB HTMLSCRIPT)) {
+       unless ($self->{"${man}PODS"}) {
+           $self->{"${man}PODS"} = {};
+           $pods{$man} = 1 unless $self->{"INST_${man}DIR"} =~ /^(none|\s*)$/;
+       }
+    }
+
+    if ($pods{MAN1} || $pods{HTMLSCRIPT}) {
        if ( exists $self->{EXE_FILES} ) {
            foreach $name (@{$self->{EXE_FILES}}) {
-#              use FileHandle ();
-#              my $fh = new FileHandle;
                local *FH;
                my($ispod)=0;
-               # one day test, if $/ can be set to '' safely (is the bug fixed that was in 5.001m?)
-#              if ($fh->open("<$name")) {
                if (open(FH,"<$name")) {
-#                  while (<$fh>) {
                    while (<FH>) {
                        if (/^=head1\s+\w+/) {
                            $ispod=1;
                            last;
                        }
                    }
-#                  $fh->close;
                    close FH;
                } else {
                    # If it doesn't exist yet, we assume, it has pods in it
                    $ispod = 1;
                }
-               if( $ispod ) {
-                   $manifypods{$name} = $self->catfile('$(INST_MAN1DIR)',basename($name).'.$(MAN1EXT)');
+               next unless $ispod;
+               if ($pods{HTMLSCRIPT}) {
+                   $self->{HTMLSCRIPTPODS}->{$name} =
+                     $self->catfile("\$(INST_HTMLSCRIPTDIR)", basename($name).".\$(HTMLEXT)");
+               }
+               if ($pods{MAN1}) {
+                   $self->{MAN1PODS}->{$name} =
+                     $self->catfile("\$(INST_MAN1DIR)", basename($name).".\$(MAN1EXT)");
                }
            }
        }
-       $self->{MAN1PODS} = \%manifypods;
     }
-    if ($self->{MAN3PODS}) {
-    } elsif ( $self->{INST_MAN3DIR} =~ /^(none|\s*)$/ ) {
-       $self->{MAN3PODS} = {};
-    } else {
+    if ($pods{MAN3} || $pods{HTMLLIB}) {
        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$/ ) {
                $manifypods{$name} = $self->{PM}{$name};
            } elsif ($name =~ /\.p[ml]$/ ) {
-#              use FileHandle ();
-#              my $fh = new FileHandle;
                local *FH;
                my($ispod)=0;
-#              $fh->open("<$name");
                if (open(FH,"<$name")) {
-                   #           while (<$fh>) {
                    while (<FH>) {
                        if (/^=head1\s+\w+/) {
                            $ispod=1;
                            last;
                        }
                    }
-                   #           $fh->close;
                    close FH;
                } else {
                    $ispod = 1;
@@ -1336,14 +1562,20 @@ sub init_dirscan {      # --- File and Directory Lists (.xs .pm .pod etc)
                next;
            }
            my($manpagename) = $name;
+           $manpagename =~ s/\.p(od|m|l)$//;
+           if ($pods{HTMLLIB}) {
+               $self->{HTMLLIBPODS}->{$name} =
+                 $self->catfile("\$(INST_HTMLLIBDIR)", "$manpagename.\$(HTMLEXT)");
+           }
            unless ($manpagename =~ s!^\W*lib\W+!!) { # everything below lib is ok
                $manpagename = $self->catfile(split(/::/,$self->{PARENT_NAME}),$manpagename);
            }
-           $manpagename =~ s/\.p(od|m|l)$//;
-           $manpagename = $self->replace_manpage_separator($manpagename);
-           $manifypods{$name} = $self->catfile("\$(INST_MAN3DIR)","$manpagename.\$(MAN3EXT)");
+           if ($pods{MAN3}) {
+               $manpagename = $self->replace_manpage_separator($manpagename);
+               $self->{MAN3PODS}->{$name} =
+                 $self->catfile("\$(INST_MAN3DIR)", "$manpagename.\$(MAN3EXT)");
+           }
        }
-       $self->{MAN3PODS} = \%manifypods;
     }
 }
 
@@ -1351,7 +1583,7 @@ sub init_dirscan {        # --- File and Directory Lists (.xs .pm .pod etc)
 
 Initializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC,
 PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*,
-PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, MAP_TARGET,
+PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, EXE_EXT, MAP_TARGET,
 LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM.
 
 =cut
@@ -1384,7 +1616,7 @@ sub init_main {
         $modfname = &DynaLoader::mod2fname(\@modparts);
     }
 
-    ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!([\w:]+::)?(\w+)$! ;
+    ($self->{PARENT_NAME}, $self->{BASEEXT}) = $self->{NAME} =~ m!(?:([\w:]+)::)?(\w+)$! ;
 
     if (defined &DynaLoader::mod2fname) {
        # As of 5.001m, dl_os2 appends '_'
@@ -1424,9 +1656,9 @@ sub init_main {
     if ($self->{PERL_SRC}){
        $self->{PERL_LIB}     ||= $self->catdir("$self->{PERL_SRC}","lib");
        $self->{PERL_ARCHLIB} = $self->{PERL_LIB};
-       $self->{PERL_INC}     = $self->{PERL_SRC};
-       # catch a situation that has occurred a few times in the past:
+       $self->{PERL_INC}     = ($Is_Win32) ? $self->catdir($self->{PERL_LIB},"CORE") : $self->{PERL_SRC};
 
+       # catch a situation that has occurred a few times in the past:
        unless (
                -s $self->catfile($self->{PERL_SRC},'cflags')
                or
@@ -1435,6 +1667,8 @@ sub init_main {
                -s $self->catfile($self->{PERL_SRC},'perlshr_attr.opt')
                or
                $Is_Mac
+               or
+               $Is_Win32
               ){
            warn qq{
 You cannot build extensions below the perl source tree after executing
@@ -1452,10 +1686,34 @@ from the perl source tree.
        }
     } else {
        # we should also consider $ENV{PERL5LIB} here
+        my $old = $self->{PERL_LIB} || $self->{PERL_ARCHLIB} || $self->{PERL_INC};
        $self->{PERL_LIB}     ||= $Config::Config{privlibexp};
        $self->{PERL_ARCHLIB} ||= $Config::Config{archlibexp};
        $self->{PERL_INC}     = $self->catdir("$self->{PERL_ARCHLIB}","CORE"); # wild guess for now
        my $perl_h;
+
+       if (not -f ($perl_h = $self->catfile($self->{PERL_INC},"perl.h"))
+           and not $old){
+           # Maybe somebody tries to build an extension with an
+           # uninstalled Perl outside of Perl build tree
+           my $found;
+           for my $dir (@INC) {
+             $found = $dir, last if -e $self->catdir($dir, "Config.pm");
+           }
+           if ($found) {
+             my $inc = dirname $found;
+             if (-e $self->catdir($inc, "perl.h")) {
+               $self->{PERL_LIB}          = $found;
+               $self->{PERL_ARCHLIB}      = $found;
+               $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.
@@ -1540,14 +1798,13 @@ usually solves this kind of problem.
     # all the installation path variables to literally $(PREFIX), so
     # the user can still say make PREFIX=foo
     my($configure_prefix) = $Config{'prefix'};
-    $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS;
+    $configure_prefix = VMS::Filespec::unixify($configure_prefix) if $Is_VMS;
     $self->{PREFIX} ||= $configure_prefix;
 
 
     my($install_variable,$search_prefix,$replace_prefix);
 
-    # The rule, taken from Configure, is that if prefix contains perl,
-    # we shape the tree
+    # If the prefix contains perl, Configure shapes the tree as follows:
     #    perlprefix/lib/                INSTALLPRIVLIB
     #    perlprefix/lib/pod/
     #    perlprefix/lib/site_perl/     INSTALLSITELIB
@@ -1559,6 +1816,11 @@ usually solves this kind of problem.
     #    prefix/lib/perl5/site_perl/   INSTALLSITELIB
     #    prefix/bin/                   INSTALLBIN
     #    prefix/lib/perl5/man/         INSTALLMAN1DIR
+    #
+    # The above results in various kinds of breakage on various
+    # platforms, so we cope with it as follows: if prefix/lib/perl5
+    # or prefix/lib/perl5/man exist, we'll replace those instead
+    # of /prefix/{lib,man}
 
     $replace_prefix = qq[\$\(PREFIX\)];
     for $install_variable (qw/
@@ -1567,36 +1829,45 @@ usually solves this kind of problem.
                           /) {
        $self->prefixify($install_variable,$configure_prefix,$replace_prefix);
     }
-    $search_prefix = $configure_prefix =~ /perl/ ?
-       $self->catdir($configure_prefix,"lib") :
-       $self->catdir($configure_prefix,"lib","perl5");
+    my $funkylibdir = $self->catdir($configure_prefix,"lib","perl5");
+    $funkylibdir = '' unless -d $funkylibdir;
+    $search_prefix = $funkylibdir || $self->catdir($configure_prefix,"lib");
     if ($self->{LIB}) {
        $self->{INSTALLPRIVLIB} = $self->{INSTALLSITELIB} = $self->{LIB};
        $self->{INSTALLARCHLIB} = $self->{INSTALLSITEARCH} = 
            $self->catdir($self->{LIB},$Config{'archname'});
-    } else {
-       $replace_prefix = $self->{PREFIX} =~ /perl/ ? 
-           $self->catdir(qq[\$\(PREFIX\)],"lib") :
-               $self->catdir(qq[\$\(PREFIX\)],"lib","perl5");
+    }
+    else {
+       if (-d $self->catdir($self->{PREFIX},"lib","perl5")) {
+           $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib", "perl5");
+       }
+       else {
+           $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib");
+       }
        for $install_variable (qw/
                               INSTALLPRIVLIB
                               INSTALLARCHLIB
                               INSTALLSITELIB
                               INSTALLSITEARCH
-                              /) {
+                              /)
+       {
            $self->prefixify($install_variable,$search_prefix,$replace_prefix);
        }
     }
-    $search_prefix = $configure_prefix =~ /perl/ ?
-       $self->catdir($configure_prefix,"man") :
-           $self->catdir($configure_prefix,"lib","perl5","man");
-    $replace_prefix = $self->{PREFIX} =~ /perl/ ? 
-       $self->catdir(qq[\$\(PREFIX\)],"man") :
-           $self->catdir(qq[\$\(PREFIX\)],"lib","perl5","man");
+    my $funkymandir = $self->catdir($configure_prefix,"lib","perl5","man");
+    $funkymandir = '' unless -d $funkymandir;
+    $search_prefix = $funkymandir || $self->catdir($configure_prefix,"man");
+    if (-d $self->catdir($self->{PREFIX},"lib","perl5", "man")) {
+       $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"lib", "perl5", "man");
+    }
+    else {
+       $replace_prefix = $self->catdir(qq[\$\(PREFIX\)],"man");
+    }
     for $install_variable (qw/
                           INSTALLMAN1DIR
                           INSTALLMAN3DIR
-                          /) {
+                          /)
+    {
        $self->prefixify($install_variable,$search_prefix,$replace_prefix);
     }
 
@@ -1624,6 +1895,30 @@ usually solves this kind of problem.
     }
     $self->{MAN3EXT} ||= $Config::Config{man3ext};
 
+    $self->{INSTALLHTMLPRIVLIBDIR} = $Config::Config{installhtmlprivlibdir}
+        unless defined $self->{INSTALLHTMLPRIVLIBDIR};
+    $self->{INSTALLHTMLSITELIBDIR} = $Config::Config{installhtmlsitelibdir}
+        unless defined $self->{INSTALLHTMLSITELIBDIR};
+
+    unless (defined $self->{INST_HTMLLIBDIR}){
+       if ($self->{INSTALLHTMLSITELIBDIR} =~ /^(none|\s*)$/){
+           $self->{INST_HTMLLIBDIR} = $self->{INSTALLHTMLSITELIBDIR};
+       } else {
+           $self->{INST_HTMLLIBDIR} = $self->catdir($self->curdir,'blib','html','lib');
+       }
+    }
+
+    $self->{INSTALLHTMLSCRIPTDIR} = $Config::Config{installhtmlscriptdir}
+        unless defined $self->{INSTALLHTMLSCRIPTDIR};
+    unless (defined $self->{INST_HTMLSCRIPTDIR}){
+       if ($self->{INSTALLHTMLSCRIPTDIR} =~ /^(none|\s*)$/){
+           $self->{INST_HTMLSCRIPTDIR} = $self->{INSTALLHTMLSCRIPTDIR};
+       } else {
+           $self->{INST_HTMLSCRIPTDIR} = $self->catdir($self->curdir,'blib','html','bin');
+       }
+    }
+    $self->{HTMLEXT} ||= $Config::Config{htmlext} || 'html';
+
 
     # Get some stuff out of %Config if we haven't yet done so
     print STDOUT "CONFIG must be an array ref\n"
@@ -1696,9 +1991,9 @@ usually solves this kind of problem.
     foreach $component ($self->{PERL_SRC}, $self->path(), $Config::Config{binexp}) {
        push @defpath, $component if defined $component;
     }
-    $self->{PERL} =
-        $self->find_perl(5.0, [ $^X, 'miniperl','perl','perl5',"perl$]" ],
-           \@defpath, $Verbose ) unless ($self->{PERL});
+    $self->{PERL} ||=
+        $self->find_perl(5.0, [ $self->canonpath($^X), 'miniperl','perl','perl5',"perl$]" ],
+           \@defpath, $Verbose );
     # don't check if perl is executable, maybe they have decided to
     # supply switches with perl
 
@@ -1711,7 +2006,7 @@ usually solves this kind of problem.
 
 Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH,
 OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, NOOP, FIRST_MAKEFILE,
-MAKEFILE, NOECHO, RM_F, RM_RF, TOUCH, CP, MV, CHMOD, UMASK_NULL
+MAKEFILE, NOECHO, RM_F, RM_RF, TEST_F, TOUCH, CP, MV, CHMOD, UMASK_NULL
 
 =cut
 
@@ -1769,10 +2064,12 @@ sub init_others {       # --- Initialize Other Attributes
     $self->{RM_F}  ||= "rm -f";
     $self->{RM_RF} ||= "rm -rf";
     $self->{TOUCH} ||= "touch";
+    $self->{TEST_F} ||= "test -f";
     $self->{CP} ||= "cp";
     $self->{MV} ||= "mv";
     $self->{CHMOD} ||= "chmod";
     $self->{UMASK_NULL} ||= "umask 0";
+    $self->{DEV_NULL} ||= "> /dev/null 2>&1";
 }
 
 =item install (o)
@@ -1814,6 +2111,8 @@ pure_perl_install ::
                $(INST_ARCHLIB) $(INSTALLARCHLIB) \
                $(INST_BIN) $(INSTALLBIN) \
                $(INST_SCRIPT) $(INSTALLSCRIPT) \
+               $(INST_HTMLLIBDIR) $(INSTALLHTMLPRIVLIBDIR) \
+               $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \
                $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
                $(INST_MAN3DIR) $(INSTALLMAN3DIR)
        }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
@@ -1828,13 +2127,16 @@ pure_site_install ::
                $(INST_ARCHLIB) $(INSTALLSITEARCH) \
                $(INST_BIN) $(INSTALLBIN) \
                $(INST_SCRIPT) $(INSTALLSCRIPT) \
+               $(INST_HTMLLIBDIR) $(INSTALLHTMLSITELIBDIR) \
+               $(INST_HTMLSCRIPTDIR) $(INSTALLHTMLSCRIPTDIR) \
                $(INST_MAN1DIR) $(INSTALLMAN1DIR) \
                $(INST_MAN3DIR) $(INSTALLMAN3DIR)
        }.$self->{NOECHO}.q{$(WARN_IF_OLD_PACKLIST) \
                }.$self->catdir('$(PERL_ARCHLIB)','auto','$(FULLEXT)').q{
 
 doc_perl_install ::
-       }.$self->{NOECHO}.q{$(DOC_INSTALL) \
+       -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB)
+       -}.$self->{NOECHO}.q{$(DOC_INSTALL) \
                "Module" "$(NAME)" \
                "installed into" "$(INSTALLPRIVLIB)" \
                LINKTYPE "$(LINKTYPE)" \
@@ -1843,7 +2145,8 @@ doc_perl_install ::
                >> }.$self->catfile('$(INSTALLARCHLIB)','perllocal.pod').q{
 
 doc_site_install ::
-       }.$self->{NOECHO}.q{$(DOC_INSTALL) \
+       -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB)
+       -}.$self->{NOECHO}.q{$(DOC_INSTALL) \
                "Module" "$(NAME)" \
                "installed into" "$(INSTALLSITELIB)" \
                LINKTYPE "$(LINKTYPE)" \
@@ -1870,7 +2173,7 @@ uninstall_from_sitedirs ::
 
 =item installbin (o)
 
-Defines targets to install EXE_FILES.
+Defines targets to make and to install EXE_FILES.
 
 =cut
 
@@ -1888,22 +2191,31 @@ sub installbin {
        $fromto{$from}=$to;
     }
     @to   = values %fromto;
-    push(@m, "
+    push(@m, qq{
 EXE_FILES = @{$self->{EXE_FILES}}
 
-all :: @to
+} . ($Is_Win32
+  ? q{FIXIN = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
+    -e "system qq[pl2bat.bat ].shift"
+} : q{FIXIN = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::MakeMaker \
+    -e "MY->fixin(shift)"
+}).qq{
+pure_all :: @to
+       $self->{NOECHO}\$(NOOP)
 
 realclean ::
        $self->{RM_F} @to
-");
+});
 
     while (($from,$to) = each %fromto) {
        last unless defined $from;
        my $todir = dirname($to);
        push @m, "
-$to: $from $self->{MAKEFILE} $todir/.exists
+$to: $from $self->{MAKEFILE} " . $self->catdir($todir,'.exists') . "
        $self->{NOECHO}$self->{RM_F} $to
        $self->{CP} $from $to
+       \$(FIXIN) $to
+       -$self->{NOECHO}\$(CHMOD) \$(PERM_RWX) $to
 ";
     }
     join "", @m;
@@ -2136,6 +2448,16 @@ MAP_PRELIBS   = $Config::Config{libs} $Config::Config{cryptlib}
        $libperl   = "$dir/$libperl";
        $lperl   ||= "libperl$self->{LIB_EXT}";
        $lperl     = "$dir/$lperl";
+
+        if (! -f $libperl and ! -f $lperl) {
+          # We did not find a static libperl. Maybe there is a shared one?
+          if ($^O eq 'solaris' or $^O eq 'sunos') {
+            $lperl  = $libperl = "$dir/$Config::Config{libperl}";
+            # SUNOS ld does not take the full path to a shared library
+            $libperl = '' if $^O eq 'sunos';
+          }
+        }
+
        print STDOUT "Warning: $libperl not found
     If you're going to build a static perl binary, make sure perl is installed
     otherwise ignore this warning\n"
@@ -2156,10 +2478,17 @@ MAP_LIBPERL = $libperl
     foreach $catfile (@$extra){
        push @m, "\tcat $catfile >> \$\@\n";
     }
+    # SUNOS ld does not take the full path to a shared library
+    my $llibperl = ($libperl)?'$(MAP_LIBPERL)':'-lperl';
 
-    push @m, "
+    # Brain dead solaris linker does not use LD_RUN_PATH?
+    # This fixes dynamic extensions which need shared libs
+    my $ldfrom = ($^O eq 'solaris')?
+           join(' ', map "-R$_", split /:/, $self->{LD_RUN_PATH}):'';
+
+push @m, "
 \$(MAP_TARGET) :: $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) \$(INST_ARCHAUTODIR)/extralibs.all
-       \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) \$(MAP_LIBPERL) \$(MAP_STATIC) `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
+       \$(MAP_LINKCMD) -o \$\@ \$(OPTIMIZE) $tmp/perlmain\$(OBJ_EXT) $ldfrom \$(MAP_STATIC) $llibperl `cat \$(INST_ARCHAUTODIR)/extralibs.all` \$(MAP_PRELIBS)
        $self->{NOECHO}echo 'To install the new \"\$(MAP_TARGET)\" binary, call'
        $self->{NOECHO}echo '    make -f $makefilename inst_perl MAP_TARGET=\$(MAP_TARGET)'
        $self->{NOECHO}echo 'To remove the intermediate files say'
@@ -2172,15 +2501,19 @@ $tmp/perlmain\$(OBJ_EXT): $tmp/perlmain.c
     push @m, qq{
 $tmp/perlmain.c: $makefilename}, q{
        }.$self->{NOECHO}.q{echo Writing $@
-       }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -e 'use ExtUtils::Miniperl; \\
-               writemain(grep s#.*/auto/##, qw|$(MAP_STATIC)|)' > $@t && mv $@t $@
+       }.$self->{NOECHO}.q{$(PERL) $(MAP_PERLINC) -MExtUtils::Miniperl \\
+               -e "writemain(grep s#.*/auto/##, split(q| |, q|$(MAP_STATIC)|))" > $@t && $(MV) $@t $@
 
 };
+    push @m, "\t",$self->{NOECHO}.q{$(PERL) $(INSTALLSCRIPT)/fixpmain
+} if (defined (&Dos::UseLFN) && Dos::UseLFN()==0);
+
 
     push @m, q{
 doc_inst_perl:
        }.$self->{NOECHO}.q{echo Appending installation info to $(INSTALLARCHLIB)/perllocal.pod
-       }.$self->{NOECHO}.q{$(DOC_INSTALL) \
+       -}.$self->{NOECHO}.q{$(MKPATH) $(INSTALLARCHLIB)
+       -}.$self->{NOECHO}.q{$(DOC_INSTALL) \
                "Perl binary" "$(MAP_TARGET)" \
                MAP_STATIC "$(MAP_STATIC)" \
                MAP_EXTRA "`cat $(INST_ARCHAUTODIR)/extralibs.all`" \
@@ -2226,11 +2559,13 @@ $(OBJECT) : $(FIRST_MAKEFILE)
 }.$self->{MAKEFILE}.q{ : Makefile.PL $(CONFIGDEP)
        }.$self->{NOECHO}.q{echo "Makefile out-of-date with respect to $?"
        }.$self->{NOECHO}.q{echo "Cleaning current config before rebuilding Makefile..."
-       -}.$self->{NOECHO}.q{mv }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{
-       -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean >/dev/null 2>&1 || true
+       -}.$self->{NOECHO}.q{$(RM_F) }."$self->{MAKEFILE}.old".q{
+       -}.$self->{NOECHO}.q{$(MV) }."$self->{MAKEFILE} $self->{MAKEFILE}.old".q{
+       -$(MAKE) -f }.$self->{MAKEFILE}.q{.old clean $(DEV_NULL) || $(NOOP)
        $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" Makefile.PL }.join(" ",map(qq["$_"],@ARGV)).q{
-       }.$self->{NOECHO}.q{echo ">>> Your Makefile has been rebuilt. <<<"
-       }.$self->{NOECHO}.q{echo ">>> Please rerun the make command.  <<<"; false
+       }.$self->{NOECHO}.q{echo "==> Your Makefile has been rebuilt. <=="
+       }.$self->{NOECHO}.q{echo "==> Please rerun the make command.  <=="
+       false
 
 # To change behavior to :: would be nice, but would break Tk b9.02
 # so you find such a warning below the dist target.
@@ -2250,7 +2585,8 @@ put them into the INST_* directories.
 
 sub manifypods {
     my($self, %attribs) = @_;
-    return "\nmanifypods :\n\t$self->{NOECHO}\$(NOOP)\n" unless %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
+    return "\nmanifypods : pure_all\n\t$self->{NOECHO}\$(NOOP)\n" unless
+       %{$self->{MAN3PODS}} or %{$self->{MAN1PODS}};
     my($dist);
     my($pod2man_exe);
     if (defined $self->{PERL_SRC}) {
@@ -2258,7 +2594,11 @@ sub manifypods {
     } else {
        $pod2man_exe = $self->catfile($Config{scriptdirexp},'pod2man');
     }
-    unless ($self->perl_script($pod2man_exe)) {
+    unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
+      # Maybe a build by uninstalled Perl?
+      $pod2man_exe = $self->catfile($self->{PERL_INC}, "pod", "pod2man");
+    }
+    unless ($pod2man_exe = $self->perl_script($pod2man_exe)) {
        # No pod2man but some MAN3PODS to be installed
        print <<END;
 
@@ -2271,13 +2611,14 @@ END
     my(@m);
     push @m,
 qq[POD2MAN_EXE = $pod2man_exe\n],
-q[POD2MAN = $(PERL) -we '%m=@ARGV;for (keys %m){' \\
--e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "].$self->{MAKEFILE}.q[";' \\
+qq[POD2MAN = \$(PERL) -we '%m=\@ARGV;for (keys %m){' \\\n],
+q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
+ $self->{MAKEFILE}, q[";' \\
 -e 'print "Manifying $$m{$$_}\n";' \\
 -e 'system(qq[$$^X ].q["-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" $(POD2MAN_EXE) ].qq[$$_>$$m{$$_}])==0 or warn "Couldn\\047t install $$m{$$_}\n";' \\
--e 'chmod 0644, $$m{$$_} or warn "chmod 644 $$m{$$_}: $$!\n";}'
+-e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: $$!\n";}'
 ];
-    push @m, "\nmanifypods : ";
+    push @m, "\nmanifypods : pure_all ";
     push @m, join " \\\n\t", keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}};
 
     push(@m,"\n");
@@ -2384,7 +2725,9 @@ sub nicetext {
 
 =item parse_version
 
-parse a file and return what you think is $VERSION in this file set to
+parse a file and return what you think is $VERSION in this file set to.
+It will return the string "undef" if it can't figure out what $VERSION
+is.
 
 =cut
 
@@ -2399,24 +2742,53 @@ sub parse_version {
        $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
        next if $inpod;
        chop;
-       next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/;
+       # next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/;
+       next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
        my $eval = qq{
            package ExtUtils::MakeMaker::_version;
            no strict;
 
-           \$$1=undef; do {
+           local $1$2;
+           \$$2=undef; do {
                $_
-           }; \$$1
+           }; \$$2
        };
        local($^W) = 0;
-       $result = eval($eval) || 0;
-       die "Could not eval '$eval' in $parsefile: $@" if $@;
+       $result = eval($eval);
+       warn "Could not eval '$eval' in $parsefile: $@" if $@;
+       $result = "undef" unless defined $result;
        last;
     }
     close FH;
     return $result;
 }
 
+=item parse_abstract
+
+parse a file and return what you think is the ABSTRACT
+
+=cut
+
+sub parse_abstract {
+    my($self,$parsefile) = @_;
+    my $result;
+    local *FH;
+    local $/ = "\n";
+    open(FH,$parsefile) or die "Could not open '$parsefile': $!";
+    my $inpod = 0;
+    my $package = $self->{DISTNAME};
+    $package =~ s/-/::/g;
+    while (<FH>) {
+        $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
+        next if !$inpod;
+        chop;
+        next unless /^($package\s-\s)(.*)/;
+        $result = $2;
+        last;
+    }
+    close FH;
+    return $result;
+}
 
 =item pasthru (o)
 
@@ -2449,7 +2821,7 @@ Takes no argument, returns the environment variable PATH as an array.
 
 sub path {
     my($self) = @_;
-    my $path_sep = $Is_OS2 ? ";" : ":";
+    my $path_sep = ($Is_OS2 || $Is_Dos) ? ";" : ":";
     my $path = $ENV{PATH};
     $path =~ s:\\:/:g if $Is_OS2;
     my @path = split $path_sep, $path;
@@ -2505,7 +2877,7 @@ $(PERL_INC)/config.h       $(PERL_INC)/mg.h           $(PERL_INC)/scope.h    \
 $(PERL_INC)/cop.h          $(PERL_INC)/op.h           $(PERL_INC)/sv.h      \
 $(PERL_INC)/cv.h           $(PERL_INC)/opcode.h       $(PERL_INC)/unixish.h  \
 $(PERL_INC)/dosish.h       $(PERL_INC)/patchlevel.h   $(PERL_INC)/util.h     \
-$(PERL_INC)/embed.h        $(PERL_INC)/perl.h                               \
+$(PERL_INC)/embed.h        $(PERL_INC)/perl.h         $(PERL_INC)/iperlsys.h \
 $(PERL_INC)/form.h         $(PERL_INC)/perly.h
 
 $(OBJECT) : $(PERL_HDRS)
@@ -2516,6 +2888,91 @@ $(OBJECT) : $(PERL_HDRS)
     join "\n", @m;
 }
 
+=item ppd
+
+Defines target that creates a PPD (Perl Package Description) file
+for a binary distribution.
+
+=cut
+
+sub ppd {
+    my($self) = @_;
+    my(@m);
+    if ($self->{ABSTRACT_FROM}){
+        $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
+            Carp::carp "WARNING: Setting ABSTRACT via file '$self->{ABSTRACT_FROM}' failed\n";
+    }
+    my ($pack_ver) = join ",", (split (/\./, $self->{VERSION}), (0) x 4) [0 .. 3];
+    push(@m, "# Creates a PPD (Perl Package Description) for a binary distribution.\n");
+    push(@m, "ppd:\n");
+    push(@m, "\t\@\$(PERL) -e \"print qq{<SOFTPKG NAME=\\\"$self->{DISTNAME}\\\" VERSION=\\\"$pack_ver\\\">\\n}");
+    push(@m, ". qq{\\t<TITLE>$self->{DISTNAME}</TITLE>\\n}");
+    my $abstract = $self->{ABSTRACT};
+    $abstract =~ s/\n/\\n/sg;
+    $abstract =~ s/</&lt;/g;
+    $abstract =~ s/>/&gt;/g;
+    push(@m, ". qq{\\t<ABSTRACT>$abstract</ABSTRACT>\\n}");
+    my ($author) = $self->{AUTHOR};
+    $author =~ s/</&lt;/g;
+    $author =~ s/>/&gt;/g;
+    $author =~ s/@/\\@/g;
+    push(@m, ". qq{\\t<AUTHOR>$author</AUTHOR>\\n}");
+    push(@m, ". qq{\\t<IMPLEMENTATION>\\n}");
+    my ($prereq);
+    foreach $prereq (sort keys %{$self->{PREREQ_PM}}) {
+        my $pre_req = $prereq;
+        $pre_req =~ s/::/-/g;
+        my ($dep_ver) = join ",", (split (/\./, $self->{PREREQ_PM}{$prereq}), (0) x 4) [0 .. 3];
+        push(@m, ". qq{\\t\\t<DEPENDENCY NAME=\\\"$pre_req\\\" VERSION=\\\"$dep_ver\\\" />\\n}");
+    }
+    push(@m, ". qq{\\t\\t<OS NAME=\\\"\$(OSNAME)\\\" />\\n}");
+    push(@m, ". qq{\\t\\t<ARCHITECTURE NAME=\\\"$Config{'archname'}\\\" />\\n}");
+    my ($bin_location) = $self->{BINARY_LOCATION};
+    $bin_location =~ s/\\/\\\\/g;
+    if ($self->{PPM_INSTALL_SCRIPT}) {
+        if ($self->{PPM_INSTALL_EXEC}) {
+            push(@m, " . qq{\\t\\t<INSTALL EXEC=\\\"$self->{PPM_INSTALL_EXEC}\\\">$self->{PPM_INSTALL_SCRIPT}</INSTALL>\\n}");
+        }
+        else {
+            push(@m, " . qq{\\t\\t<INSTALL>$self->{PPM_INSTALL_SCRIPT}</INSTALL>\\n}");
+        }
+    }
+    push(@m, ". qq{\\t\\t<CODEBASE HREF=\\\"$bin_location\\\" />\\n}");
+    push(@m, ". qq{\\t</IMPLEMENTATION>\\n}");
+    push(@m, ". qq{</SOFTPKG>\\n}\" > $self->{DISTNAME}.ppd");
+
+    join("", @m);   
+}
+
+=item perm_rw (o)
+
+Returns the attribute C<PERM_RW> or the string C<644>.
+Used as the string that is passed
+to the C<chmod> command to set the permissions for read/writeable files.
+MakeMaker chooses C<644> because it has turned out in the past that
+relying on the umask provokes hard-to-track bug reports.
+When the return value is used by the perl function C<chmod>, it is
+interpreted as an octal value.
+
+=cut
+
+sub perm_rw {
+    shift->{PERM_RW} || "644";
+}
+
+=item perm_rwx (o)
+
+Returns the attribute C<PERM_RWX> or the string C<755>,
+i.e. the string that is passed
+to the C<chmod> command to set the permissions for executable files.
+See also perl_rw.
+
+=cut
+
+sub perm_rwx {
+    shift->{PERM_RWX} || "755";
+}
+
 =item pm_to_blib
 
 Defines target that copies all files in the hash PM to their
@@ -2530,7 +2987,7 @@ sub pm_to_blib {
 pm_to_blib: $(TO_INST_PM)
        }.$self->{NOECHO}.q{$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \
        "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \
-        -e 'pm_to_blib({qw{$(PM_TO_BLIB)}},"}.$autodir.q{")'
+        -e "pm_to_blib({qw{$(PM_TO_BLIB)}},'}.$autodir.q{')"
        }.$self->{NOECHO}.q{$(TOUCH) $@
 };
 }
@@ -2599,12 +3056,18 @@ sub processPL {
     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}];
+       foreach $target (@$list) {
        push @m, "
-all :: $self->{PL_FILES}->{$plfile}
+all :: $target
+       $self->{NOECHO}\$(NOOP)
 
-$self->{PL_FILES}->{$plfile} :: $plfile
-       \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile
+$target :: $plfile
+       \$(PERL) -I\$(INST_ARCHLIB) -I\$(INST_LIB) -I\$(PERL_ARCHLIB) -I\$(PERL_LIB) $plfile $target
 ";
+       }
     }
     join "", @m;
 }
@@ -2623,7 +3086,9 @@ sub realclean {
 realclean purge ::  clean
 ');
     # realclean subdirectories first (already cleaned)
-    my $sub = "\t-cd %s && test -f %s && \$(MAKE) %s realclean\n";
+    my $sub = ($Is_Win32  &&  Win32::IsWin95()) ?
+      "\tcd %s\n\t\$(TEST_F) %s\n\t\$(MAKE) %s realclean\n\tcd ..\n" :
+      "\t-cd %s && \$(TEST_F) %s && \$(MAKE) %s realclean\n";
     foreach(@{$self->{DIR}}){
        push(@m, sprintf($sub,$_,"$self->{MAKEFILE}.old","-f $self->{MAKEFILE}.old"));
        push(@m, sprintf($sub,$_,"$self->{MAKEFILE}",''));
@@ -2633,7 +3098,8 @@ realclean purge ::  clean
         push(@m, "     $self->{RM_F} \$(INST_DYNAMIC) \$(INST_BOOT)\n");
         push(@m, "     $self->{RM_F} \$(INST_STATIC)\n");
     }
-    push(@m, " $self->{RM_F} " . join(" ", values %{$self->{PM}}) . "\n");
+    push(@m, " $self->{RM_F} " . join(" ", values %{$self->{PM}}) . "\n")
+       if keys %{$self->{PM}};
     my(@otherfiles) = ($self->{MAKEFILE},
                       "$self->{MAKEFILE}.old"); # Makefiles last
     push(@otherfiles, $attribs{FILES}) if $attribs{FILES};
@@ -2651,7 +3117,11 @@ form Foo/Bar and replaces the slash with C<::>. Returns the replacement.
 
 sub replace_manpage_separator {
     my($self,$man) = @_;
-    $man =~ s,/+,::,g;
+       if ($^O eq 'uwin') {
+               $man =~ s,/+,.,g;
+       } else {
+               $man =~ s,/+,::,g;
+       }
     $man;
 }
 
@@ -2698,14 +3168,14 @@ END
 
     push @m,
 q{     $(AR) $(AR_STATIC_ARGS) $@ $(OBJECT) && $(RANLIB) $@
+       $(CHMOD) $(PERM_RWX) $@
        }.$self->{NOECHO}.q{echo "$(EXTRALIBS)" > $(INST_ARCHAUTODIR)/extralibs.ld
-       $(CHMOD) 755 $@
 };
-
-# Old mechanism - still available:
-
-    push @m, "\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs}."\n\n"
-       if $self->{PERL_SRC};
+    # Old mechanism - still available:
+    push @m,
+"\t$self->{NOECHO}".q{echo "$(EXTRALIBS)" >> $(PERL_SRC)/ext.libs
+}      if $self->{PERL_SRC} && $self->{EXTRALIBS};
+    push @m, "\n";
 
     push @m, $self->dir_target('$(INST_ARCHAUTODIR)');
     join('', "\n",@m);
@@ -2762,12 +3232,22 @@ Helper subroutine for subdirs
 sub subdir_x {
     my($self, $subdir) = @_;
     my(@m);
-    qq{
+    if ($Is_Win32 && Win32::IsWin95()) {
+       return <<EOT;
+subdirs ::
+       cd $subdir
+       \$(MAKE) all \$(PASTHRU)
+       cd ..
+EOT
+    }
+    else {
+       return <<EOT;
 
 subdirs ::
        $self->{NOECHO}cd $subdir && \$(MAKE) all \$(PASTHRU)
 
-};
+EOT
+    }
 }
 
 =item subdirs (o)
@@ -2809,27 +3289,32 @@ sub test {
 # --- Test and Installation Sections ---
 
     my($self, %attribs) = @_;
-    my($tests) = $attribs{TESTS} || (-d "t" ? "t/*.t" : "");
+    my $tests = $attribs{TESTS};
+    if (!$tests && -d 't') {
+       $tests = $Is_Win32 ? join(' ', <t\\*.t>) : 't/*.t';
+    }
+    # note: 'test.pl' name is also hardcoded in init_dirscan()
     my(@m);
     push(@m,"
 TEST_VERBOSE=0
 TEST_TYPE=test_\$(LINKTYPE)
 TEST_FILE = test.pl
+TEST_FILES = $tests
 TESTDB_SW = -d
 
 testdb :: testdb_\$(LINKTYPE)
 
 test :: \$(TEST_TYPE)
 ");
-    push(@m, map("\t$self->{NOECHO}cd $_ && test -f $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
+    push(@m, map("\t$self->{NOECHO}cd $_ && \$(TEST_F) $self->{MAKEFILE} && \$(MAKE) test \$(PASTHRU)\n",
                 @{$self->{DIR}}));
     push(@m, "\t$self->{NOECHO}echo 'No tests defined for \$(NAME) extension.'\n")
        unless $tests or -f "test.pl" or @{$self->{DIR}};
     push(@m, "\n");
 
     push(@m, "test_dynamic :: pure_all\n");
-    push(@m, $self->test_via_harness('$(FULLPERL)', $tests)) if $tests;
-    push(@m, $self->test_via_script('$(FULLPERL)', 'test.pl')) if -f "test.pl";
+    push(@m, $self->test_via_harness('$(FULLPERL)', '$(TEST_FILES)')) if $tests;
+    push(@m, $self->test_via_script('$(FULLPERL)', '$(TEST_FILE)')) if -f "test.pl";
     push(@m, "\n");
 
     push(@m, "testdb_dynamic :: pure_all\n");
@@ -2841,8 +3326,8 @@ test :: \$(TEST_TYPE)
 
     if ($self->needs_linking()) {
        push(@m, "test_static :: pure_all \$(MAP_TARGET)\n");
-       push(@m, $self->test_via_harness('./$(MAP_TARGET)', $tests)) if $tests;
-       push(@m, $self->test_via_script('./$(MAP_TARGET)', 'test.pl')) if -f "test.pl";
+       push(@m, $self->test_via_harness('./$(MAP_TARGET)', '$(TEST_FILES)')) if $tests;
+       push(@m, $self->test_via_script('./$(MAP_TARGET)', '$(TEST_FILE)')) if -f "test.pl";
        push(@m, "\n");
        push(@m, "testdb_static :: pure_all \$(MAP_TARGET)\n");
        push(@m, $self->test_via_script('./$(MAP_TARGET) $(TESTDB_SW)', '$(TEST_FILE)'));
@@ -2862,7 +3347,8 @@ Helper method to write the test targets
 
 sub test_via_harness {
     my($self, $perl, $tests) = @_;
-    "\tPERL_DL_NONLAZY=1 $perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
+    $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
+    "\t$perl".q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e 'use Test::Harness qw(&runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !."$tests\n";
 }
 
 =item test_via_script (o)
@@ -2873,7 +3359,8 @@ Other helper method for test.
 
 sub test_via_script {
     my($self, $perl, $script) = @_;
-    qq{\tPERL_DL_NONLAZY=1 $perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
+    $perl = "PERL_DL_NONLAZY=1 $perl" unless $Is_Win32;
+    qq{\t$perl}.q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) }.qq{$script
 };
 }
 
@@ -2912,27 +3399,23 @@ sub tools_other {
 SHELL = $bin_sh
 };
 
-    for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TOUCH UMASK_NULL / ) {
+    for (qw/ CHMOD CP LD MV NOOP RM_F RM_RF TEST_F TOUCH UMASK_NULL DEV_NULL/ ) {
        push @m, "$_ = $self->{$_}\n";
     }
 
-
     push @m, q{
 # The following is a portable way to say mkdir -p
 # To see which directories are created, change the if 0 to if 1
-MKPATH = $(PERL) -wle '$$"="/"; foreach $$p (@ARGV){' \\
--e 'next if -d $$p; my(@p); foreach(split(/\//,$$p)){' \\
--e 'push(@p,$$_); next if -d "@p/"; print "mkdir @p" if 0;' \\
--e 'mkdir("@p",0777)||die $$! } } exit 0;'
+MKPATH = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e mkpath
 
 # This helps us to minimize the effect of the .exists files A yet
 # better solution would be to have a stable file in the perl
 # distribution with a timestamp of zero. But this solution doesn't
 # need any changes to the core distribution and works with older perls
-EQUALIZE_TIMESTAMP = $(PERL) -we 'open F, ">$$ARGV[1]"; close F;' \\
--e 'utime ((stat("$$ARGV[0]"))[8,9], $$ARGV[1])'
+EQUALIZE_TIMESTAMP = $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -MExtUtils::Command -e eqtime
 };
 
+
     return join "", @m if $self->{PARENT};
 
     push @m, q{
@@ -2947,7 +3430,7 @@ UNINST=0
 VERBINST=1
 
 MOD_INSTALL = $(PERL) -I$(INST_LIB) -I$(PERL_LIB) -MExtUtils::Install \
--e 'install({@ARGV},"$(VERBINST)",0,"$(UNINST)");'
+-e "install({@ARGV},'$(VERBINST)',0,'$(UNINST)');"
 
 DOC_INSTALL = $(PERL) -e '$$\="\n\n";' \
 -e 'print "=head2 ", scalar(localtime), ": C<", shift, ">", " L<", shift, ">";' \
@@ -3009,9 +3492,11 @@ sub tool_xsubpp {
        }
     }
 
+    my $xsubpp = "xsubpp";
+
     return qq{
 XSUBPPDIR = $xsdir
-XSUBPP = \$(XSUBPPDIR)/xsubpp
+XSUBPP = \$(XSUBPPDIR)/$xsubpp
 XSPROTOARG = $self->{XSPROTOARG}
 XSUBPPDEPS = @tmdeps
 XSUBPPARGS = @tmargs
@@ -3086,10 +3571,15 @@ sub top_targets {
     my(@m);
     push @m, '
 #all ::        config $(INST_PM) subdirs linkext manifypods
+';
 
-all :: pure_all manifypods
+    push @m, '
+all :: pure_all htmlifypods manifypods
        '.$self->{NOECHO}.'$(NOOP)
-
+' 
+         unless $self->{SKIPHASH}{'all'};
+    
+    push @m, '
 pure_all :: config pm_to_blib subdirs linkext
        '.$self->{NOECHO}.'$(NOOP)
 
@@ -3114,6 +3604,24 @@ config :: Version_check
 
     push @m, $self->dir_target(qw[$(INST_AUTODIR) $(INST_LIBDIR) $(INST_ARCHAUTODIR)]);
 
+    if (%{$self->{HTMLLIBPODS}}) {
+       push @m, qq[
+config :: \$(INST_HTMLLIBDIR)/.exists
+       $self->{NOECHO}\$(NOOP)
+
+];
+       push @m, $self->dir_target(qw[$(INST_HTMLLIBDIR)]);
+    }
+
+    if (%{$self->{HTMLSCRIPTPODS}}) {
+       push @m, qq[
+config :: \$(INST_HTMLSCRIPTDIR)/.exists
+       $self->{NOECHO}\$(NOOP)
+
+];
+       push @m, $self->dir_target(qw[$(INST_HTMLSCRIPTDIR)]);
+    }
+
     if (%{$self->{MAN1PODS}}) {
        push @m, qq[
 config :: \$(INST_MAN1DIR)/.exists
@@ -3144,7 +3652,7 @@ help:
 Version_check:
        }.$self->{NOECHO}.q{$(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \
                -MExtUtils::MakeMaker=Version_check \
-               -e 'Version_check("$(MM_VERSION)")'
+               -e "Version_check('$(MM_VERSION)')"
 };
 
     join('',@m);
@@ -3152,7 +3660,7 @@ Version_check:
 
 =item writedoc
 
-Obsolete, depecated method. Not used since Version 5.21.
+Obsolete, deprecated method. Not used since Version 5.21.
 
 =cut
 
@@ -3176,7 +3684,22 @@ sub xs_c {
     return '' unless $self->needs_linking();
     '
 .xs.c:
-       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >$*.tc && mv $*.tc $@
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
+';
+}
+
+=item xs_cpp (o)
+
+Defines the suffix rules to compile XS files to C++.
+
+=cut
+
+sub xs_cpp {
+    my($self) = shift;
+    return '' unless $self->needs_linking();
+    '
+.xs.cpp:
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.cpp
 ';
 }
 
@@ -3192,11 +3715,39 @@ sub xs_o {      # many makes are too dumb to use xs_c then c_o
     return '' unless $self->needs_linking();
     '
 .xs$(OBJ_EXT):
-       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs >xstmp.c && mv xstmp.c $*.c
+       $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSPROTOARG) $(XSUBPPARGS) $*.xs > $*.xsc && $(MV) $*.xsc $*.c
        $(CCCMD) $(CCCDLFLAGS) -I$(PERL_INC) $(DEFINE) $*.c
 ';
 }
 
+=item perl_archive
+
+This is internal method that returns path to libperl.a equivalent
+to be linked to dynamic extensions. UNIX does not have one but OS2
+and Win32 do.
+
+=cut 
+
+sub perl_archive
+{
+ return '$(PERL_INC)' . "/$Config{libperl}" if $^O eq "beos";
+ return "";
+}
+
+=item export_list
+
+This is internal method that returns name of a file that is
+passed to linker to define symbols to be exported.
+UNIX does not have one but OS2 and Win32 do.
+
+=cut 
+
+sub export_list
+{
+ return "";
+}
+
+
 1;
 
 =back