Use Module::Info instead of eval "require $mod" in Makefile.PL
[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.';
d846ade3 15$ccflags .= ' -Wall' if -d '.svn' || -d '.git' || $ENV{MAINTAINER_MODE};
f125b31e 16
89dc39a9 17requires 'Carp';
18requires 'Devel::GlobalDestruction';
d065fbe6 19requires 'MRO::Compat' => '0.05';
20requires 'Scalar::Util' => '1.18';
21requires 'Sub::Name' => '0.04';
89dc39a9 22requires 'Task::Weaken';
23
24test_requires 'File::Spec';
7975280a 25test_requires 'Test::More' => '0.88';
4cd537dd 26test_requires 'Test::Exception' => '0.27';
89dc39a9 27
4f262fc6 28install_headers('mop.h'); # need Module::Install::XSUtil
e989c0df 29
30#extra_tests();
3fd3a2ab 31
89dc39a9 32makemaker_args( CCFLAGS => $ccflags );
33
d846ade3 34{
35 my (@clean, @OBJECT, %XS);
36
37 for my $xs (<xs/*.xs>) {
38 (my $c = $xs) =~ s/\.xs$/.c/i;
39 (my $o = $xs) =~ s/\.xs$/\$(OBJ_EXT)/i;
40
41 $XS{$xs} = $c;
42 push @OBJECT, $o;
43 push @clean, $o;
44 }
45
46 for my $c (<*.c>) {
47 (my $o = $c) =~ s/\.c$/\$(OBJ_EXT)/i;
48 push @OBJECT, $o;
49 push @clean, $o;
50 }
51
52 makemaker_args(
53 clean => { FILES => join(q{ }, @clean) },
54 OBJECT => join (q{ }, @OBJECT),
55 XS => \%XS,
56 );
57}
58
8a9fe086 59postamble(<<'EOM');
60$(OBJECT) : mop.h
61EOM
62
89dc39a9 63WriteAll();
64
65# Use the cpan-smolder-stable script in the Moose svn root to figure
66# out what on CPAN will break with the latest Moose, then update this
67# before a release.
68sub check_conflicts {
69 my %conflicts = (
0dc00e2f 70 'Moose' => '0.85',
89dc39a9 71 );
72
e97ccbf1 73 my $has_module_info = eval{ require Module::Info };
74 my $get_version = $has_module_info
75 ? sub{ Module::Info->new_from_module($_[0])->version }
76 : sub{ eval qq{ require $_[0] } ? $_[0]->VERSION : undef };
77
89dc39a9 78 my $found = 0;
79 for my $mod ( sort keys %conflicts ) {
e97ccbf1 80 my $installed = $get_version->($mod);
89dc39a9 81
e97ccbf1 82 if ( defined($installed) && $installed le $conflicts{$mod} ) {
89dc39a9 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
94EOF
95
96 $found = 1;
97 }
98 }
99
100 return unless $found;
101
102 # More or less copied from Module::Build
d065fbe6 103 return if $ENV{PERL_MM_USE_DEFAULT};
104 return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
89dc39a9 105
106 sleep 4;
107}
d846ade3 108
109package MY;
110
111use Config;
112
113sub 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}