Allow requiring a version with is_class_loaded, load_class and load_first_existing_class.
[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';
4154c4d0 21requires 'Data::OptList';
89dc39a9 22requires 'Devel::GlobalDestruction';
d065fbe6 23requires 'MRO::Compat' => '0.05';
24requires 'Scalar::Util' => '1.18';
25requires 'Sub::Name' => '0.04';
a8344505 26requires 'Try::Tiny' => '0.02';
89dc39a9 27requires 'Task::Weaken';
28
29test_requires 'File::Spec';
7975280a 30test_requires 'Test::More' => '0.88';
4cd537dd 31test_requires 'Test::Exception' => '0.27';
89dc39a9 32
3fd3a2ab 33extra_tests();
34
89dc39a9 35makemaker_args( CCFLAGS => $ccflags );
36
d846ade3 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
8a9fe086 62postamble(<<'EOM');
63$(OBJECT) : mop.h
64EOM
65
89dc39a9 66WriteAll();
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.
71sub check_conflicts {
72 my %conflicts = (
0dc00e2f 73 'Moose' => '0.85',
89dc39a9 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
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}