fix detection if loaded during global destruction
[p5sagit/Devel-GlobalDestruction.git] / Makefile.PL
index caafb55..b2ddd69 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-require 5.006000;
+require 5.006;
 
 use ExtUtils::MakeMaker;
 BEGIN { if ( $^O eq 'cygwin' ) {
@@ -19,13 +19,29 @@ BEGIN { if ( $^O eq 'cygwin' ) {
   }
 }}
 
+use Text::ParseWords;
+
+sub parse_args {
+  # copied from EUMM
+  ExtUtils::MakeMaker::parse_args(
+    my $tmp = {},
+    Text::ParseWords::shellwords($ENV{PERL_MM_OPT} || ''),
+    @ARGV,
+  );
+  return $tmp->{ARGS} || {};
+}
+
 my $mymeta_works = eval { ExtUtils::MakeMaker->VERSION('6.5707'); 1 };
 my $mymeta = $mymeta_works || eval { ExtUtils::MakeMaker->VERSION('6.5702'); 1 };
 
 my %META_BITS = (
 );
 my %RUN_DEPS = (
-  'Sub::Exporter' => 0,
+  'Sub::Exporter::Progressive' => '0.001006',
+  ( (defined ${^GLOBAL_PHASE} or parse_args()->{PUREPERL_ONLY} or !can_xs() )
+    ? ()
+    : ('Devel::GlobalDestruction::XS' => 0)
+  ),
 );
 
 my %WriteMakefileArgs = (
@@ -34,22 +50,18 @@ my %WriteMakefileArgs = (
   LICENSE             => 'perl',
   INSTALLDIRS         => 'site',
   PL_FILES            => { },
-  MIN_PERL_VERSION    => '5.006000',
+  MIN_PERL_VERSION    => '5.006',
   PREREQ_PM           => \%RUN_DEPS,
   CONFIGURE_REQUIRES  => { 'ExtUtils::CBuilder' => 0.27 },
   META_ADD => {
     resources => {
-      homepage => 'http://search.cpan.org/dist/Devel-Globaldestruction',
-      repository => 'git://git.shadowcat.co.uk/p5sagit/Devel-Globaldestruction.git',
-      bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Devel-Globaldestruction',
+      homepage => 'http://search.cpan.org/dist/Devel-GlobalDestruction',
+      repository => 'git://git.shadowcat.co.uk/p5sagit/Devel-GlobalDestruction.git',
+      bugtracker => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Devel-GlobalDestruction',
     },
     requires => \%RUN_DEPS,
   },
   ($mymeta and !$mymeta_works) ? ( 'NO_MYMETA' => 1 ) : (),
-  ( (defined ${^GLOBAL_PHASE} or !can_xs() )
-    ? (XS => {}, C => [])
-    : ()
-  ),
 );
 
 unless ( eval { ExtUtils::MakeMaker->VERSION('6.56') } ) {
@@ -65,6 +77,21 @@ unless ( eval { ExtUtils::MakeMaker->VERSION('6.56') } ) {
   }
 }
 
+if (eval { require Devel::GlobalDestruction }
+    && Devel::GlobalDestruction->VERSION < 0.10) {
+  package MY;
+  no warnings 'once';
+
+  *install = sub {
+    my $self = shift;
+    return '
+pure_site_install ::
+       $(NOECHO) $(RM_F) ' . $self->quote_literal(
+      $self->catfile('$(DESTINSTALLSITEARCH)', 'Devel', 'GlobalDestruction.pm')
+    ) . "\n" . $self->SUPER::install;
+  };
+}
+
 delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
   unless eval { ExtUtils::MakeMaker->VERSION('6.52') };