Merge branch 'master' of github.com:gfx/p5-Mouse-temporary
[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
125dc1a8 101repository 'git://git.moose.perl.org/Mouse.git';
03eb8368 102# or web interface:
103# http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Mouse.git;a=summary
125dc1a8 104
823419c5 105system($^X, 'tool/generate-mouse-tiny.pl', 'lib/Mouse/Tiny.pm') == 0
106 or warn "Cannot generate Mouse::Tiny: $!";
107makemaker_args PL_FILES => {
108 'tool/generate-mouse-tiny.pl' => 'lib/Mouse/Tiny.pm',
109};
110
af1c2a64 111if ($Module::Install::AUTHOR) {
112 require 'lib/Mouse/Spec.pm'; # for the version
121acb8a 113 my $require_version = Mouse::Spec->MooseVersion;
bf9f3f91 114
972340a6 115 if ($ENV{COMPAT_TEST}
116 && eval { require Moose; Moose->VERSION($require_version) }) {
92ff14d0 117 print "You have Moose ", Moose->VERSION, ".\n";
2af88019 118 do 'tool/create-moose-compatibility-tests.pl';
38f4a557 119 test_target test_moose => (
120 tests => ['xt/compat/t/*/*.t'],
121 alias => 'test',
122 );
314fe304 123 } else {
92ff14d0 124 print "You don't have Moose $require_version. skipping moose compatibility test\n";
314fe304 125 }
4358792d 126
f7f4955d 127
128 # Hack to disable Test::Exception, which might pull a perl internal bug.
129 # See also Test::Exception::LessClever.
130 open my $out, '>', 'inc/Test/Exception.pm' or die $!;
131 print $out <<'EOT';
132package Test::Exception; # wapper to T::E::LessClever
133require Test::Exception::LessClever;
134$INC{'Test/Exception.pm'} = __FILE__;
135sub import {
136 shift;
137 Test::Exception::LessClever->export_to_level(1, @_);
138}
1391;
140EOT
141 close $out or die $!;
314fe304 142}
143
af1c2a64 144clean_files q{
145 lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log
b910af20 146 xshelper.h
af1c2a64 147 *.out
148 cover_db xs-src/*.gc{v,no,da}
149};
1e2f2888 150
eb88905f 151WriteAll check_nmake => 0;