Mouse::Util::does_role() respects $thing->does() method
[gitmo/Mouse.git] / Makefile.PL
CommitLineData
972340a6 1# COMPAT_TEST=1 genrates Moose compatible tests
e8c583d3 2# for developpers:
3BEGIN{
4 if(grep{ $_ eq '--author' } @ARGV){
01f38ab1 5 print "$^X -S cpanm < author/requires.cpanm\n";
e8c583d3 6 system "$^X -S cpanm < author/requires.cpanm";
7 }
8}
9
08f7a8db 10use strict;
11use warnings;
9c96124c 12BEGIN {
1746908e 13 unshift @INC, 'inc';
14
9c96124c 15 # author requires, or bundled modules
16 my @devmods = qw(
17 inc::Module::Install 1.00
18 Module::Install::TestTarget 0.13
19 Module::Install::AuthorTests 0.002
20 Module::Install::XSUtil 0.36
21 Test::Exception::LessClever 0.005
22 Test::Requires 0.06
23 );
24 my @not_available;
25 while(my($mod, $ver) = splice @devmods, 0, 2) {
26 eval qq{use $mod $ver (); 1} or push @not_available, $mod;
27 }
28 if(@not_available) {
29 print qq{# The following modules are not available.\n};
30 print qq{# `perl $0 | cpanm` will install them:\n};
31 print $_, "\n" for @not_available;
32 exit 1;
33 }
34}
35use inc::Module::Install;
884bf37f 36
c3398f5b 37all_from 'lib/Mouse.pm';
38
ec53d678 39# Scalar::Util < 1.14 has a bug.
40# > Fixed looks_like_number(undef) to return false for perl >= 5.009002
41requires 'Scalar::Util' => 1.14;
272a1930 42
9c96124c 43test_requires 'Test::More' => 0.88;
f7f4955d 44
45# to keep zero-dependencies
46include 'Test::Exception::LessClever';
47include 'Test::Requires';
179ac6cc 48
3310ddf2 49my %suggests = (
af1c2a64 50 'Any::Moose' => 0.10,
8e4a10a8 51
3310ddf2 52 'MouseX::AttributeHelpers' => 0.06,
32ec255c 53 'MouseX::NativeTraits' => 1.00,
3310ddf2 54);
3310ddf2 55while(my($mod, $least) = each %suggests){
6741954a 56 my $status = system $^X, '-e', <<"CHECK";
57if(eval q{ use $mod (); 1 }) {
58 if(eval q{ use $mod $least (); 1 }) {
c4f4f5e3 59 exit 0; # installd, and new enough
60 }
61 else {
62 exit 1; # installed, but too old
63 }
64}
65CHECK
66
67 if($status != 0){
68 my $ver = `$^X -e "use $mod (); print $mod->VERSION"`;
69 warn("\n",
70 "WARNING: $mod is installed, but its version ($ver) is too old (< $least).\n",
71 " Please update $mod after installation of Mouse.\n",
72 "\n"
73 );
3310ddf2 74 }
75}
76
ec7a9423 77# cc_want deals with the '--pp' and '--xs' options
78my $use_xs = ($] >= 5.008_001 && want_xs());
0e81c55d 79
80if($use_xs){
2af88019 81 print "Mouse configured with XS.\n";
bb543d7f 82
fdee07cc 83 use_ppport(3.19);
8e4a10a8 84 use_xshelper();
2af88019 85 cc_warnings();
0e81c55d 86 cc_src_paths('xs-src');
758664cd 87 if($use_xs){
38f4a557 88 test_target test_pp => (
89 env => { PERL_ONLY => 1 },
90 ($Module::Install::AUTHOR ? (alias => 'test') : ()),
91 );
758664cd 92 }
38f4a557 93}
0e81c55d 94else{
7b92a82b 95 print "Mouse configured with Pure Perl.\n";
0e81c55d 96}
97
125dc1a8 98tests 't/*.t t/*/*.t';
1e2f2888 99author_tests 'xt';
100
40762421 101homepage 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Mouse.git';
125dc1a8 102repository 'git://git.moose.perl.org/Mouse.git';
03eb8368 103# or web interface:
104# http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Mouse.git;a=summary
125dc1a8 105
823419c5 106system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
107 or warn "Cannot generate Mouse::Tiny: $!";
108makemaker_args PL_FILES => {
109 'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
110};
111
af1c2a64 112if ($Module::Install::AUTHOR) {
113 require 'lib/Mouse/Spec.pm'; # for the version
121acb8a 114 my $require_version = Mouse::Spec->MooseVersion;
bf9f3f91 115
972340a6 116 if ($ENV{COMPAT_TEST}
117 && eval { require Moose; Moose->VERSION($require_version) }) {
92ff14d0 118 print "You have Moose ", Moose->VERSION, ".\n";
2af88019 119 do 'tool/create-moose-compatibility-tests.pl';
38f4a557 120 test_target test_moose => (
121 tests => ['xt/compat/t/*/*.t'],
122 alias => 'test',
123 );
314fe304 124 } else {
92ff14d0 125 print "You don't have Moose $require_version. skipping moose compatibility test\n";
314fe304 126 }
4358792d 127
f7f4955d 128
129 # Hack to disable Test::Exception, which might pull a perl internal bug.
130 # See also Test::Exception::LessClever.
131 open my $out, '>', 'inc/Test/Exception.pm' or die $!;
132 print $out <<'EOT';
133package Test::Exception; # wapper to T::E::LessClever
134require Test::Exception::LessClever;
135$INC{'Test/Exception.pm'} = __FILE__;
136sub import {
137 shift;
138 Test::Exception::LessClever->export_to_level(1, @_);
139}
1401;
141EOT
142 close $out or die $!;
314fe304 143}
144
af1c2a64 145clean_files q{
146 lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
b910af20 147 xshelper.h
af1c2a64 148 *.out
149 cover_db xs-src/*.gc{v,no,da}
150};
1e2f2888 151
eb88905f 152WriteAll check_nmake => 0;