5
5
use ExtUtils::MakeMaker ();
6
6
use Module::Install::Base ();
7
use Fcntl qw/:flock :seek/;
8
9
use vars qw{$VERSION @ISA $ISCORE};
11
12
@ISA = 'Module::Install::Base';
25
26
die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
28
# In automated testing, always use defaults
29
if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
29
# In automated testing or non-interactive session, always use defaults
30
if ( ($ENV{AUTOMATED_TESTING} or -! -t STDIN) and ! $ENV{PERL_MM_USE_DEFAULT} ) {
30
31
local $ENV{PERL_MM_USE_DEFAULT} = 1;
31
32
goto &ExtUtils::MakeMaker::prompt;
45
46
( @_ < 2 or $makemaker >= eval($_[1]) ) ? $makemaker : 0
49
# Ripped from ExtUtils::MakeMaker 6.56, and slightly modified
50
# as we only need to know here whether the attribute is an array
51
# or a hash or something else (which may or may not be appendable).
52
my %makemaker_argtype = (
55
# CONFIGURE => 'CODE', # ignore
59
EXCLUDE_EXT => 'ARRAY',
64
INCLUDE_EXT => 'ARRAY',
65
LIBS => 'ARRAY', # ignore ''
73
PMLIBPARENTDIRS => 'ARRAY',
75
CONFIGURE_REQUIRES => 'HASH',
79
# VERSION => ['version',''], # ignore
80
# _KEEP_AFTER_FLUSH => '',
91
tool_autosplit => 'HASH',
93
# special cases where you can use makemaker_append
94
CCFLAGS => 'APPENDABLE',
95
DEFINE => 'APPENDABLE',
97
LDDLFLAGS => 'APPENDABLE',
98
LDFROM => 'APPENDABLE',
48
101
sub makemaker_args {
102
my ($self, %new_args) = @_;
50
103
my $args = ( $self->{makemaker_args} ||= {} );
51
%$args = ( %$args, @_ );
104
foreach my $key (keys %new_args) {
105
if ($makemaker_argtype{$key}) {
106
if ($makemaker_argtype{$key} eq 'ARRAY') {
107
$args->{$key} = [] unless defined $args->{$key};
108
unless (ref $args->{$key} eq 'ARRAY') {
109
$args->{$key} = [$args->{$key}]
111
push @{$args->{$key}},
112
ref $new_args{$key} eq 'ARRAY'
116
elsif ($makemaker_argtype{$key} eq 'HASH') {
117
$args->{$key} = {} unless defined $args->{$key};
118
foreach my $skey (keys %{ $new_args{$key} }) {
119
$args->{$key}{$skey} = $new_args{$key}{$skey};
122
elsif ($makemaker_argtype{$key} eq 'APPENDABLE') {
123
$self->makemaker_append($key => $new_args{$key});
127
if (defined $args->{$key}) {
128
warn qq{MakeMaker attribute "$key" is overriden; use "makemaker_append" to append values\n};
130
$args->{$key} = $new_args{$key};
60
141
my $args = $self->makemaker_args;
61
$args->{name} = defined $args->{$name}
62
? join( ' ', $args->{name}, @_ )
142
$args->{$name} = defined $args->{$name}
143
? join( ' ', $args->{$name}, @_ )
63
144
: join( ' ', @_ );
100
181
$self->makemaker_args( INC => shift );
106
/\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1;
109
187
sub tests_recursive {
110
188
my $self = shift;
111
if ( $self->tests ) {
112
die "tests_recursive will not work if tests are already defined";
114
189
my $dir = shift || 't';
115
190
unless ( -d $dir ) {
116
191
die "tests_recursive dir '$dir' does not exist";
193
my %tests = map { $_ => 1 } split / /, ($self->tests || '');
119
194
require File::Find;
120
File::Find::find( \&_wanted_t, $dir );
121
if ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) {
122
File::Find::find( \&_wanted_t, 'xt' );
124
$self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir );
196
sub { /\.t$/ and -f $_ and $tests{"$File::Find::dir/*.t"} = 1 },
199
$self->tests( join ' ', sort keys %tests );
158
233
my $args = $self->makemaker_args;
159
234
$args->{DISTNAME} = $self->name;
160
235
$args->{NAME} = $self->module_name || $self->name;
161
$args->{VERSION} = $self->version;
162
236
$args->{NAME} =~ s/-/::/g;
237
$args->{VERSION} = $self->version or die <<'EOT';
238
ERROR: Can't determine distribution version. Please specify it
239
explicitly via 'version' in Makefile.PL, or set a valid $VERSION
240
in a module, and provide its file path via 'version_from' (or
241
'all_from' if you prefer) in Makefile.PL.
164
245
if ( $self->tests ) {
246
my @tests = split ' ', $self->tests;
165
248
$args->{test} = {
166
TESTS => $self->tests,
249
TESTS => (join ' ', grep {!$seen{$_}++} @tests),
251
} elsif ( $Module::Install::ExtraTests::use_extratests ) {
252
# Module::Install::ExtraTests doesn't set $self->tests and does its own tests via harness.
253
# So, just ignore our xt tests here.
168
254
} elsif ( -d 'xt' and ($Module::Install::AUTHOR or $ENV{RELEASE_TESTING}) ) {
169
255
$args->{test} = {
170
256
TESTS => join( ' ', map { "$_/*.t" } grep { -d $_ } qw{ t xt } ),
173
259
if ( $] >= 5.005 ) {
174
260
$args->{ABSTRACT} = $self->abstract;
175
$args->{AUTHOR} = $self->author;
261
$args->{AUTHOR} = join ', ', @{$self->author || []};
177
263
if ( $self->makemaker(6.10) ) {
178
264
$args->{NO_META} = 1;
208
297
# Remove any reference to perl, BUILD_REQUIRES doesn't support it
209
298
delete $args->{BUILD_REQUIRES}->{perl};
211
# Delete bundled dists from prereq_pm
212
my $subdirs = ($args->{DIR} ||= []);
300
# Delete bundled dists from prereq_pm, add it to Makefile DIR
301
my $subdirs = ($args->{DIR} || []);
213
302
if ($self->bundles) {
214
304
foreach my $bundle (@{ $self->bundles }) {
215
my ($file, $dir) = @$bundle;
216
push @$subdirs, $dir if -d $dir;
217
delete $build_prereq->{$file}; #Delete from build prereqs only
305
my ($mod_name, $dist_dir) = @$bundle;
306
delete $prereq->{$mod_name};
307
$dist_dir = File::Basename::basename($dist_dir); # dir for building this module
308
if (not exists $processed{$dist_dir}) {
310
# List as sub-directory to be processed by make
311
push @$subdirs, $dist_dir;
313
# Else do nothing: the module is already present on the system
314
$processed{$dist_dir} = undef;
236
$args->{INSTALLDIRS} = $self->installdirs;
334
if ($self->installdirs) {
335
warn qq{old INSTALLDIRS (probably set by makemaker_args) is overriden by installdirs\n} if $args->{INSTALLDIRS};
336
$args->{INSTALLDIRS} = $self->installdirs;
239
340
( $_ => $args->{$_} ) } grep {defined($args->{$_} )
264
365
. ($self->postamble || '');
267
open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
368
open MAKEFILE, "+< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
369
eval { flock MAKEFILE, LOCK_EX };
268
370
my $makefile = do { local $/; <MAKEFILE> };
269
close MAKEFILE or die $!;
271
372
$makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
272
373
$makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
286
387
# XXX - This is currently unused; not sure if it breaks other MM-users
287
388
# $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
289
open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
390
seek MAKEFILE, 0, SEEK_SET;
391
truncate MAKEFILE, 0;
290
392
print MAKEFILE "$preamble$makefile$postamble" or die $!;
291
393
close MAKEFILE or die $!;