CMOP now conflicts with the most recent release of Moose
[gitmo/Class-MOP.git] / Makefile.PL
1 use strict;
2 use warnings;
3 use inc::Module::Install;
4 use 5.008001;
5
6 check_conflicts();
7
8 name 'Class-MOP';
9 perl_version '5.008001';
10 all_from 'lib/Class/MOP.pm';
11 license 'perl';
12
13 my $ccflags = ' -I.';
14 $ccflags .= ' -Wall' if -d '.svn' || -d '.git' || $ENV{MAINTAINER_MODE};
15
16 requires 'Carp';
17 requires 'Devel::GlobalDestruction';
18 requires 'MRO::Compat'  => '0.05';
19 requires 'Scalar::Util' => '1.18';
20 requires 'Sub::Name'    => '0.04';
21 requires 'Task::Weaken';
22
23 test_requires 'File::Spec';
24 test_requires 'Test::More'      => '0.77';
25 test_requires 'Test::Exception' => '0.21';
26
27 makemaker_args( CCFLAGS => $ccflags );
28
29 {
30     my (@clean, @OBJECT, %XS);
31
32     for my $xs (<xs/*.xs>) {
33         (my $c = $xs) =~ s/\.xs$/.c/i;
34         (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
35
36         $XS{$xs} = $c;
37         push @OBJECT, $o;
38         push @clean, $o;
39     }
40
41     for my $c (<*.c>) {
42         (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
43         push @OBJECT, $o;
44         push @clean, $o;
45     }
46
47     makemaker_args(
48         clean  => { FILES => join(q{ }, @clean) },
49         OBJECT => join (q{ }, @OBJECT),
50         XS     => \%XS,
51     );
52 }
53
54 postamble(<<'EOM');
55 $(OBJECT) : mop.h
56 EOM
57
58 WriteAll();
59
60 # Use the cpan-smolder-stable script in the Moose svn root to figure
61 # out what on CPAN will break with the latest Moose, then update this
62 # before a release.
63 sub check_conflicts {
64     my %conflicts = (
65         'Moose' => '0.72',
66     );
67
68     my $found = 0;
69     for my $mod ( sort keys %conflicts ) {
70         eval "require $mod";
71         next if $@;
72
73         my $installed = $mod->VERSION();
74         if ( $installed le $conflicts{$mod} ) {
75
76             print <<"EOF";
77
78 ***
79     This version of Class::MOP conflicts with the version of
80     $mod ($installed) you have installed.
81
82     You will need to upgrade $mod after installing
83     this version of Class::MOP.
84 ***
85
86 EOF
87
88             $found = 1;
89         }
90     }
91
92     return unless $found;
93
94     # More or less copied from Module::Build
95     return if $ENV{PERL_MM_USE_DEFAULT};
96     return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
97
98     sleep 4;
99 }
100
101 package MY;
102
103 use Config;
104
105 sub const_cccmd {
106     my $ret = shift->SUPER::const_cccmd(@_);
107     return q{} unless $ret;
108
109     if ($Config{cc} =~ /^cl\b/i) {
110         warn 'you are using MSVC... my condolences.';
111         $ret .= ' /Fo$@';
112     }
113     else {
114         $ret .= ' -o $@';
115     }
116
117     return $ret;
118 }