This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to ExtUtils::MakeMaker 6.28
[perl5.git] / lib / ExtUtils / MM_Any.pm
index f03985b..8369e63 100644 (file)
@@ -2,11 +2,22 @@ package ExtUtils::MM_Any;
 
 use strict;
 use vars qw($VERSION @ISA);
-$VERSION = 0.09;
-@ISA = qw(File::Spec);
+$VERSION = '0.13';
 
-use Config;
 use File::Spec;
+BEGIN { @ISA = qw(File::Spec); }
+
+# We need $Verbose
+use ExtUtils::MakeMaker qw($Verbose);
+
+use ExtUtils::MakeMaker::Config;
+
+
+# So we don't have to keep calling the methods over and over again,
+# we have these globals to cache the values.  Faster and shrtr.
+my $Curdir  = __PACKAGE__->curdir;
+my $Rootdir = __PACKAGE__->rootdir;
+my $Updir   = __PACKAGE__->updir;
 
 
 =head1 NAME
@@ -37,36 +48,45 @@ temporary solution.
 
 B<THIS MAY BE TEMPORARY!>
 
-=head1 Inherently Cross-Platform Methods
 
-These are methods which are by their nature cross-platform and should
-always be cross-platform.
+=head1 METHODS
 
-=over 4
+Any methods marked I<Abstract> must be implemented by subclasses.
 
-=item installvars
 
-    my @installvars = $mm->installvars;
+=head2 Cross-platform helper methods
 
-A list of all the INSTALL* variables without the INSTALL prefix.  Useful
-for iteration or building related variable sets.
+These are methods which help writing cross-platform code.
 
-=cut
 
-sub installvars {
-    return qw(PRIVLIB SITELIB  VENDORLIB
-              ARCHLIB SITEARCH VENDORARCH
-              BIN     SITEBIN  VENDORBIN
-              SCRIPT
-              MAN1DIR SITEMAN1DIR VENDORMAN1DIR
-              MAN3DIR SITEMAN3DIR VENDORMAN3DIR
-             );
-}
 
-=item os_flavor_is
+=head3 os_flavor  I<Abstract>
+
+    my @os_flavor = $mm->os_flavor;
+
+@os_flavor is the style of operating system this is, usually
+corresponding to the MM_*.pm file we're using.  
+
+The first element of @os_flavor is the major family (ie. Unix,
+Windows, VMS, OS/2, etc...) and the rest are sub families.
+
+Some examples:
+
+    Cygwin98       ('Unix',  'Cygwin', 'Cygwin9x')
+    Windows NT     ('Win32', 'WinNT')
+    Win98          ('Win32', 'Win9x')
+    Linux          ('Unix',  'Linux')
+    MacOS X        ('Unix',  'Darwin', 'MacOS', 'MacOS X')
+    OS/2           ('OS/2')
+
+This is used to write code for styles of operating system.  
+See os_flavor_is() for use.
+
+
+=head3 os_flavor_is
 
-    $mm->os_flavor_is($this_flavor);
-    $mm->os_flavor_is(@one_of_these_flavors);
+    my $is_this_flavor = $mm->os_flavor_is($this_flavor);
+    my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
 
 Checks to see if the current operating system is one of the given flavors.
 
@@ -87,66 +107,8 @@ sub os_flavor_is {
     return (grep { $flavors{$_} } @_) ? 1 : 0;
 }
 
-=item blibdirs_target (o)
-
-    my $make_frag = $mm->blibdirs_target;
-
-Creates the blibdirs target which creates all the directories we use in
-blib/.
-
-=cut
-
-sub blibdirs_target {
-    my $self = shift;
-
-    my @dirs = map { uc "\$(INST_$_)" } qw(libdir
-                                       autodir archautodir
-                                       bin script
-                                       man1dir man3dir
-                                      );
-    my @mkpath = $self->split_command('$(NOECHO) $(MKPATH)', @dirs);
-    my @chmod  = $self->split_command('$(NOECHO) $(CHMOD) 755', @dirs);
-
-    my $make = "\nblibdirs : \n";
-    $make .= join "", map { "\t$_\n" } @mkpath, @chmod;
-    $make .= "\t\$(NOECHO) \$(TOUCH) blibdirs\n\n";
-
-    return $make;
-}
-
-
-=back
-
-=head2 File::Spec wrappers
-
-ExtUtils::MM_Any is a subclass of File::Spec.  The methods noted here
-override File::Spec.
-
-=over 4
-
-=item catfile
-
-File::Spec <= 0.83 has a bug where the file part of catfile is not
-canonicalized.  This override fixes that bug.
-
-=cut
-
-sub catfile {
-    my $self = shift;
-    return $self->canonpath($self->SUPER::catfile(@_));
-}
-
-=back
-
-=head1 Thought To Be Cross-Platform Methods
 
-These are methods which are thought to be cross-platform by virtue of
-having been written in a way to avoid incompatibilities.  They may
-require partial overrides.
-
-=over 4
-
-=item B<split_command>
+=head3 split_command
 
     my @cmds = $MM->split_command($cmd, @args);
 
@@ -154,7 +116,7 @@ Most OS have a maximum command length they can execute at once.  Large
 modules can easily generate commands well past that limit.  Its
 necessary to split long commands up into a series of shorter commands.
 
-split_command() will return a series of @cmds each processing part of
+C<split_command> will return a series of @cmds each processing part of
 the args.  Collectively they will process all the arguments.  Each
 individual line in @cmds will not be longer than the
 $self->max_exec_len being careful to take into account macro expansion.
@@ -223,7 +185,7 @@ sub _expand_macros {
 }
 
 
-=item B<echo>
+=head3 echo
 
     my @commands = $MM->echo($text);
     my @commands = $MM->echo($text, $file);
@@ -254,345 +216,476 @@ sub echo {
 }
 
 
-=item init_VERSION
+=head3 wraplist
 
-    $mm->init_VERSION
+  my $args = $mm->wraplist(@list);
 
-Initialize macros representing versions of MakeMaker and other tools
+Takes an array of items and turns them into a well-formatted list of
+arguments.  In most cases this is simply something like:
 
-MAKEMAKER: path to the MakeMaker module.
+    FOO \
+    BAR \
+    BAZ
 
-MM_VERSION: ExtUtils::MakeMaker Version
+=cut
 
-MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards 
-             compat)
+sub wraplist {
+    my $self = shift;
+    return join " \\\n\t", @_;
+}
 
-VERSION: version of your module
 
-VERSION_MACRO: which macro represents the version (usually 'VERSION')
+=head3 cd  I<Abstract>
 
-VERSION_SYM: like version but safe for use as an RCS revision number
+  my $subdir_cmd = $MM->cd($subdir, @cmds);
 
-DEFINE_VERSION: -D line to set the module version when compiling
+This will generate a make fragment which runs the @cmds in the given
+$dir.  The rough equivalent to this, except cross platform.
 
-XS_VERSION: version in your .xs file.  Defaults to $(VERSION)
+  cd $subdir && $cmd
 
-XS_VERSION_MACRO: which macro represents the XS version.
+Currently $dir can only go down one level.  "foo" is fine.  "foo/bar" is
+not.  "../foo" is right out.
 
-XS_DEFINE_VERSION: -D line to set the xs version when compiling.
+The resulting $subdir_cmd has no leading tab nor trailing newline.  This
+makes it easier to embed in a make string.  For example.
 
-Called by init_main.
+      my $make = sprintf <<'CODE', $subdir_cmd;
+  foo :
+      $(ECHO) what
+      %s
+      $(ECHO) mouche
+  CODE
 
-=cut
 
-sub init_VERSION {
-    my($self) = shift;
+=head3 oneliner  I<Abstract>
 
-    $self->{MAKEMAKER}  = $ExtUtils::MakeMaker::Filename;
-    $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
-    $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
-    $self->{VERSION_FROM} ||= '';
+  my $oneliner = $MM->oneliner($perl_code);
+  my $oneliner = $MM->oneliner($perl_code, \@switches);
 
-    if ($self->{VERSION_FROM}){
-        $self->{VERSION} = $self->parse_version($self->{VERSION_FROM});
-        if( $self->{VERSION} eq 'undef' ) {
-            require Carp;
-            Carp::carp("WARNING: Setting VERSION via file ".
-                       "'$self->{VERSION_FROM}' failed\n");
-        }
-    }
+This will generate a perl one-liner safe for the particular platform
+you're on based on the given $perl_code and @switches (a -e is
+assumed) suitable for using in a make target.  It will use the proper
+shell quoting and escapes.
 
-    # strip blanks
-    if (defined $self->{VERSION}) {
-        $self->{VERSION} =~ s/^\s+//;
-        $self->{VERSION} =~ s/\s+$//;
-    }
-    else {
-        $self->{VERSION} = '';
-    }
+$(PERLRUN) will be used as perl.
 
+Any newlines in $perl_code will be escaped.  Leading and trailing
+newlines will be stripped.  Makes this idiom much easier:
 
-    $self->{VERSION_MACRO}  = 'VERSION';
-    ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
-    $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
+    my $code = $MM->oneliner(<<'CODE', [...switches...]);
+some code here
+another line here
+CODE
 
+Usage might be something like:
 
-    # Graham Barr and Paul Marquess had some ideas how to ensure
-    # version compatibility between the *.pm file and the
-    # corresponding *.xs file. The bottomline was, that we need an
-    # XS_VERSION macro that defaults to VERSION:
-    $self->{XS_VERSION} ||= $self->{VERSION};
+    # an echo emulation
+    $oneliner = $MM->oneliner('print "Foo\n"');
+    $make = '$oneliner > somefile';
 
-    $self->{XS_VERSION_MACRO}  = 'XS_VERSION';
-    $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
+All dollar signs must be doubled in the $perl_code if you expect them
+to be interpreted normally, otherwise it will be considered a make
+macro.  Also remember to quote make macros else it might be used as a
+bareword.  For example:
 
-}
+    # Assign the value of the $(VERSION_FROM) make macro to $vf.
+    $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
 
-=item wraplist
+Its currently very simple and may be expanded sometime in the figure
+to include more flexible code and switches.
 
-Takes an array of items and turns them into a well-formatted list of
-arguments.  In most cases this is simply something like:
 
-    FOO \
-    BAR \
-    BAZ
+=head3 quote_literal  I<Abstract>
 
-=cut
+    my $safe_text = $MM->quote_literal($text);
 
-sub wraplist {
-    my $self = shift;
-    return join " \\\n\t", @_;
-}
+This will quote $text so it is interpreted literally in the shell.
 
-=item manifypods
+For example, on Unix this would escape any single-quotes in $text and
+put single-quotes around the whole thing.
 
-Defines targets and routines to translate the pods into manpages and
-put them into the INST_* directories.
 
-=cut
+=head3 escape_newlines  I<Abstract>
 
-sub manifypods {
-    my $self          = shift;
+    my $escaped_text = $MM->escape_newlines($text);
 
-    my $POD2MAN_macro = $self->POD2MAN_macro();
-    my $manifypods_target = $self->manifypods_target();
+Shell escapes newlines in $text.
 
-    return <<END_OF_TARGET;
 
-$POD2MAN_macro
+=head3 max_exec_len  I<Abstract>
 
-$manifypods_target
+    my $max_exec_len = $MM->max_exec_len;
 
-END_OF_TARGET
+Calculates the maximum command size the OS can exec.  Effectively,
+this is the max size of a shell command line.
 
-}
+=for _private
+$self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
 
 
-=item manifypods_target
 
-  my $manifypods_target = $self->manifypods_target;
 
-Generates the manifypods target.  This target generates man pages from
-all POD files in MAN1PODS and MAN3PODS.
 
-=cut
+=head2 Targets
 
-sub manifypods_target {
-    my($self) = shift;
+These are methods which produce make targets.
 
-    my $man1pods      = '';
-    my $man3pods      = '';
-    my $dependencies  = '';
 
-    # populate manXpods & dependencies:
-    foreach my $name (keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}) {
-        $dependencies .= " \\\n\t$name";
-    }
+=head3 all_target
 
-    foreach my $name (keys %{$self->{MAN3PODS}}) {
-        $dependencies .= " \\\n\t$name"
-    }
+Generate the default target 'all'.
 
-    my $manify = <<END;
-manifypods : pure_all $dependencies
-END
+=cut
 
-    my @man_cmds;
-    foreach my $section (qw(1 3)) {
-        my $pods = $self->{"MAN${section}PODS"};
-        push @man_cmds, $self->split_command(<<CMD, %$pods);
-       \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)
-CMD
-    }
+sub all_target {
+    my $self = shift;
 
-    $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
-    $manify .= join '', map { "$_\n" } @man_cmds;
+    return <<'MAKE_EXT';
+all :: pure_all
+       $(NOECHO) $(NOOP)
+MAKE_EXT
 
-    return $manify;
 }
 
 
-=item makemakerdflt_target
+=head3 blibdirs_target
 
-  my $make_frag = $mm->makemakerdflt_target
+    my $make_frag = $mm->blibdirs_target;
+
+Creates the blibdirs target which creates all the directories we use
+in blib/.
+
+The blibdirs.ts target is deprecated.  Depend on blibdirs instead.
 
-Returns a make fragment with the makemakerdeflt_target specified.
-This target is the first target in the Makefile, is the default target
-and simply points off to 'all' just in case any make variant gets
-confused or something gets snuck in before the real 'all' target.
 
 =cut
 
-sub makemakerdflt_target {
-    return <<'MAKE_FRAG';
-makemakerdflt: all
-       $(NOECHO) $(NOOP)
-MAKE_FRAG
+sub blibdirs_target {
+    my $self = shift;
 
-}
+    my @dirs = map { uc "\$(INST_$_)" } qw(libdir archlib
+                                           autodir archautodir
+                                           bin script
+                                           man1dir man3dir
+                                          );
 
+    my @exists = map { $_.'$(DFSEP).exists' } @dirs;
 
-=item special_targets
+    my $make = sprintf <<'MAKE', join(' ', @exists);
+blibdirs : %s
+       $(NOECHO) $(NOOP)
 
-  my $make_frag = $mm->special_targets
+# Backwards compat with 6.18 through 6.25
+blibdirs.ts : blibdirs
+       $(NOECHO) $(NOOP)
 
-Returns a make fragment containing any targets which have special
-meaning to make.  For example, .SUFFIXES and .PHONY.
+MAKE
 
-=cut
+    $make .= $self->dir_target(@dirs);
 
-sub special_targets {
-    my $make_frag = <<'MAKE_FRAG';
-.SUFFIXES: .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
+    return $make;
+}
 
-.PHONY: all config static dynamic test linkext manifest
 
-MAKE_FRAG
+=head3 clean (o)
 
-    $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};
-.NO_CONFIG_REC: Makefile
+Defines the clean target.
 
-MAKE_FRAG
+=cut
 
-    return $make_frag;
-}
+sub clean {
+# --- Cleanup and Distribution Sections ---
 
-=item POD2MAN_macro
+    my($self, %attribs) = @_;
+    my @m;
+    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 @files = values %{$self->{XS}}; # .c files from *.xs files
+    my @dirs  = qw(blib);
+
+    # Normally these are all under blib but they might have been
+    # redefined.
+    # XXX normally this would be a good idea, but the Perl core sets
+    # INST_LIB = ../../lib rather than actually installing the files.
+    # So a "make clean" in an ext/ directory would blow away lib.
+    # Until the core is adjusted let's leave this out.
+#     push @dirs, qw($(INST_ARCHLIB) $(INST_LIB)
+#                    $(INST_BIN) $(INST_SCRIPT)
+#                    $(INST_MAN1DIR) $(INST_MAN3DIR)
+#                    $(INST_LIBDIR) $(INST_ARCHLIBDIR) $(INST_AUTODIR) 
+#                    $(INST_STATIC) $(INST_DYNAMIC) $(INST_BOOT)
+#                 );
+                  
+
+    if( $attribs{FILES} ) {
+        # Use @dirs because we don't know what's in here.
+        push @dirs, ref $attribs{FILES}                ?
+                        @{$attribs{FILES}}             :
+                        split /\s+/, $attribs{FILES}   ;
+    }
 
-  my $pod2man_macro = $self->POD2MAN_macro
+    push(@files, qw[$(MAKE_APERL_FILE) 
+                    perlmain.c tmon.out mon.out so_locations 
+                    blibdirs.ts pm_to_blib pm_to_blib.ts
+                    *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
+                    $(BOOTSTRAP) $(BASEEXT).bso
+                    $(BASEEXT).def lib$(BASEEXT).def
+                    $(BASEEXT).exp $(BASEEXT).x
+                   ]);
 
-Returns a definition for the POD2MAN macro.  This is a program
-which emulates the pod2man utility.  You can add more switches to the
-command by simply appending them on the macro.
+    push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
+    push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
 
-Typical usage:
+    # core files
+    push(@files, qw[core core.*perl.*.? *perl.core]);
+    push(@files, map { "core." . "[0-9]"x$_ } (1..5));
 
-    $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
+    # OS specific things to clean up.  Use @dirs since we don't know
+    # what might be in here.
+    push @dirs, $self->extra_clean_files;
 
-=cut
+    # Occasionally files are repeated several times from different sources
+    { my(%f) = map { ($_ => 1) } @files; @files = keys %f; }
+    { my(%d) = map { ($_ => 1) } @dirs;  @dirs  = keys %d; }
 
-sub POD2MAN_macro {
-    my $self = shift;
+    push @m, map "\t$_\n", $self->split_command('- $(RM_F)',  @files);
+    push @m, map "\t$_\n", $self->split_command('- $(RM_RF)', @dirs);
 
-# Need the trailing '--' so perl stops gobbling arguments and - happens
-# to be an alternative end of line seperator on VMS so we quote it
-    return <<'END_OF_DEF';
-POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
-POD2MAN = $(POD2MAN_EXE)
-END_OF_DEF
-}
+    # Leave Makefile.old around for realclean
+    push @m, <<'MAKE';
+       - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
+MAKE
 
+    push(@m, "\t$attribs{POSTOP}\n")   if $attribs{POSTOP};
 
-=item test_via_harness
+    join("", @m);
+}
 
-  my $command = $mm->test_via_harness($perl, $tests);
 
-Returns a $command line which runs the given set of $tests with
-Test::Harness and the given $perl.
+=head3 clean_subdirs_target
 
-Used on the t/*.t files.
+  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 test_via_harness {
-    my($self, $perl, $tests) = @_;
+sub clean_subdirs_target {
+    my($self) = shift;
 
-    return qq{\t$perl "-MExtUtils::Command::MM" }.
-           qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
+    # 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}}) {
+        my $subclean = $self->oneliner(sprintf <<'CODE', $dir);
+chdir '%s';  system '$(MAKE) clean' if -f '$(FIRST_MAKEFILE)';
+CODE
+
+        $clean .= "\t$subclean\n";
+    }
+
+    return $clean;
 }
 
-=item test_via_script
 
-  my $command = $mm->test_via_script($perl, $script);
+=head3 dir_target
 
-Returns a $command line which just runs a single test without
-Test::Harness.  No checks are done on the results, they're just
-printed.
+    my $make_frag = $mm->dir_target(@directories);
 
-Used for test.pl, since they don't always follow Test::Harness
-formatting.
+Generates targets to create the specified directories and set its
+permission to 0755.
+
+Because depending on a directory to just ensure it exists doesn't work
+too well (the modified time changes too often) dir_target() creates a
+.exists file in the created directory.  It is this you should depend on.
+For portability purposes you should use the $(DIRFILESEP) macro rather
+than a '/' to seperate the directory from the file.
+
+    yourdirectory$(DIRFILESEP).exists
 
 =cut
 
-sub test_via_script {
-    my($self, $perl, $script) = @_;
-    return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
-}
+sub dir_target {
+    my($self, @dirs) = @_;
 
-=item libscan
+    my $make = '';
+    foreach my $dir (@dirs) {
+        $make .= sprintf <<'MAKE', ($dir) x 7;
+%s$(DFSEP).exists :: Makefile.PL
+       $(NOECHO) $(MKPATH) %s
+       $(NOECHO) $(CHMOD) 755 %s
+       $(NOECHO) $(TOUCH) %s$(DFSEP).exists
 
-  my $wanted = $self->libscan($path);
+MAKE
 
-Takes a path to a file or dir and returns an empty string if we don't
-want to include this file in the library.  Otherwise it returns the
-the $path unchanged.
+    }
 
-Mainly used to exclude RCS, CVS, and SCCS directories from
-installation.
+    return $make;
+}
+
+
+=head3 distdir
+
+Defines the scratch directory target that will hold the distribution
+before tar-ing (or shar-ing).
 
 =cut
 
-sub libscan {
-    my($self,$path) = @_;
-    my($dirs,$file) = ($self->splitpath($path))[1,2];
-    return '' if grep /^(?:RCS|CVS|SCCS|\.svn)$/, 
-                     $self->splitdir($dirs), $file;
+# For backwards compatibility.
+*dist_dir = *distdir;
+
+sub distdir {
+    my($self) = shift;
+
+    my $meta_target = $self->{NO_META} ? '' : 'distmeta';
+    my $sign_target = !$self->{SIGN}   ? '' : 'distsignature';
+
+    return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;
+create_distdir :
+       $(RM_RF) $(DISTVNAME)
+       $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
+               -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
+
+distdir : create_distdir %s %s
+       $(NOECHO) $(NOOP)
+
+MAKE_FRAG
 
-    return $path;
 }
 
-=item tool_autosplit
 
-Defines a simple perl call that runs autosplit. May be deprecated by
-pm_to_blib soon.
+=head3 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 tool_autosplit {
-    my($self, %attribs) = @_;
+sub dist_test {
+    my($self) = shift;
 
-    my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};' 
-                                  : '';
+    my $mpl_args = join " ", map qq["$_"], @ARGV;
 
-    my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
-use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
-PERL_CODE
+    my $test = $self->cd('$(DISTVNAME)',
+                         '$(ABSPERLRUN) Makefile.PL '.$mpl_args,
+                         '$(MAKE) $(PASTHRU)',
+                         '$(MAKE) test $(PASTHRU)'
+                        );
 
-    return sprintf <<'MAKE_FRAG', $asplit;
-# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
-AUTOSPLITFILE = %s
+    return sprintf <<'MAKE_FRAG', $test;
+disttest : distdir
+       %s
 
 MAKE_FRAG
 
+
 }
 
 
-=item all_target
+=head3 dynamic (o)
 
-Generate the default target 'all'.
+Defines the dynamic target.
 
 =cut
 
-sub all_target {
-    my $self = shift;
+sub dynamic {
+# --- Dynamic Loading Sections ---
 
-    return <<'MAKE_EXT';
-all :: pure_all
+    my($self) = shift;
+    '
+dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
        $(NOECHO) $(NOOP)
-MAKE_EXT
+';
+}
+
+
+=head3 makemakerdflt_target
+
+  my $make_frag = $mm->makemakerdflt_target
+
+Returns a make fragment with the makemakerdeflt_target specified.
+This target is the first target in the Makefile, is the default target
+and simply points off to 'all' just in case any make variant gets
+confused or something gets snuck in before the real 'all' target.
+
+=cut
+
+sub makemakerdflt_target {
+    return <<'MAKE_FRAG';
+makemakerdflt: all
+       $(NOECHO) $(NOOP)
+MAKE_FRAG
+
+}
+
+
+=head3 manifypods_target
+
+  my $manifypods_target = $self->manifypods_target;
+
+Generates the manifypods target.  This target generates man pages from
+all POD files in MAN1PODS and MAN3PODS.
+
+=cut
+
+sub manifypods_target {
+    my($self) = shift;
+
+    my $man1pods      = '';
+    my $man3pods      = '';
+    my $dependencies  = '';
+
+    # populate manXpods & dependencies:
+    foreach my $name (keys %{$self->{MAN1PODS}}, keys %{$self->{MAN3PODS}}) {
+        $dependencies .= " \\\n\t$name";
+    }
+
+    foreach my $name (keys %{$self->{MAN3PODS}}) {
+        $dependencies .= " \\\n\t$name"
+    }
+
+    my $manify = <<END;
+manifypods : pure_all $dependencies
+END
+
+    my @man_cmds;
+    foreach my $section (qw(1 3)) {
+        my $pods = $self->{"MAN${section}PODS"};
+        push @man_cmds, $self->split_command(<<CMD, %$pods);
+       \$(NOECHO) \$(POD2MAN) --section=$section --perm_rw=\$(PERM_RW)
+CMD
+    }
+
+    $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
+    $manify .= join '', map { "$_\n" } @man_cmds;
 
+    return $manify;
 }
 
 
-=item metafile_target
+=head3 metafile_target
 
     my $target = $mm->metafile_target;
 
 Generate the metafile target.
 
-Writes the file META.yml, YAML encoded meta-data about the module.  The
-format follows Module::Build's as closely as possible.  Additionally, we
-include:
+Writes the file META.yml YAML encoded meta-data about the module in
+the distdir.  The format follows Module::Build's as closely as
+possible.  Additionally, we include:
 
     version_from
     installdirs
@@ -627,181 +720,625 @@ generated_by: ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION
 YAML
 
     my @write_meta = $self->echo($meta, 'META_new.yml');
-    my $move = $self->oneliner(<<'CODE', ['-MExtUtils::Command', '-MFile::Compare']);
-compare(@ARGV) != 0 ? (mv or warn "Cannot move @ARGV: $$!\n") : unlink(shift);
-CODE
 
-    return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta), $move;
-metafile :
+    return sprintf <<'MAKE_FRAG', join("\n\t", @write_meta);
+metafile : create_distdir
        $(NOECHO) $(ECHO) Generating META.yml
        %s
-       -$(NOECHO) %s META_new.yml META.yml
+       -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
 MAKE_FRAG
 
 }
 
 
-=item signature_target
-
-    my $target = $mm->signature_target;
+=head3 distmeta_target
 
-Generate the signature target.
+    my $make_frag = $mm->distmeta_target;
 
-Writes the file SIGNATURE with "cpansign -s".
+Generates the distmeta target to add META.yml to the MANIFEST in the
+distdir.
 
 =cut
 
-sub signature_target {
+sub distmeta_target {
     my $self = shift;
 
-    return <<'MAKE_FRAG' if !$self->{SIGN};
-signature :
-       $(NOECHO) $(NOOP)
-MAKE_FRAG
+    my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
+eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } 
+    or print "Could not add META.yml to MANIFEST: $${'@'}\n"
+CODE
 
-    return <<'MAKE_FRAG';
-signature :  signature_addtomanifest
-       cpansign -s
-MAKE_FRAG
+    my $add_meta_to_distdir = $self->cd('$(DISTVNAME)', $add_meta);
 
-}
+    return sprintf <<'MAKE', $add_meta_to_distdir;
+distmeta : create_distdir metafile
+       $(NOECHO) %s
+
+MAKE
 
+}
 
-=item metafile_addtomanifest_target
 
-  my $target = $mm->metafile_addtomanifest_target
+=head3 realclean (o)
 
-Adds the META.yml file to the MANIFEST.
+Defines the realclean target.
 
 =cut
 
-sub metafile_addtomanifest_target {
-    my $self = shift;
+sub realclean {
+    my($self, %attribs) = @_;
 
-    return <<'MAKE_FRAG' if $self->{NO_META};
-metafile_addtomanifest:
-       $(NOECHO) $(NOOP)
-MAKE_FRAG
+    my @dirs  = qw($(DISTVNAME));
+    my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD));
 
-    my $add_meta = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
-eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } 
-    or print "Could not add META.yml to MANIFEST: $${'@'}\n"
-CODE
+    # Special exception for the perl core where INST_* is not in blib.
+    # This cleans up the files built from the ext/ directory (all XS).
+    if( $self->{PERL_CORE} ) {
+       push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR));
+        push @files, values %{$self->{PM}};
+    }
 
-    return sprintf <<'MAKE_FRAG', $add_meta;
-metafile_addtomanifest:
-       $(NOECHO) $(ECHO) Adding META.yml to MANIFEST
-       $(NOECHO) %s
-MAKE_FRAG
+    if( $self->has_link_code ){
+        push @files, qw($(OBJECT));
+    }
+
+    if( $attribs{FILES} ) {
+        if( ref $attribs{FILES} ) {
+            push @dirs, @{ $attribs{FILES} };
+        }
+        else {
+            push @dirs, split /\s+/, $attribs{FILES};
+        }
+    }
+
+    # Occasionally files are repeated several times from different sources
+    { my(%f) = map { ($_ => 1) } @files;  @files = keys %f; }
+    { my(%d) = map { ($_ => 1) } @dirs;   @dirs  = keys %d; }
+
+    my $rm_cmd  = join "\n\t", map { "$_" } 
+                    $self->split_command('- $(RM_F)',  @files);
+    my $rmf_cmd = join "\n\t", map { "$_" } 
+                    $self->split_command('- $(RM_RF)', @dirs);
 
+    my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
+# Delete temporary files (via clean) and also delete dist files
+realclean purge ::  clean realclean_subdirs
+       %s
+       %s
+MAKE
+
+    $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP};
+
+    return $m;
 }
 
 
-=item signature_addtomanifest_target
+=head3 realclean_subdirs_target
 
-  my $target = $mm->signature_addtomanifest_target
+  my $make_frag = $MM->realclean_subdirs_target;
 
-Adds the META.yml file to the MANIFEST.
+Returns the realclean_subdirs target.  This is used by the realclean
+target to call realclean on any subdirectories which contain Makefiles.
 
 =cut
 
-sub signature_addtomanifest_target {
+sub realclean_subdirs_target {
     my $self = shift;
 
-    return <<'MAKE_FRAG' if !$self->{SIGN};
-signature_addtomanifest :
+    return <<'NOOP_FRAG' unless @{$self->{DIR}};
+realclean_subdirs :
        $(NOECHO) $(NOOP)
-MAKE_FRAG
+NOOP_FRAG
 
-    my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
-eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } 
-    or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"
+    my $rclean = "realclean_subdirs :\n";
+
+    foreach my $dir (@{$self->{DIR}}) {
+        foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
+            my $subrclean .= $self->oneliner(sprintf <<'CODE', $dir, ($makefile) x 2);
+chdir '%s';  system '$(MAKE) $(USEMAKEFILE) %s realclean' if -f '%s';
 CODE
 
-    return sprintf <<'MAKE_FRAG', $add_sign;
-signature_addtomanifest :
-       $(NOECHO) $(ECHO) Adding SIGNATURE to MANIFEST
-       $(NOECHO) %s
-MAKE_FRAG
+            $rclean .= sprintf <<'RCLEAN', $subrclean;
+       - %s
+RCLEAN
+
+        }
+    }
 
+    return $rclean;
 }
 
 
-=back
+=head3 signature_target
 
-=head2 Abstract methods
+    my $target = $mm->signature_target;
 
-Methods which cannot be made cross-platform and each subclass will
-have to do their own implementation.
+Generate the signature target.
 
-=over 4
+Writes the file SIGNATURE with "cpansign -s".
 
-=item oneliner
+=cut
 
-  my $oneliner = $MM->oneliner($perl_code);
-  my $oneliner = $MM->oneliner($perl_code, \@switches);
+sub signature_target {
+    my $self = shift;
 
-This will generate a perl one-liner safe for the particular platform
-you're on based on the given $perl_code and @switches (a -e is
-assumed) suitable for using in a make target.  It will use the proper
-shell quoting and escapes.
+    return <<'MAKE_FRAG';
+signature :
+       cpansign -s
+MAKE_FRAG
 
-$(PERLRUN) will be used as perl.
+}
 
-Any newlines in $perl_code will be escaped.  Leading and trailing
-newlines will be stripped.  Makes this idiom much easier:
 
-    my $code = $MM->oneliner(<<'CODE', [...switches...]);
-some code here
-another line here
-CODE
+=head3 distsignature_target
 
-Usage might be something like:
+    my $make_frag = $mm->distsignature_target;
 
-    # an echo emulation
-    $oneliner = $MM->oneliner('print "Foo\n"');
-    $make = '$oneliner > somefile';
+Generates the distsignature target to add SIGNATURE to the MANIFEST in the
+distdir.
 
-All dollar signs must be doubled in the $perl_code if you expect them
-to be interpreted normally, otherwise it will be considered a make
-macro.  Also remember to quote make macros else it might be used as a
-bareword.  For example:
+=cut
 
-    # Assign the value of the $(VERSION_FROM) make macro to $vf.
-    $oneliner = $MM->oneliner('$$vf = "$(VERSION_FROM)"');
+sub distsignature_target {
+    my $self = shift;
 
-Its currently very simple and may be expanded sometime in the figure
-to include more flexible code and switches.
+    my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
+eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } 
+    or print "Could not add SIGNATURE to MANIFEST: $${'@'}\n"
+CODE
 
+    my $sign_dist        = $self->cd('$(DISTVNAME)' => 'cpansign -s');
 
-=item B<quote_literal>
+    # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
+    # exist
+    my $touch_sig        = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
+    my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
 
-    my $safe_text = $MM->quote_literal($text);
+    return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
+distsignature : create_distdir
+       $(NOECHO) %s
+       $(NOECHO) %s
+       %s
 
-This will quote $text so it is interpreted literally in the shell.
+MAKE
 
-For example, on Unix this would escape any single-quotes in $text and
-put single-quotes around the whole thing.
+}
 
 
-=item B<escape_newlines>
+=head3 special_targets
 
-    my $escaped_text = $MM->escape_newlines($text);
+  my $make_frag = $mm->special_targets
 
-Shell escapes newlines in $text.
+Returns a make fragment containing any targets which have special
+meaning to make.  For example, .SUFFIXES and .PHONY.
 
+=cut
 
-=item max_exec_len
+sub special_targets {
+    my $make_frag = <<'MAKE_FRAG';
+.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
 
-    my $max_exec_len = $MM->max_exec_len;
+.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
 
-Calculates the maximum command size the OS can exec.  Effectively,
-this is the max size of a shell command line.
+MAKE_FRAG
 
-=for _private
-$self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
+    $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};
+.NO_CONFIG_REC: Makefile
+
+MAKE_FRAG
+
+    return $make_frag;
+}
+
+
+
+
+=head2 Init methods
+
+Methods which help initialize the MakeMaker object and macros.
+
+
+=head3 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;
+}
+
+
+=head3 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;
+
+    if( $self->{ARGS}{INSTALLBASE} and $self->{ARGS}{PREFIX} ) {
+        die "Only one of PREFIX or INSTALLBASE can be given.  Not both.\n";
+    }
+
+    if( $self->{ARGS}{INSTALLBASE} ) {
+        $self->init_INSTALL_from_INSTALLBASE;
+    }
+    else {
+        $self->init_INSTALL_from_PREFIX;
+    }
+}
+
+
+=head3 init_INSTALL_from_PREFIX
+
+  $mm->init_INSTALL_from_PREFIX;
+
+=cut
+
+sub init_INSTALL_from_PREFIX {
+    my $self = shift;
+
+    $self->init_lib2arch;
+
+    # There are often no Config.pm defaults for these new man variables so 
+    # we fall back to the old behavior which is to use installman*dir
+    foreach my $num (1, 3) {
+        my $k = 'installsiteman'.$num.'dir';
+
+        $self->{uc $k} ||= uc "\$(installman${num}dir)"
+          unless $Config{$k};
+    }
+
+    foreach my $num (1, 3) {
+        my $k = 'installvendorman'.$num.'dir';
+
+        unless( $Config{$k} ) {
+            $self->{uc $k}  ||= $Config{usevendorprefix}
+                              ? uc "\$(installman${num}dir)"
+                              : '';
+        }
+    }
+
+    $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)'
+      unless $Config{installsitebin};
+
+    unless( $Config{installvendorbin} ) {
+        $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix} 
+                                    ? $Config{installbin}
+                                    : '';
+    }
+
+
+    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;
+
+
+    $self->{PREFIX}       ||= '';
+
+    if( $self->{PREFIX} ) {
+        @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
+          ('$(PREFIX)') x 3;
+    }
+    else {
+        $self->{PERLPREFIX}   ||= $iprefix;
+        $self->{SITEPREFIX}   ||= $sprefix;
+        $self->{VENDORPREFIX} ||= $vprefix;
+
+        # Lots of MM extension authors like to use $(PREFIX) so we
+        # put something sensible in there no matter what.
+        $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)';
+    }
+
+    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'
+                      );
 
-=item B<init_others>
+    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;
+}
+
+
+=head3 init_from_INSTALLBASE
+
+    $mm->init_from_INSTALLBASE
+
+=cut
+
+my %map = (
+           lib      => [qw(lib perl5)],
+           arch     => [('lib', 'perl5', $Config{archname})],
+           bin      => [qw(bin)],
+           man1dir  => [qw(man man1)],
+           man3dir  => [qw(man man3)]
+          );
+$map{script} = $map{bin};
+
+sub init_INSTALL_from_INSTALLBASE {
+    my $self = shift;
+
+    @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} = 
+                                                         '$(INSTALLBASE)';
+
+    my %install;
+    foreach my $thing (keys %map) {
+        foreach my $dir (('', 'SITE', 'VENDOR')) {
+            my $uc_thing = uc $thing;
+            my $key = "INSTALL".$dir.$uc_thing;
+
+            $install{$key} ||= 
+              $self->catdir('$(INSTALLBASE)', @{$map{$thing}});
+        }
+    }
+
+    # Adjust for variable quirks.
+    $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH};
+    $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB};
+    delete @install{qw(INSTALLVENDORSCRIPT INSTALLSITESCRIPT)};
+
+    foreach my $key (keys %install) {
+        $self->{$key} ||= $install{$key};
+    }
+
+    return 1;
+}
+
+
+=head3 init_VERSION  I<Abstract>
+
+    $mm->init_VERSION
+
+Initialize macros representing versions of MakeMaker and other tools
+
+MAKEMAKER: path to the MakeMaker module.
+
+MM_VERSION: ExtUtils::MakeMaker Version
+
+MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards 
+             compat)
+
+VERSION: version of your module
+
+VERSION_MACRO: which macro represents the version (usually 'VERSION')
+
+VERSION_SYM: like version but safe for use as an RCS revision number
+
+DEFINE_VERSION: -D line to set the module version when compiling
+
+XS_VERSION: version in your .xs file.  Defaults to $(VERSION)
+
+XS_VERSION_MACRO: which macro represents the XS version.
+
+XS_DEFINE_VERSION: -D line to set the xs version when compiling.
+
+Called by init_main.
+
+=cut
+
+sub init_VERSION {
+    my($self) = shift;
+
+    $self->{MAKEMAKER}  = $ExtUtils::MakeMaker::Filename;
+    $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
+    $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
+    $self->{VERSION_FROM} ||= '';
+
+    if ($self->{VERSION_FROM}){
+        $self->{VERSION} = $self->parse_version($self->{VERSION_FROM});
+        if( $self->{VERSION} eq 'undef' ) {
+            require Carp;
+            Carp::carp("WARNING: Setting VERSION via file ".
+                       "'$self->{VERSION_FROM}' failed\n");
+        }
+    }
+
+    # strip blanks
+    if (defined $self->{VERSION}) {
+        $self->{VERSION} =~ s/^\s+//;
+        $self->{VERSION} =~ s/\s+$//;
+    }
+    else {
+        $self->{VERSION} = '';
+    }
+
+
+    $self->{VERSION_MACRO}  = 'VERSION';
+    ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
+    $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
+
+
+    # Graham Barr and Paul Marquess had some ideas how to ensure
+    # version compatibility between the *.pm file and the
+    # corresponding *.xs file. The bottomline was, that we need an
+    # XS_VERSION macro that defaults to VERSION:
+    $self->{XS_VERSION} ||= $self->{VERSION};
+
+    $self->{XS_VERSION_MACRO}  = 'XS_VERSION';
+    $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
+
+}
+
+
+=head3 init_others  I<Abstract>
 
     $MM->init_others();
 
@@ -839,7 +1376,8 @@ Defines at least these macros.
   UMASK_NULL        Nullify umask
   DEV_NULL          Supress all command output
 
-=item init_DIRFILESEP
+
+=head3 init_DIRFILESEP  I<Abstract>
 
   $MM->init_DIRFILESEP;
   my $dirfilesep = $MM->{DIRFILESEP};
@@ -860,7 +1398,7 @@ Do not use this as a seperator between directories.  Some operating
 systems use different seperators between subdirectories as between
 directories and filenames (for example:  VOLUME:[dir1.dir2]file on VMS).
 
-=item init_linker
+=head3 init_linker  I<Abstract>
 
     $mm->init_linker;
 
@@ -880,7 +1418,7 @@ to be exported.
 Some OSes do not need these in which case leave it blank.
 
 
-=item init_platform
+=head3 init_platform
 
     $mm->init_platform
 
@@ -889,48 +1427,249 @@ Initialize any macros which are for platform specific use only.
 A typical one is the version number of your OS specific mocule.
 (ie. MM_Unix_VERSION or MM_VMS_VERSION).
 
-=item platform_constants
+=cut
 
-    my $make_frag = $mm->platform_constants
+sub init_platform {
+    return '';
+}
 
-Returns a make fragment defining all the macros initialized in
-init_platform() rather than put them in constants().
+
+
+
+
+=head2 Tools
+
+A grab bag of methods to generate specific macros and commands.
+
+
+
+=head3 manifypods
+
+Defines targets and routines to translate the pods into manpages and
+put them into the INST_* directories.
 
 =cut
 
-sub init_platform {
-    return '';
+sub manifypods {
+    my $self          = shift;
+
+    my $POD2MAN_macro = $self->POD2MAN_macro();
+    my $manifypods_target = $self->manifypods_target();
+
+    return <<END_OF_TARGET;
+
+$POD2MAN_macro
+
+$manifypods_target
+
+END_OF_TARGET
+
 }
 
-sub platform_constants {
-    return '';
+
+=head3 POD2MAN_macro
+
+  my $pod2man_macro = $self->POD2MAN_macro
+
+Returns a definition for the POD2MAN macro.  This is a program
+which emulates the pod2man utility.  You can add more switches to the
+command by simply appending them on the macro.
+
+Typical usage:
+
+    $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
+
+=cut
+
+sub POD2MAN_macro {
+    my $self = shift;
+
+# Need the trailing '--' so perl stops gobbling arguments and - happens
+# to be an alternative end of line seperator on VMS so we quote it
+    return <<'END_OF_DEF';
+POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
+POD2MAN = $(POD2MAN_EXE)
+END_OF_DEF
 }
 
-=item os_flavor
 
-    my @os_flavor = $mm->os_flavor;
+=head3 test_via_harness
 
-@os_flavor is the style of operating system this is, usually
-corresponding to the MM_*.pm file we're using.  
+  my $command = $mm->test_via_harness($perl, $tests);
 
-The first element of @os_flavor is the major family (ie. Unix,
-Windows, VMS, OS/2, MacOS, etc...) and the rest are sub families.
+Returns a $command line which runs the given set of $tests with
+Test::Harness and the given $perl.
 
-Some examples:
+Used on the t/*.t files.
 
-    Cygwin98       ('Unix',  'Cygwin', 'Cygwin9x')
-    Windows NT     ('Win32', 'WinNT')
-    Win98          ('Win32', 'Win9x')
-    Linux          ('Unix',  'Linux')
-    MacOS Classic  ('MacOS', 'MacOS Classic')
-    MacOS X        ('Unix',  'Darwin', 'MacOS', 'MacOS X')
-    OS/2           ('OS/2')
+=cut
 
-This is used to write code for styles of operating system.  
-See os_flavor_is() for use.
+sub test_via_harness {
+    my($self, $perl, $tests) = @_;
+
+    return qq{\t$perl "-MExtUtils::Command::MM" }.
+           qq{"-e" "test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
+}
+
+=head3 test_via_script
+
+  my $command = $mm->test_via_script($perl, $script);
+
+Returns a $command line which just runs a single test without
+Test::Harness.  No checks are done on the results, they're just
+printed.
+
+Used for test.pl, since they don't always follow Test::Harness
+formatting.
+
+=cut
+
+sub test_via_script {
+    my($self, $perl, $script) = @_;
+    return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
+}
+
+
+=head3 tool_autosplit
+
+Defines a simple perl call that runs autosplit. May be deprecated by
+pm_to_blib soon.
+
+=cut
+
+sub tool_autosplit {
+    my($self, %attribs) = @_;
+
+    my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};' 
+                                  : '';
+
+    my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
+use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
+PERL_CODE
+
+    return sprintf <<'MAKE_FRAG', $asplit;
+# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
+AUTOSPLITFILE = %s
+
+MAKE_FRAG
+
+}
+
+
+
+
+=head2 File::Spec wrappers
+
+ExtUtils::MM_Any is a subclass of File::Spec.  The methods noted here
+override File::Spec.
+
+
+
+=head3 catfile
+
+File::Spec <= 0.83 has a bug where the file part of catfile is not
+canonicalized.  This override fixes that bug.
+
+=cut
+
+sub catfile {
+    my $self = shift;
+    return $self->canonpath($self->SUPER::catfile(@_));
+}
+
+
+
+=head2 Misc
+
+Methods I can't really figure out where they should go yet.
+
+
+=head3 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 -d 't' ? 't/*.t' : '';
+}
+
+
+=head3 extra_clean_files
+
+    my @files_to_clean = $MM->extra_clean_files;
+
+Returns a list of OS specific files to be removed in the clean target in
+addition to the usual set.
+
+=cut
 
+# An empty method here tickled a perl 5.8.1 bug and would return its object.
+sub extra_clean_files { 
+    return;
+}
+
+
+=head3 installvars
+
+    my @installvars = $mm->installvars;
+
+A list of all the INSTALL* variables without the INSTALL prefix.  Useful
+for iteration or building related variable sets.
+
+=cut
+
+sub installvars {
+    return qw(PRIVLIB SITELIB  VENDORLIB
+              ARCHLIB SITEARCH VENDORARCH
+              BIN     SITEBIN  VENDORBIN
+              SCRIPT
+              MAN1DIR SITEMAN1DIR VENDORMAN1DIR
+              MAN3DIR SITEMAN3DIR VENDORMAN3DIR
+             );
+}
+
+
+=head3 libscan
+
+  my $wanted = $self->libscan($path);
+
+Takes a path to a file or dir and returns an empty string if we don't
+want to include this file in the library.  Otherwise it returns the
+the $path unchanged.
+
+Mainly used to exclude version control administrative directories from
+installation.
+
+=cut
+
+sub libscan {
+    my($self,$path) = @_;
+    my($dirs,$file) = ($self->splitpath($path))[1,2];
+    return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/, 
+                     $self->splitdir($dirs), $file;
+
+    return $path;
+}
+
+
+=head3 platform_constants
+
+    my $make_frag = $mm->platform_constants
+
+Returns a make fragment defining all the macros initialized in
+init_platform() rather than put them in constants().
+
+=cut
+
+sub platform_constants {
+    return '';
+}
 
-=back
 
 =head1 AUTHOR