replace several uses of eval with try
[gitmo/Class-MOP.git] / Makefile.PL
CommitLineData
591a9381 1use strict;
2use warnings;
89dc39a9 3use inc::Module::Install;
4use 5.008001;
5
6check_conflicts();
7
8name 'Class-MOP';
9perl_version '5.008001';
10all_from 'lib/Class/MOP.pm';
11license 'perl';
591a9381 12
72bc0a47 13require Config;
14my $ccflags = ( $Config::Config{ccflags} || '' ) . ' -I.';
06e9254b 15
16if ( -d '.git' || $ENV{MAINTAINER_MODE} ) {
17 $ccflags .= ' -Wall -Wdeclaration-after-statement';
18}
f125b31e 19
89dc39a9 20requires 'Carp';
21requires 'Devel::GlobalDestruction';
d065fbe6 22requires 'MRO::Compat' => '0.05';
23requires 'Scalar::Util' => '1.18';
24requires 'Sub::Name' => '0.04';
a8344505 25requires 'Try::Tiny' => '0.02';
89dc39a9 26requires 'Task::Weaken';
27
28test_requires 'File::Spec';
7975280a 29test_requires 'Test::More' => '0.88';
4cd537dd 30test_requires 'Test::Exception' => '0.27';
89dc39a9 31
3fd3a2ab 32extra_tests();
33
89dc39a9 34makemaker_args( CCFLAGS => $ccflags );
35
d846ade3 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
8a9fe086 61postamble(<<'EOM');
62$(OBJECT) : mop.h
63EOM
64
89dc39a9 65WriteAll();
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.
70sub check_conflicts {
71 my %conflicts = (
0dc00e2f 72 'Moose' => '0.85',
89dc39a9 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
93EOF
94
95 $found = 1;
96 }
97 }
98
99 return unless $found;
100
101 # More or less copied from Module::Build
d065fbe6 102 return if $ENV{PERL_MM_USE_DEFAULT};
103 return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
89dc39a9 104
105 sleep 4;
106}
d846ade3 107
108package MY;
109
110use Config;
111
112sub 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}