Improve Makefile.PL
[gitmo/Mouse.git] / Makefile.PL
1 BEGIN{ $INC{'Module/Install/ExtraTests.pm'} = __FILE__ } # to disable the use of ExtrTests
2 use strict;
3 use warnings;
4 use inc::Module::Install;
5
6 system($^X, 'author/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
7     or warn "Cannot generate Mouse::Tiny: $!";
8
9 name     'Mouse';
10 all_from 'lib/Mouse.pm';
11
12 tests 't/*.t t/*/*.t';
13
14 # Scalar::Util < 1.14 has a bug.
15 # > Fixed looks_like_number(undef) to return false for perl >= 5.009002
16 requires 'Scalar::Util' => 1.14;
17
18 configure_requires 'ExtUtils::CBuilder';
19
20 test_requires 'Test::More'      => 0.88;
21 test_requires 'Test::Exception' => 0.27;
22 # test_requires 'Test::Output'    => 0.16; # too many dependencies!
23
24
25 include_deps 'Test::Exception'; # work around 0.27_0x (its use of diehook might be wrong)
26
27 recommends 'MRO::Compat' if $] < 5.010;
28
29 my $use_xs;
30
31 for (@ARGV) {
32     /^--pp$/ and $use_xs = 0;
33     /^--xs$/ and $use_xs = 1;
34 }
35
36 if($] < 5.008_001){
37     $use_xs = 0;
38 }
39
40 if(!defined $use_xs){
41     $use_xs = eval {
42         require ExtUtils::CBuilder;
43         ExtUtils::CBuilder->new(quiet => 1)->have_compiler();
44     };
45 }
46
47 if($use_xs){
48     require Module::Install::XSUtil;
49     use_ppport(3.19);
50     cc_warnings();
51     cc_src_paths('xs-src');
52
53     print "Mouse configured in XS (--xs)\n";
54 }
55 else{
56     print "Mouse configured in Pure Perl (--pp)\n";
57 }
58
59 if (author_context()) {
60     local @INC = ('lib', @INC);
61     require 'lib/Mouse/Spec.pm';
62     my $require_version = Mouse::Spec->MooseVersion;
63
64     if (eval{ require Moose; Moose->VERSION($require_version) }) {
65         if (eval 'use Module::Install::AuthorTests; 1') {
66             do 'author/create-moose-compatibility-tests.pl';
67             recursive_author_tests('xt');
68         } else {
69             print "you don't have a M::I::AuthorTests.\n";
70         }
71     } else {
72         print "you don't have Moose $require_version. skipping moose compatibility test\n";
73     }
74
75     if($use_xs){
76         # repeat testing
77         # see also ExtUtils::MM_Any::test_via_harness()
78         my $test_via_harness =  q{$(FULLPERLRUN) -MExtUtils::Command::MM -e}
79                                .q{ "do 'author/force-pp.pl'; test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')"}
80                                .q{ $(TEST_FILES)} . "\n";
81
82         postamble qq{test_dynamic :: test_pp\n\n}
83                 . qq{test_pp :: pure_all\n}
84                 . qq{\t} . $test_via_harness;
85     }
86 }
87
88 clean_files 'lib/Mouse/Tiny.pm';
89
90 WriteAll check_nmake => 0;