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