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