also add x_breaks to META.*
[gitmo/Moo.git] / Makefile.PL
1 use strict;
2 use warnings FATAL => 'all';
3 use 5.008001;
4 use ExtUtils::MakeMaker;
5
6 check_conflicts();
7 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
8
9 my %BUILD_DEPS = ();
10
11 my %TEST_DEPS = (
12   'Test::More' => 0.96,
13   'Test::Fatal' => 0.003,
14 );
15
16 my %RUN_DEPS = (
17   'Class::Method::Modifiers' => 1.10,
18   'strictures' => 1.004003,
19   'Module::Runtime' => 0.012,
20   'Role::Tiny' => 1.002004,
21   'Devel::GlobalDestruction' => 0.11,
22 );
23
24 # have to do this since old EUMM dev releases miss the eval $VERSION line
25 my $mymeta_works = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.5707 };
26 my $mymeta = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.5702 };
27
28 my $has_test_requires = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.63_03 };
29
30 if (not $has_test_requires)
31 {
32     %BUILD_DEPS = (%BUILD_DEPS, %TEST_DEPS);
33     %TEST_DEPS = ();
34 }
35
36 my %extra_info = (
37   resources => {
38     repository => 'git://git.shadowcat.co.uk/gitmo/Moo.git',
39     IRC => 'irc://irc.perl.org/#moose',
40     bugtracker => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=Moo',
41     license => 'http://dev.perl.org/licenses/',
42   }
43 );
44
45 WriteMakefile(
46   NAME => 'Moo',
47   VERSION_FROM => 'lib/Moo.pm',
48   CONFIGURE_REQUIRES => {
49     'Dist::CheckConflicts' => '0.02',
50   },
51   PREREQ_PM => {
52     %RUN_DEPS,
53     ($] >= 5.010 ? () : ('MRO::Compat' => 0)),
54     ($mymeta_works ? () : (%BUILD_DEPS)),
55     'Dist::CheckConflicts' => '0.02',
56   },
57   ($mymeta_works
58     ? ( # BUILD_REQUIRES makes MYMETA right, requires stops META being wrong
59         BUILD_REQUIRES => \%BUILD_DEPS,
60         $has_test_requires ? ( TEST_REQUIRES => \%TEST_DEPS ) : (),
61         META_ADD => { requires => \%RUN_DEPS, %extra_info }
62       )
63     : ( # META_ADD both to get META right - only Makefile written
64         META_ADD => {
65           requires => \%RUN_DEPS,
66           build_requires => \%BUILD_DEPS,
67           test_requires => \%TEST_DEPS,
68           %extra_info,
69         }
70       )
71   ),
72   META_MERGE => {
73     no_index => {
74       directory => [ 'xt' ]
75     },
76     x_breaks => {
77       # enter conflicting data here, *and* in Moo::Conflicts
78     },
79   },
80   ($mymeta && !$mymeta_works ? (NO_MYMETA => 1) : ()),
81   LICENSE => 'perl',
82   'EXE_FILES' => [
83     'bin/moo-outdated',
84   ],
85 );
86
87
88 # copied from Moose-2.0801/Makefile.PL
89 sub check_conflicts {
90     if ( eval { require 'lib/Moo/Conflicts.pm'; 1; } ) {
91         if ( eval { Moo::Conflicts->check_conflicts; 1 } ) {
92             return;
93         }
94         else {
95             my $err = $@;
96             $err =~ s/^/    /mg;
97             warn "***\n$err***\n";
98         }
99     }
100     else {
101         print <<'EOF';
102 ***
103     Your toolchain doesn't support configure_requires, so
104     Dist::CheckConflicts hasn't been installed yet. You should check for
105     conflicting modules manually using the 'moo-outdated' script that is
106     installed with this distribution once the installation finishes.
107 ***
108 EOF
109     }
110
111     # More or less copied from Module::Build
112     return if $ENV{PERL_MM_USE_DEFAULT};
113     return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
114
115     sleep 4;
116 }
117