use dist-checkconflicts
[gitmo/Class-MOP.git] / Makefile.PL
index 183cd17..f61a293 100644 (file)
@@ -1,6 +1,8 @@
 use strict;
 use warnings;
 use inc::Module::Install;
+use Module::Install::AuthorRequires;
+use Module::Install::ExtraTests;
 use 5.008001;
 
 check_conflicts();
@@ -10,62 +12,125 @@ perl_version '5.008001';
 all_from 'lib/Class/MOP.pm';
 license 'perl';
 
+require Config;
+my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.';
 
-my $ccflags = -d '.svn' || -d '.git' || $ENV{MAINTAINER_MODE} ? '-Wall' : '';
+if ( -d '.git' || $ENV{MAINTAINER_MODE} ) {
+    $ccflags .= ' -Wall -Wdeclaration-after-statement';
+}
 
 requires 'Carp';
+requires 'Data::OptList';
 requires 'Devel::GlobalDestruction';
-requires 'MRO::Compat' => '0.05';
-requires 'Scalar::Util'     => '1.18';
-requires 'Sub::Identify'    => '0.03';
-requires 'Sub::Name' => '0.04';
+requires 'Dist::CheckConflicts';
+requires 'Eval::Closure';
+requires 'List::MoreUtils'             => '0.12';
+requires 'MRO::Compat'                 => '0.05';
+requires 'Package::DeprecationManager' => '0.10';
+requires 'Package::Stash'              => '0.15';
+requires 'Package::Stash::XS'          => '0.17';
+requires 'Scalar::Util'                => '1.18';
+requires 'Sub::Name'                   => '0.05';
+requires 'Try::Tiny'                   => '0.02';
 requires 'Task::Weaken';
 
 test_requires 'File::Spec';
-test_requires 'Test::More'      => '0.77';
-test_requires 'Test::Exception' => '0.21';
+test_requires 'Test::More'     => '0.88';
+test_requires 'Test::Fatal'    => '0.001';
+test_requires 'Test::Requires' => '0.05';
 
-makemaker_args( CCFLAGS => $ccflags );
+author_requires 'Algorithm::C3';
+author_requires 'Module::Info';
+author_requires 'Test::LeakTrace';
+author_requires 'Test::NoTabs';
+author_requires 'Test::Output';
+author_requires 'Test::Spelling';
 
-WriteAll();
+configure_requires 'Dist::CheckConflicts';
+configure_requires 'Package::Stash::Conflicts';
 
-# Use the cpan-smolder-stable script in the Moose svn root to figure
-# out what on CPAN will break with the latest Moose, then update this
-# before a release.
-sub check_conflicts {
-    my %conflicts = (
-        'Moose' => '0.71',
-    );
+repository 'git://git.moose.perl.org/Class-MOP.git';
+add_metadata(x_authority => 'cpan:STEVAN');
 
-    my $found = 0;
-    for my $mod ( sort keys %conflicts ) {
-        eval "require $mod";
-        next if $@;
+extra_tests();
 
-        my $installed = $mod->VERSION();
-        if ( $installed le $conflicts{$mod} ) {
+makemaker_args( CCFLAGS => $ccflags );
 
-            print <<"EOF";
+{
+    my (@clean, @OBJECT, %XS);
 
-***
-    This version of Class::MOP conflicts with the version of
-    $mod ($installed) you have installed.
+    for my $xs (<xs/*.xs>) {
+        (my $c = $xs) =~ s/\.xs$/.c/i;
+        (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
 
-    You will need to upgrade $mod after installing
-    this version of Class::MOP.
-***
+        $XS{$xs} = $c;
+        push @OBJECT, $o;
+        push @clean, $o;
+    }
 
-EOF
+    for my $c (<*.c>) {
+        (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
+        push @OBJECT, $o;
+        push @clean, $o;
+    }
+
+    makemaker_args(
+        clean  => { FILES => join(q{ }, @clean) },
+        OBJECT => join (q{ }, @OBJECT),
+        XS     => \%XS,
+    );
+}
+
+postamble(<<'EOM');
+$(OBJECT) : mop.h
+EOM
+
+WriteAll();
 
-            $found = 1;
+sub check_conflicts {
+    if (eval { require 'lib/Class/MOP/Conflicts.pm'; 1; }) {
+        if (eval { Class::MOP::Conflicts->check_conflicts; 1 }) {
+            return;
+        }
+        else {
+            my $err = $@;
+            $err =~ s/^/    /mg;
+            warn "***\n$err***\n";
         }
     }
-
-    return unless $found;
+    else {
+        print <<'EOF';
+***
+    Your toolchain doesn't support configure_requires, so Dist::CheckConflicts
+    hasn't been installed yet. You should check for conflicting modules
+    manually using the 'cmop-conflicts' script that is installed with
+    this distribution once the installation finishes.
+***
+EOF
+    }
 
     # More or less copied from Module::Build
-    return if  $ENV{PERL_MM_USE_DEFAULT};
+    return if $ENV{PERL_MM_USE_DEFAULT};
     return unless -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT));
 
     sleep 4;
 }
+
+package MY;
+
+use Config;
+
+sub const_cccmd {
+    my $ret = shift->SUPER::const_cccmd(@_);
+    return q{} unless $ret;
+
+    if ($Config{cc} =~ /^cl\b/i) {
+        warn 'you are using MSVC... my condolences.';
+        $ret .= ' /Fo$@';
+    }
+    else {
+        $ret .= ' -o $@';
+    }
+
+    return $ret;
+}