Fix for perl 5.6.2
[gitmo/Mouse.git] / Makefile.PL
1 # for developpers:
2 BEGIN{
3     if(grep{ $_ eq '--author' } @ARGV){
4         print "$^X -S cpanm < author/requires.cpanm\n";
5         system "$^X -S cpanm < author/requires.cpanm";
6     }
7 }
8
9 use strict;
10 use warnings;
11 use inc::Module::Install 0.99;
12
13 # for co-developpers
14 use Module::Install::XSUtil 0.24;
15 use Module::Install::AuthorTests;
16
17 system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
18     or warn "Cannot generate Mouse::Tiny: $!";
19
20 name     'Mouse';
21 all_from 'lib/Mouse.pm';
22
23 # Scalar::Util < 1.14 has a bug.
24 # > Fixed looks_like_number(undef) to return false for perl >= 5.009002
25 requires 'Scalar::Util' => 1.14;
26
27 test_requires 'Test::More'      => 0.88;
28
29 my %suggests = (
30     'Any::Moose'                     => 0.10,
31     'Data::Util'                     => 0.55,
32     'MouseX::AttributeHelpers'       => 0.06,
33 );
34
35 while(my($mod, $least) = each %suggests){
36     my $status = system $^X, '-e', <<"CHECK";
37 if(eval q{ use $mod (); 1 }) {
38     if(eval q{ use $mod $least (); 1 }) {
39         exit 0; # installd, and new enough
40     }
41     else {
42         exit 1; # installed, but too old
43     }
44 }
45 CHECK
46
47     if($status != 0){
48         my $ver = `$^X -e "use $mod (); print $mod->VERSION"`;
49         warn("\n",
50             "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n",
51             "         Please update $mod after installation of Mouse.\n",
52             "\n"
53         );
54     }
55 }
56
57 # cc_want deals with the '--pp' and '--xs' options
58 my $use_xs = ($] >= 5.008_001 && want_xs());
59
60 if($use_xs){
61     print "Mouse configured with XS.\n",
62           "NOTE: You can try --pp option to configure Mouse with Pure Perl.\n";
63
64     cc_warnings();
65     use_ppport(3.19);
66     cc_src_paths('xs-src');
67 }
68 else{
69     print "Mouse configured with Pure Perl.\n";
70 }
71
72
73 tests 't/*.t t/*/*.t';
74 author_tests 'xt';
75
76 repository 'git://git.moose.perl.org/Mouse.git';
77
78 if ($Module::Install::AUTHOR) {
79     require 'lib/Mouse/Spec.pm'; # for the version
80     my $require_version = Mouse::Spec->MooseVersion;
81
82     if (eval { require Moose; Moose->VERSION($require_version) }) {
83         print "You have Moose ", Moose->VERSION, ".\n";
84         if (eval { require Module::Install::AuthorTests }) {
85             do 'tool/create-moose-compatibility-tests.pl';
86             # repeat testing
87             # see also ExtUtils::MM_Any::test_via_harness()
88             my $t_moose =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
89                           .q{ "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')"}
90                           .q{ xt/compatibility/t/*/*.t } . "\n";
91
92             postamble qq{test_dynamic :: test_moose\n\n}
93                     . qq{test_moose :: pure_all\n}
94                     . qq{\t} . $t_moose;
95         } else {
96             print "You don't have a M::I::AuthorTests.\n";
97         }
98     } else {
99         print "You don't have Moose $require_version. skipping moose compatibility test\n";
100     }
101
102     if($use_xs){
103         # repeat testing
104         # see also ExtUtils::MM_Any::test_via_harness()
105         my $t_pp =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
106                    .q{ "do 'tool/force-pp.pl'; test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')"}
107                    .q{ $(TEST_FILES)} . "\n";
108
109         postamble qq{test_dynamic :: test_pp\n\n}
110                 . qq{test_pp :: pure_all\n}
111                 . qq{\t} . $t_pp;
112     }
113 }
114
115 clean_files q{
116     lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
117     *.out
118     cover_db xs-src/*.gc{v,no,da}
119 };
120
121 WriteAll check_nmake => 0;