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