Tidy lists of required modules
[gitmo/Class-MOP.git] / Makefile.PL
1 use strict;
2 use warnings;
3 use inc::Module::Install;
4 use Module::Install::AuthorRequires;
5 use Module::Install::ExtraTests;
6 use 5.008001;
7
8 check_conflicts();
9
10 name 'Class-MOP';
11 perl_version '5.008001';
12 all_from 'lib/Class/MOP.pm';
13 license 'perl';
14
15 require Config;
16 my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.';
17
18 if ( -d '.git' || $ENV{MAINTAINER_MODE} ) {
19     $ccflags .= ' -Wall -Wdeclaration-after-statement';
20 }
21
22 requires 'Carp';
23 requires 'Data::OptList';
24 requires 'Devel::GlobalDestruction';
25 requires 'List::MoreUtils'             => '0.12';
26 requires 'MRO::Compat'                 => '0.05';
27 requires 'Package::DeprecationManager' => '0.10';
28 requires 'Package::Stash'              => '0.08';
29 requires 'Scalar::Util'                => '1.18';
30 requires 'Sub::Name'                   => '0.04';
31 requires 'Try::Tiny'                   => '0.02';
32 requires 'Task::Weaken';
33
34 test_requires 'File::Spec';
35 test_requires 'Test::More'     => '0.88';
36 test_requires 'Test::Fatal'    => '0.001';
37 test_requires 'Test::Requires' => '0.05';
38
39 author_requires 'Algorithm::C3';
40 author_requires 'Module::Info';
41 author_requires 'Test::LeakTrace';
42 author_requires 'Test::NoTabs';
43 author_requires 'Test::Output';
44 author_requires 'Test::Spelling';
45
46 repository 'git://git.moose.perl.org/Class-MOP.git';
47 add_metadata(x_authority => 'cpan:STEVAN');
48
49 extra_tests();
50
51 makemaker_args( CCFLAGS => $ccflags );
52
53 {
54     my (@clean, @OBJECT, %XS);
55
56     for my $xs (<xs/*.xs>) {
57         (my $c = $xs) =~ s/\.xs$/.c/i;
58         (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
59
60         $XS{$xs} = $c;
61         push @OBJECT, $o;
62         push @clean, $o;
63     }
64
65     for my $c (<*.c>) {
66         (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
67         push @OBJECT, $o;
68         push @clean, $o;
69     }
70
71     makemaker_args(
72         clean  => { FILES => join(q{ }, @clean) },
73         OBJECT => join (q{ }, @OBJECT),
74         XS     => \%XS,
75     );
76 }
77
78 postamble(<<'EOM');
79 $(OBJECT) : mop.h
80 EOM
81
82 WriteAll();
83
84 # Use the cpan-smolder-stable script in the Moose svn root to figure
85 # out what on CPAN will break with the latest Moose, then update this
86 # before a release.
87 sub check_conflicts {
88     my %conflicts = (
89         'Moose'                         => '1.14',
90         'namespace::autoclean'          => '0.08',
91     );
92
93     my $found = 0;
94     for my $mod ( sort keys %conflicts ) {
95         eval "require $mod";
96         next if $@;
97
98         my $installed = $mod->VERSION();
99         if ( $installed le $conflicts{$mod} ) {
100
101             print <<"EOF";
102
103 ***
104     This version of Class::MOP conflicts with the version of
105     $mod ($installed) you have installed.
106
107     You will need to upgrade $mod after installing
108     this version of Class::MOP.
109 ***
110
111 EOF
112
113             $found = 1;
114         }
115     }
116
117     return unless $found;
118
119     # More or less copied from Module::Build
120     return if $ENV{PERL_MM_USE_DEFAULT};
121     return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
122
123     sleep 4;
124 }
125
126 package MY;
127
128 use Config;
129
130 sub const_cccmd {
131     my $ret = shift->SUPER::const_cccmd(@_);
132     return q{} unless $ret;
133
134     if ($Config{cc} =~ /^cl\b/i) {
135         warn 'you are using MSVC... my condolences.';
136         $ret .= ' /Fo$@';
137     }
138     else {
139         $ret .= ' -o $@';
140     }
141
142     return $ret;
143 }