hook into EUMM at a higher level
[p5sagit/Distar.git] / lib / Distar.pm
index 6bee4f1..72b8c2d 100644 (file)
@@ -15,7 +15,7 @@ $VERSION = eval $VERSION;
 my $MM_VER = eval $ExtUtils::MakeMaker::VERSION;
 
 our @EXPORT = qw(
-  author manifest_include run_preflight
+  author manifest_include readme_generator run_preflight
 );
 
 sub import {
@@ -30,10 +30,9 @@ sub author {
     if !ref $Author;
 }
 
-our $Ran_Preflight;
-
 our @Manifest = (
   'lib' => '.pm',
+  'lib' => '.pod',
   't' => '.t',
   't/lib' => '.pm',
   'xt' => '.t',
@@ -47,6 +46,14 @@ sub manifest_include {
   push @Manifest, @_;
 }
 
+my $readme_generator = <<'README';
+       pod2text $(VERSION_FROM) >$(DISTVNAME)/README
+       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
+README
+sub readme_generator {
+    $readme_generator = shift;
+}
+
 sub write_manifest_skip {
   my @files = @Manifest;
   my @parts;
@@ -68,7 +75,6 @@ sub write_manifest_skip {
 }
 
 sub run_preflight {
-  $Ran_Preflight = 1;
   my $version = $ARGV[0];
 
   my $make = $Config{make};
@@ -116,24 +122,42 @@ sub run_preflight {
 
 {
   package Distar::MM;
-  our @ISA = @ExtUtils::MM::ISA;
-  @ExtUtils::MM::ISA = (__PACKAGE__);
+  our @ISA = @MM::ISA;
+  @MM::ISA = (__PACKAGE__);
 
   sub new {
     my ($class, $args) = @_;
     return $class->SUPER::new({
-      LICENSE => 'perl',
+      LICENSE => 'perl_5',
       MIN_PERL_VERSION => '5.006',
+      AUTHOR => ($MM_VER >= 6.5702 ? $Distar::Author : join(', ', @$Distar::Author)),
       %$args,
-      AUTHOR => ($MM_VER >= 6.5702 ? $Distar::Author : $Distar::Author->[0]),
       ABSTRACT_FROM => $args->{VERSION_FROM},
       test => { TESTS => ($args->{test}{TESTS}||'t/*.t').' xt/*.t xt/*/*.t' },
+      realclean => { FILES => (
+        ($args->{realclean}{FILES}||'')
+        . ' Distar/ MANIFEST.SKIP MANIFEST MANIFEST.bak'
+      ) },
     });
   }
 
+  sub flush {
+    my $self = shift;
+    Distar::write_manifest_skip();
+    $self->SUPER::flush(@_);
+  }
+
   sub dist_test {
     my $self = shift;
-    my $dist_test = $self->SUPER::dist_test(@_) . <<'END';
+    my $dist_test = $self->SUPER::dist_test(@_);
+
+    my $include = '';
+    if (open my $fh, '<', 'maint/Makefile.include') {
+      $include = "\n# --- Makefile.include:\n" . do { local $/; <$fh> };
+    }
+
+    $dist_test .= "REMAKE = \$(PERLRUN) Makefile.PL @{[ map { $self->quote_literal($_) } @ARGV ]}";
+    $dist_test .= <<'END'
 
 # --- Distar section:
 preflight:
@@ -148,22 +172,36 @@ release: preflight
        git push origin v$(VERSION) HEAD
 distdir: readmefile
 readmefile: create_distdir
-       pod2text $(VERSION_FROM) >$(DISTVNAME)/README
-       $(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) ../Distar/helpers/add-readme-to-manifest
+END
+    . $readme_generator . <<'END';
 disttest: distmanicheck
 distmanicheck: create_distdir
        cd $(DISTVNAME) && $(ABSPERLRUN) "-MExtUtils::Manifest=manicheck" -e "exit manicheck"
+nextrelease:
+       $(ABSPERLRUN) Distar/helpers/add-changelog-heading $(VERSION) Changes
+       git add -p Changes
+refresh:
+       cd Distar && git pull
+       rm Makefile
+       $(REMAKE)
+END
 
+    for my $type ('', 'minor', 'major') {
+      if ($include !~ /^bump$type:/m) {
+        my $arg = $type || '$(V)';
+        $dist_test .= <<"END"
+bump$type:
+       Distar/helpers/bump-version --git \$(VERSION) $arg
+       rm Makefile
+       \$(REMAKE)
 END
-    if (open my $fh, '<', 'maint/Makefile.include') {
-      $dist_test .= do { local $/; <$fh> };
+      }
     }
+
+    $dist_test .= $include . "\n";
+
     return $dist_test;
   }
 }
 
-END {
-  write_manifest_skip() unless $Ran_Preflight
-}
-
 1;