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