1package Test::File;
2use strict;
3use warnings;
4
5=encoding utf8
6
7=head1 The build file for Test::File
8
9This build file is a modulino; it works as both a build script and
10a module.
11
12To build the distribution, run this file normally:
13
14	% perl Makefile.PL
15
16But, it's more interesting than that. You can load it with C<require>
17and call C<arguments> to get the data structure it passes to
18C<WriteMakefile>:
19
20	my $package = require '/path/to/Makefile.PL';
21	my $arguments = $package->arguments;
22
23Note that C<require>-ing a file makes an entry in C<%INC> for exactly
24that name. If you try to C<require> another file with the same name,
25even from a different path, C<require> thinks it has already loaded
26the file. As such, I recommend you always require the full path to the
27file.
28
29The return value of the C<require> is a package name (in this case,
30the name of the main module. Use that to call the C<arguments> method.
31
32Even if this distribution needs a higher version of Perl, this bit
33only needs v5.8. You can play with the data structure with a primitive
34Perl.
35
36=cut
37
38use File::Spec::Functions qw(catfile);
39
40my $module    = __PACKAGE__;
41( my $dist = $module ) =~ s/::/-/g;
42
43my $github    = 'https://github.com/briandfoy/test-file';
44my $main_file = catfile( 'lib', split /::/, "$module.pm" );
45
46my %WriteMakefile = (
47	'MIN_PERL_VERSION' => '5.008',
48
49	'NAME'          => $module,
50	'VERSION_FROM'  => $main_file,
51	'ABSTRACT_FROM' => $main_file,
52	'LICENSE'       => 'artistic_2',
53	'AUTHOR'        => 'brian d foy <bdfoy@cpan.org>',
54
55	'CONFIGURE_REQUIRES' => {
56		'ExtUtils::MakeMaker'   => '6.64',
57		'File::Spec::Functions' => '0',
58		},
59
60	'BUILD_REQUIRES' => {
61		},
62
63	'TEST_REQUIRES' => {
64		'Test::More'            => '1',
65		'Test::Builder::Tester' => '1.04',
66		'Test::Builder'         => '1.001006',
67		'Test::utf8'            => '0',
68		},
69
70	'PREREQ_PM' => {
71		},
72
73	'META_MERGE' => {
74		'meta-spec' => { version => 2 },
75		keywords    => ['testing','file'],
76		resources => {
77			repository => {
78				type => 'git',
79				url  => "$github.git",
80				web  => $github,
81				},
82			bugtracker => {
83				web    => "$github/issues",
84				},
85			homepage => $github,
86			},
87		no_index => {
88			package   => [ qw( version Local ) ],
89			directory => [ qw( t/inc inc ) ],
90			file      => [ qw( t/lib/test.pm ) ],
91			namespace => [ qw( Local ) ],
92			},
93		},
94
95	clean  => { FILES    => qq|$dist-*| },
96	test   => { TESTS    => 't/*.t t/*/*.t' },
97	);
98
99
100sub arguments { \%WriteMakefile }
101
102do_it() unless caller;
103sub do_it {
104	my $MM ='ExtUtils::MakeMaker';
105	my $MM_version =
106		eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} }
107			||
108		"$MM 6.64";
109	eval "use $MM_version; 1" or die "Could not load $MM_version: $@";
110	eval "use Test::Manifest 1.21";
111
112	my $arguments = arguments();
113	my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008';
114	eval "require $minimum_perl;" or die $@;
115
116	WriteMakefile( %$arguments );
117	}
118
119BEGIN {
120use ExtUtils::MM_Unix;
121package ExtUtils::MM_Unix;
122
123my $original = \&ExtUtils::MM_Unix::init_dirscan;
124no warnings 'redefine';
125
126*init_dirscan = sub {
127	&$original;
128	delete $_[0]{PM}{'README.pod'};
129	$_[0];
130	};
131}
132
133no warnings;
134__PACKAGE__;
135