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