6 | 6 |
|
7 | 7 |
use vars qw{$VERSION $ISCORE @ISA};
|
8 | 8 |
BEGIN {
|
9 | |
$VERSION = '0.64';
|
|
9 |
$VERSION = '0.67';
|
10 | 10 |
$ISCORE = 1;
|
11 | 11 |
@ISA = qw{Module::Install::Base};
|
12 | 12 |
}
|
|
16 | 16 |
my %seen = ();
|
17 | 17 |
|
18 | 18 |
sub prompt {
|
19 | |
shift;
|
20 | |
|
21 | |
# Infinite loop protection
|
22 | |
my @c = caller();
|
23 | |
if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
|
24 | |
die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
|
25 | |
}
|
26 | |
|
27 | |
# In automated testing, always use defaults
|
28 | |
if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
|
29 | |
local $ENV{PERL_MM_USE_DEFAULT} = 1;
|
30 | |
goto &ExtUtils::MakeMaker::prompt;
|
31 | |
} else {
|
32 | |
goto &ExtUtils::MakeMaker::prompt;
|
33 | |
}
|
|
19 |
shift;
|
|
20 |
|
|
21 |
# Infinite loop protection
|
|
22 |
my @c = caller();
|
|
23 |
if ( ++$seen{"$c[1]|$c[2]|$_[0]"} > 3 ) {
|
|
24 |
die "Caught an potential prompt infinite loop ($c[1]|$c[2]|$_[0])";
|
|
25 |
}
|
|
26 |
|
|
27 |
# In automated testing, always use defaults
|
|
28 |
if ( $ENV{AUTOMATED_TESTING} and ! $ENV{PERL_MM_USE_DEFAULT} ) {
|
|
29 |
local $ENV{PERL_MM_USE_DEFAULT} = 1;
|
|
30 |
goto &ExtUtils::MakeMaker::prompt;
|
|
31 |
} else {
|
|
32 |
goto &ExtUtils::MakeMaker::prompt;
|
|
33 |
}
|
34 | 34 |
}
|
35 | 35 |
|
36 | 36 |
sub makemaker_args {
|
37 | |
my $self = shift;
|
38 | |
my $args = ($self->{makemaker_args} ||= {});
|
39 | |
%$args = ( %$args, @_ ) if @_;
|
40 | |
$args;
|
|
37 |
my $self = shift;
|
|
38 |
my $args = ($self->{makemaker_args} ||= {});
|
|
39 |
%$args = ( %$args, @_ ) if @_;
|
|
40 |
$args;
|
41 | 41 |
}
|
42 | 42 |
|
43 | 43 |
# For mm args that take multiple space-seperated args,
|
44 | 44 |
# append an argument to the current list.
|
45 | 45 |
sub makemaker_append {
|
46 | |
my $self = shift;
|
47 | |
my $name = shift;
|
48 | |
my $args = $self->makemaker_args;
|
49 | |
$args->{name} = defined $args->{$name}
|
50 | |
? join( ' ', $args->{name}, @_ )
|
51 | |
: join( ' ', @_ );
|
|
46 |
my $self = sShift;
|
|
47 |
my $name = shift;
|
|
48 |
my $args = $self->makemaker_args;
|
|
49 |
$args->{name} = defined $args->{$name}
|
|
50 |
? join( ' ', $args->{name}, @_ )
|
|
51 |
: join( ' ', @_ );
|
52 | 52 |
}
|
53 | 53 |
|
54 | 54 |
sub build_subdirs {
|
55 | |
my $self = shift;
|
56 | |
my $subdirs = $self->makemaker_args->{DIR} ||= [];
|
57 | |
for my $subdir (@_) {
|
58 | |
push @$subdirs, $subdir;
|
59 | |
}
|
|
55 |
my $self = shift;
|
|
56 |
my $subdirs = $self->makemaker_args->{DIR} ||= [];
|
|
57 |
for my $subdir (@_) {
|
|
58 |
push @$subdirs, $subdir;
|
|
59 |
}
|
60 | 60 |
}
|
61 | 61 |
|
62 | 62 |
sub clean_files {
|
63 | |
my $self = shift;
|
64 | |
my $clean = $self->makemaker_args->{clean} ||= {};
|
65 | |
%$clean = (
|
66 | |
%$clean,
|
67 | |
FILES => join(' ', grep length, $clean->{FILES}, @_),
|
68 | |
);
|
|
63 |
my $self = shift;
|
|
64 |
my $clean = $self->makemaker_args->{clean} ||= {};
|
|
65 |
%$clean = (
|
|
66 |
%$clean,
|
|
67 |
FILES => join(' ', grep length, $clean->{FILES}, @_),
|
|
68 |
);
|
69 | 69 |
}
|
70 | 70 |
|
71 | 71 |
sub realclean_files {
|
72 | |
my $self = shift;
|
73 | |
my $realclean = $self->makemaker_args->{realclean} ||= {};
|
74 | |
%$realclean = (
|
75 | |
%$realclean,
|
76 | |
FILES => join(' ', grep length, $realclean->{FILES}, @_),
|
77 | |
);
|
|
72 |
my $self = shift;
|
|
73 |
my $realclean = $self->makemaker_args->{realclean} ||= {};
|
|
74 |
%$realclean = (
|
|
75 |
%$realclean,
|
|
76 |
FILES => join(' ', grep length, $realclean->{FILES}, @_),
|
|
77 |
);
|
78 | 78 |
}
|
79 | 79 |
|
80 | 80 |
sub libs {
|
81 | |
my $self = shift;
|
82 | |
my $libs = ref $_[0] ? shift : [ shift ];
|
83 | |
$self->makemaker_args( LIBS => $libs );
|
|
81 |
my $self = shift;
|
|
82 |
my $libs = ref $_[0] ? shift : [ shift ];
|
|
83 |
$self->makemaker_args( LIBS => $libs );
|
84 | 84 |
}
|
85 | 85 |
|
86 | 86 |
sub inc {
|
87 | |
my $self = shift;
|
88 | |
$self->makemaker_args( INC => shift );
|
|
87 |
my $self = shift;
|
|
88 |
$self->makemaker_args( INC => shift );
|
|
89 |
}
|
|
90 |
|
|
91 |
my %test_dir = ();
|
|
92 |
|
|
93 |
sub _wanted_t {
|
|
94 |
/\.t$/ and -f $_ and $test_dir{$File::Find::dir} = 1;
|
|
95 |
}
|
|
96 |
|
|
97 |
sub tests_recursive {
|
|
98 |
my $self = shift;
|
|
99 |
if ( $self->tests ) {
|
|
100 |
die "tests_recursive will not work if tests are already defined";
|
|
101 |
}
|
|
102 |
my $dir = shift || 't';
|
|
103 |
unless ( -d $dir ) {
|
|
104 |
die "tests_recursive dir '$dir' does not exist";
|
|
105 |
}
|
|
106 |
require File::Find;
|
|
107 |
%test_dir = ();
|
|
108 |
File::Find::find( \&_wanted_t, $dir );
|
|
109 |
$self->tests( join ' ', map { "$_/*.t" } sort keys %test_dir );
|
89 | 110 |
}
|
90 | 111 |
|
91 | 112 |
sub write {
|
92 | |
my $self = shift;
|
93 | |
die "&Makefile->write() takes no arguments\n" if @_;
|
94 | |
|
95 | |
my $args = $self->makemaker_args;
|
96 | |
$args->{DISTNAME} = $self->name;
|
97 | |
$args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
|
98 | |
$args->{VERSION} = $self->version || $self->determine_VERSION($args);
|
99 | |
$args->{NAME} =~ s/-/::/g;
|
100 | |
if ( $self->tests ) {
|
101 | |
$args->{test} = { TESTS => $self->tests };
|
102 | |
}
|
103 | |
if ($] >= 5.005) {
|
104 | |
$args->{ABSTRACT} = $self->abstract;
|
105 | |
$args->{AUTHOR} = $self->author;
|
106 | |
}
|
107 | |
if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
|
108 | |
$args->{NO_META} = 1;
|
109 | |
}
|
110 | |
if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 and $self->sign ) {
|
111 | |
$args->{SIGN} = 1;
|
112 | |
}
|
113 | |
unless ( $self->is_admin ) {
|
114 | |
delete $args->{SIGN};
|
115 | |
}
|
116 | |
|
117 | |
# merge both kinds of requires into prereq_pm
|
118 | |
my $prereq = ($args->{PREREQ_PM} ||= {});
|
119 | |
%$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_,
|
120 | |
($self->build_requires, $self->requires) );
|
121 | |
|
122 | |
# merge both kinds of requires into prereq_pm
|
123 | |
my $subdirs = ($args->{DIR} ||= []);
|
124 | |
if ($self->bundles) {
|
125 | |
foreach my $bundle (@{ $self->bundles }) {
|
126 | |
my ($file, $dir) = @$bundle;
|
127 | |
push @$subdirs, $dir if -d $dir;
|
128 | |
delete $prereq->{$file};
|
129 | |
}
|
130 | |
}
|
131 | |
|
132 | |
if ( my $perl_version = $self->perl_version ) {
|
133 | |
eval "use $perl_version; 1"
|
134 | |
or die "ERROR: perl: Version $] is installed, "
|
135 | |
. "but we need version >= $perl_version";
|
136 | |
}
|
137 | |
|
138 | |
my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args;
|
139 | |
if ($self->admin->preop) {
|
140 | |
$args{dist} = $self->admin->preop;
|
141 | |
}
|
142 | |
|
143 | |
my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
|
144 | |
$self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile');
|
|
113 |
my $self = shift;
|
|
114 |
die "&Makefile->write() takes no arguments\n" if @_;
|
|
115 |
|
|
116 |
my $args = $self->makemaker_args;
|
|
117 |
$args->{DISTNAME} = $self->name;
|
|
118 |
$args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
|
|
119 |
$args->{VERSION} = $self->version || $self->determine_VERSION($args);
|
|
120 |
$args->{NAME} =~ s/-/::/g;
|
|
121 |
if ( $self->tests ) {
|
|
122 |
$args->{test} = { TESTS => $self->tests };
|
|
123 |
}
|
|
124 |
if ($] >= 5.005) {
|
|
125 |
$args->{ABSTRACT} = $self->abstract;
|
|
126 |
$args->{AUTHOR} = $self->author;
|
|
127 |
}
|
|
128 |
if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
|
|
129 |
$args->{NO_META} = 1;
|
|
130 |
}
|
|
131 |
if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 and $self->sign ) {
|
|
132 |
$args->{SIGN} = 1;
|
|
133 |
}
|
|
134 |
unless ( $self->is_admin ) {
|
|
135 |
delete $args->{SIGN};
|
|
136 |
}
|
|
137 |
|
|
138 |
# merge both kinds of requires into prereq_pm
|
|
139 |
my $prereq = ($args->{PREREQ_PM} ||= {});
|
|
140 |
%$prereq = ( %$prereq,
|
|
141 |
map { @$_ }
|
|
142 |
map { @$_ }
|
|
143 |
grep $_,
|
|
144 |
($self->build_requires, $self->requires)
|
|
145 |
);
|
|
146 |
|
|
147 |
# merge both kinds of requires into prereq_pm
|
|
148 |
my $subdirs = ($args->{DIR} ||= []);
|
|
149 |
if ($self->bundles) {
|
|
150 |
foreach my $bundle (@{ $self->bundles }) {
|
|
151 |
my ($file, $dir) = @$bundle;
|
|
152 |
push @$subdirs, $dir if -d $dir;
|
|
153 |
delete $prereq->{$file};
|
|
154 |
}
|
|
155 |
}
|
|
156 |
|
|
157 |
if ( my $perl_version = $self->perl_version ) {
|
|
158 |
eval "use $perl_version; 1"
|
|
159 |
or die "ERROR: perl: Version $] is installed, "
|
|
160 |
. "but we need version >= $perl_version";
|
|
161 |
}
|
|
162 |
|
|
163 |
$args->{INSTALLDIRS} = $self->installdirs;
|
|
164 |
|
|
165 |
my %args = map { ( $_ => $args->{$_} ) } grep {defined($args->{$_})} keys %$args;
|
|
166 |
|
|
167 |
my $user_preop = delete $args{dist}->{PREOP};
|
|
168 |
if (my $preop = $self->admin->preop($user_preop)) {
|
|
169 |
$args{dist} = $preop;
|
|
170 |
}
|
|
171 |
|
|
172 |
my $mm = ExtUtils::MakeMaker::WriteMakefile(%args);
|
|
173 |
$self->fix_up_makefile($mm->{FIRST_MAKEFILE} || 'Makefile');
|
145 | 174 |
}
|
146 | 175 |
|
147 | 176 |
sub fix_up_makefile {
|
148 | |
my $self = shift;
|
149 | |
my $makefile_name = shift;
|
150 | |
my $top_class = ref($self->_top) || '';
|
151 | |
my $top_version = $self->_top->VERSION || '';
|
152 | |
|
153 | |
my $preamble = $self->preamble
|
154 | |
? "# Preamble by $top_class $top_version\n"
|
155 | |
. $self->preamble
|
156 | |
: '';
|
157 | |
my $postamble = "# Postamble by $top_class $top_version\n"
|
158 | |
. ($self->postamble || '');
|
159 | |
|
160 | |
local *MAKEFILE;
|
161 | |
open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
|
162 | |
my $makefile = do { local $/; <MAKEFILE> };
|
163 | |
close MAKEFILE or die $!;
|
164 | |
|
165 | |
$makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
|
166 | |
$makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
|
167 | |
$makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
|
168 | |
$makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
|
169 | |
$makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
|
170 | |
|
171 | |
# Module::Install will never be used to build the Core Perl
|
172 | |
# Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
|
173 | |
# PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
|
174 | |
$makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
|
175 | |
#$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
|
176 | |
|
177 | |
# Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well.
|
178 | |
$makefile =~ s/("?)-I\$\(PERL_LIB\)\1//g;
|
179 | |
|
180 | |
# XXX - This is currently unused; not sure if it breaks other MM-users
|
181 | |
# $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
|
182 | |
|
183 | |
open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
|
184 | |
print MAKEFILE "$preamble$makefile$postamble" or die $!;
|
185 | |
close MAKEFILE or die $!;
|
186 | |
|
187 | |
1;
|
|
177 |
my $self = shift;
|
|
178 |
my $makefile_name = shift;
|
|
179 |
my $top_class = ref($self->_top) || '';
|
|
180 |
my $top_version = $self->_top->VERSION || '';
|
|
181 |
|
|
182 |
my $preamble = $self->preamble
|
|
183 |
? "# Preamble by $top_class $top_version\n"
|
|
184 |
. $self->preamble
|
|
185 |
: '';
|
|
186 |
my $postamble = "# Postamble by $top_class $top_version\n"
|
|
187 |
. ($self->postamble || '');
|
|
188 |
|
|
189 |
local *MAKEFILE;
|
|
190 |
open MAKEFILE, "< $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
|
|
191 |
my $makefile = do { local $/; <MAKEFILE> };
|
|
192 |
close MAKEFILE or die $!;
|
|
193 |
|
|
194 |
$makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
|
|
195 |
$makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
|
|
196 |
$makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
|
|
197 |
$makefile =~ s/^(FULLPERL = .*)/$1 "-Iinc"/m;
|
|
198 |
$makefile =~ s/^(PERL = .*)/$1 "-Iinc"/m;
|
|
199 |
|
|
200 |
# Module::Install will never be used to build the Core Perl
|
|
201 |
# Sometimes PERL_LIB and PERL_ARCHLIB get written anyway, which breaks
|
|
202 |
# PREFIX/PERL5LIB, and thus, install_share. Blank them if they exist
|
|
203 |
$makefile =~ s/^PERL_LIB = .+/PERL_LIB =/m;
|
|
204 |
#$makefile =~ s/^PERL_ARCHLIB = .+/PERL_ARCHLIB =/m;
|
|
205 |
|
|
206 |
# Perl 5.005 mentions PERL_LIB explicitly, so we have to remove that as well.
|
|
207 |
$makefile =~ s/("?)-I\$\(PERL_LIB\)\1//g;
|
|
208 |
|
|
209 |
# XXX - This is currently unused; not sure if it breaks other MM-users
|
|
210 |
# $makefile =~ s/^pm_to_blib\s+:\s+/pm_to_blib :: /mg;
|
|
211 |
|
|
212 |
open MAKEFILE, "> $makefile_name" or die "fix_up_makefile: Couldn't open $makefile_name: $!";
|
|
213 |
print MAKEFILE "$preamble$makefile$postamble" or die $!;
|
|
214 |
close MAKEFILE or die $!;
|
|
215 |
|
|
216 |
1;
|
188 | 217 |
}
|
189 | 218 |
|
190 | 219 |
sub preamble {
|
191 | |
my ($self, $text) = @_;
|
192 | |
$self->{preamble} = $text . $self->{preamble} if defined $text;
|
193 | |
$self->{preamble};
|
|
220 |
my ($self, $text) = @_;
|
|
221 |
$self->{preamble} = $text . $self->{preamble} if defined $text;
|
|
222 |
$self->{preamble};
|
194 | 223 |
}
|
195 | 224 |
|
196 | 225 |
sub postamble {
|
197 | |
my ($self, $text) = @_;
|
198 | |
$self->{postamble} ||= $self->admin->postamble;
|
199 | |
$self->{postamble} .= $text if defined $text;
|
200 | |
$self->{postamble}
|
|
226 |
my ($self, $text) = @_;
|
|
227 |
$self->{postamble} ||= $self->admin->postamble;
|
|
228 |
$self->{postamble} .= $text if defined $text;
|
|
229 |
$self->{postamble}
|
201 | 230 |
}
|
202 | 231 |
|
203 | 232 |
1;
|
204 | 233 |
|
205 | 234 |
__END__
|
206 | 235 |
|
207 | |
#line 334
|
|
236 |
#line 363
|