Skip to content

Commit a0b9888

Browse files
committed
Breakup MakeMaker->new: makefile_preamble method
1 parent 0c5e618 commit a0b9888

File tree

1 file changed

+36
-38
lines changed

1 file changed

+36
-38
lines changed

lib/ExtUtils/MakeMaker.pm

+36-38
Original file line numberDiff line numberDiff line change
@@ -476,44 +476,7 @@ END
476476
File::Spec->catfile($Config{'archlibexp'}, "Config.pm")
477477
);
478478

479-
my($argv) = neatvalue(\@ARGV);
480-
$argv =~ s/^\[/(/;
481-
$argv =~ s/\]$/)/;
482-
push @{$self->{RESULT}}, <<END;
483-
# This Makefile is for the $self->{NAME} extension to perl.
484-
#
485-
# It was generated automatically by MakeMaker version
486-
# $VERSION (Revision: $Revision) from the contents of
487-
# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
488-
#
489-
# ANY CHANGES MADE HERE WILL BE LOST!
490-
#
491-
# MakeMaker ARGV: $argv
492-
#
493-
END
494-
495-
push @{$self->{RESULT}}, $self->_MakeMaker_Parameters_section(\%initial_att);
496-
497-
if (defined $self->{CONFIGURE}) {
498-
push @{$self->{RESULT}}, <<END;
499-
500-
# MakeMaker 'CONFIGURE' Parameters:
501-
END
502-
if (scalar(keys %configure_att) > 0) {
503-
foreach my $key (sort keys %configure_att) {
504-
next if $key eq 'ARGS';
505-
my($v) = neatvalue($configure_att{$key});
506-
$v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
507-
$v =~ tr/\n/ /s;
508-
push @{$self->{RESULT}}, "# $key => $v";
509-
}
510-
}
511-
else
512-
{
513-
push @{$self->{RESULT}}, "# no values returned";
514-
}
515-
undef %configure_att; # free memory
516-
}
479+
$self->makefile_preamble(\@ARGV, \%initial_att, \%configure_att);
517480

518481
# turn the SKIP array into a SKIPHASH hash
519482
for my $skip (@{$self->{SKIP} || []}) {
@@ -556,6 +519,41 @@ END
556519
$self;
557520
}
558521

522+
sub makefile_preamble {
523+
my ($self, $argvref, $initial_att, $configure_att) = @_;
524+
my ($argv) = neatvalue($argvref);
525+
$argv =~ s/^\[/(/;
526+
$argv =~ s/\]$/)/;
527+
my $results = $self->{RESULT}; # cache, plus looks nicer
528+
push @$results, <<END;
529+
# This Makefile is for the $self->{NAME} extension to perl.
530+
#
531+
# It was generated automatically by MakeMaker version
532+
# $VERSION (Revision: $Revision) from the contents of
533+
# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
534+
#
535+
# ANY CHANGES MADE HERE WILL BE LOST!
536+
#
537+
# MakeMaker ARGV: $argv
538+
#
539+
END
540+
push @$results, $self->_MakeMaker_Parameters_section($initial_att);
541+
if (defined $self->{CONFIGURE}) {
542+
push @$results, "\n# MakeMaker 'CONFIGURE' Parameters:\n";
543+
if (scalar(keys %$configure_att) > 0) {
544+
foreach my $key (sort keys %$configure_att) {
545+
next if $key eq 'ARGS';
546+
my($v) = neatvalue($configure_att->{$key});
547+
$v =~ s/(CODE|HASH|ARRAY|SCALAR)\([\dxa-f]+\)/$1\(...\)/;
548+
$v =~ tr/\n/ /s;
549+
push @$results, "# $key => $v";
550+
}
551+
} else {
552+
push @$results, "# no values returned";
553+
}
554+
}
555+
}
556+
559557
sub extract_ARGV {
560558
my ($self, $argvref) = @_;
561559
if ($self->{PARENT}) {

0 commit comments

Comments
 (0)