13fec7d2faee2a6387318363f68125f1e0b5fefd
[p5sagit/Module-Metadata.git] / maint / Makefile.PL.include
1 use strict;
2 use warnings FATAL => 'all';
3
4 {
5   package MY;
6
7   {
8     no warnings 'once'; push @ExtUtils::MakeMaker::Overridable, 'find_tests';
9   }
10
11   sub find_tests {
12     shift->SUPER::find_tests.' xt/*.t';
13   }
14
15   sub postamble { 'include maint/Makefile.include' }
16 }
17
18 {
19   no warnings 'redefine';
20   sub WriteMakefile {
21     my %args = @_;
22     ExtUtils::MakeMaker::WriteMakefile(
23       %args,
24       AUTHOR => 'Ken Williams <kwilliams@cpan.org>, Randy W. Sims <RandyS@ThePierianSpring.org>',
25       ABSTRACT_FROM => $args{VERSION_FROM},
26     );
27   }
28 }
29
30 sub manifest_include {
31   use autodie;
32   my @files = @_;
33   my @parts;
34   while (my ($dir, $spec) = splice(@files, 0, 2)) {
35     my $re = ($dir ? $dir.'/' : '').
36       ((ref($spec) eq 'Regexp')
37         ? $spec
38         : !ref($spec)
39           ? ".*\Q${spec}\E"
40           : die "spec must be string or regexp, was: ${spec} (${\ref $spec})");
41     push @parts, $re;
42   }
43   my $final = '^(?!'.join('|', map "${_}\$", @parts).')';
44   open my $skip, '>', 'MANIFEST.SKIP';
45   print $skip "${final}\n";
46   close $skip;
47 }
48
49 manifest_include(
50   'lib' => '.pm',
51   't' => '.t',
52   't/lib' => '.pm',
53   'xt' => '.t',
54   'xt/lib' => '.pm',
55   '' => '.PL',
56   '' => qr{Changes|MANIFEST|README|META\.yml},
57   'maint' => qr{[^.].*},
58 );
59
60 1;