tidy
[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       'HTML::Restrict' => '2.1.5',
79     },
80   },
81   ($mymeta && !$mymeta_works ? (NO_MYMETA => 1) : ()),
82   LICENSE => 'perl',
83   'EXE_FILES' => [
84     'bin/moo-outdated',
85   ],
86 );
87
88
89 # copied from Moose-2.0801/Makefile.PL
90 sub check_conflicts {
91     if ( eval { require 'lib/Moo/Conflicts.pm'; 1; } ) {
92         if ( eval { Moo::Conflicts->check_conflicts; 1 } ) {
93             return;
94         }
95         else {
96             my $err = $@;
97             $err =~ s/^/    /mg;
98             warn "***\n$err***\n";
99         }
100     }
101     else {
102         print <<'EOF';
103 ***
104     Your toolchain doesn't support configure_requires, so
105     Dist::CheckConflicts hasn't been installed yet. You should check for
106     conflicting modules manually using the 'moo-outdated' script that is
107     installed with this distribution once the installation finishes.
108 ***
109 EOF
110     }
111
112     return if $ENV{AUTOMATED_TESTING} || $ENV{NONINTERACTIVE_TESTING};
113
114     # More or less copied from Module::Build
115     return if $ENV{PERL_MM_USE_DEFAULT};
116     return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
117
118     sleep 4;
119 }
120