lib/ExtUtils/MM_Any.pm

filter: Statementstmt 81.8% 643 / 786 Branchbran 65.3% 230 / 352 Conditioncond 44.8% 144 / 321 MC/DCmcdc 15.1% 28 / 185 Subroutinesub 83.8% 83 / 99 Podpod 94.4% 68 / 72 totaltotal 65.9% 1196 / 1815 CC 323 SCAR 36.9
CC
323
Cov
70%
xs_dlsyms_iterator
156.0
init_tools
147.8
init_INSTALL_from_PREFIX
117.0
CRAP 40.1
« lib/ExtUtils/Command/MM.pm ↑ Summary lib/ExtUtils/MM_Cygwin.pm »
1 package ExtUtils::MM_Any;
2  
3 50 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 50 our $VERSION = '7.13_01';
5 50 $VERSION = eval $VERSION;
6  
7 50 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 50 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 50 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 50 ▶BEGIN { our @ISA = qw(File::Spec); }
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 # We need $Verbose
13 50 ▶use ExtUtils::MakeMaker qw($Verbose neatvalue _sprintf562);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 50 ▶use ExtUtils::MakeMaker::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17  
18 # So we don't have to keep calling the methods over and over again,
19 # we have these globals to cache the values. Faster and shrtr.
20 50 my $Curdir = __PACKAGE__->curdir;
21 #my $Updir = __PACKAGE__->updir;
22  
23 50 my $METASPEC_URL = 'https://metacpan.org/pod/CPAN::Meta::Spec';
24 50 my $METASPEC_V = 2;
25  
26 =head1 NAME
27  
28 ExtUtils::MM_Any - Platform-agnostic MM methods
29  
30 =head1 SYNOPSIS
31  
32 FOR INTERNAL USE ONLY!
33  
34 package ExtUtils::MM_SomeOS;
35  
36 # Temporarily, you have to subclass both. Put MM_Any first.
37 require ExtUtils::MM_Any;
38 require ExtUtils::MM_Unix;
39 @ISA = qw(ExtUtils::MM_Any ExtUtils::Unix);
40  
41 =head1 DESCRIPTION
42  
43 B<FOR INTERNAL USE ONLY!>
44  
45 ExtUtils::MM_Any is a superclass for the ExtUtils::MM_* set of
46 modules. It contains methods which are either inherently
47 cross-platform or are written in a cross-platform manner.
48  
49 Subclass off of ExtUtils::MM_Any I<and> ExtUtils::MM_Unix. This is a
50 temporary solution.
51  
52 B<THIS MAY BE TEMPORARY!>
53  
54  
55 =head1 METHODS
56  
57 Any methods marked I<Abstract> must be implemented by subclasses.
58  
59  
60 =head2 Cross-platform helper methods
61  
62 These are methods which help writing cross-platform code.
63  
64  
65  
66 =head3 os_flavor I<Abstract>
67  
68 my @os_flavor = $mm->os_flavor;
69  
70 @os_flavor is the style of operating system this is, usually
71 corresponding to the MM_*.pm file we're using.
72  
73 The first element of @os_flavor is the major family (ie. Unix,
74 Windows, VMS, OS/2, etc...) and the rest are sub families.
75  
76 Some examples:
77  
78 Cygwin98 ('Unix', 'Cygwin', 'Cygwin9x')
79 Windows ('Win32')
80 Win98 ('Win32', 'Win9x')
81 Linux ('Unix', 'Linux')
82 MacOS X ('Unix', 'Darwin', 'MacOS', 'MacOS X')
83 OS/2 ('OS/2')
84  
85 This is used to write code for styles of operating system.
86 See os_flavor_is() for use.
87  
88  
89 =head3 os_flavor_is
90  
91 my $is_this_flavor = $mm->os_flavor_is($this_flavor);
92 my $is_this_flavor = $mm->os_flavor_is(@one_of_these_flavors);
93  
94 Checks to see if the current operating system is one of the given flavors.
95  
96 This is useful for code like:
97  
98 if( $mm->os_flavor_is('Unix') ) {
99 $out = `foo 2>&1`;
100 }
101 else {
102 $out = `foo`;
103 }
104  
105 =cut
106  
107 sub os_flavor_is {
108 211 ▶ my $self = shift;
Subroutine os_flavor_is: called CC=2 SCAR=6.9
Pod documented
109 211 my %flavors = map { ($_ => 1) } $self->os_flavor;
110 211 ▶ return (grep { $flavors{$_} } @_) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
grep({$flavors{$_};} @_) ? : 119 92 211
111 }
112  
113  
114 =head3 can_load_xs
115  
116 my $can_load_xs = $self->can_load_xs;
117  
118 Returns true if we have the ability to load XS.
119  
120 This is important because miniperl, used to build XS modules in the
121 core, can not load XS.
122  
123 =cut
124  
125 sub can_load_xs {
126 0 ▶ return defined &DynaLoader::boot_DynaLoader ? 1 : 0;
Subroutine can_load_xs: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined &DynaLoader::boot_DynaLoader ? : 0 0 0
127 }
128  
129  
130 =head3 can_run
131  
132 use ExtUtils::MM;
133 my $runnable = MM->can_run($Config{make});
134  
135 If called in a scalar context it will return the full path to the binary
136 you asked for if it was found, or C<undef> if it was not.
137  
138 If called in a list context, it will return a list of the full paths to instances
139 of the binary where found in C<PATH>, or an empty list if it was not found.
140  
141 Copied from L<IPC::Cmd|IPC::Cmd/"$path = can_run( PROGRAM );">, but modified into
142 a method (and removed C<$INSTANCES> capability).
143  
144 =cut
145  
146 sub can_run {
147 9 ▶ my ($self, $command) = @_;
Subroutine can_run: called CC=10 SCAR=29.6
Pod documented
148  
149 # a lot of VMS executables have a symbol defined
150 # check those first
151 9 ▶ if ( $^O eq 'VMS' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "VMS") 0 9 9
152 0 require VMS::DCLsym;
153 0 my $syms = VMS::DCLsym->new;
154 0 ▶ return $command if scalar $syms->getsym( uc $command );
Branch: 1 branch
BranchTrueFalseTotal
if scalar $syms->getsym(uc $command) 0 0 0
155 }
156  
157 9 my @possibles;
158  
159 9 ▶ if( File::Spec->file_name_is_absolute($command) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('File::Spec'->file_name_is_absolute($command)) { } 0 9 9
160 0 return $self->maybe_command($command);
161  
162 } else {
163 9 for my $dir (
164 File::Spec->path,
165 File::Spec->curdir
166 ) {
167 90 ▶ next if ! $dir || ! -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless $dir and -d $dir 0 90 90
Condition33%1/3
$dir and -d $dir
!ll&&!rl&&r
0090
MC/DC0%0/2
$dir and -d $dir
$dir -d $dir
Truth table33%1/3
A and B
A= $dirB= -d $dir
ABresult
0X0
100
111
168 90 ▶ my $abs = File::Spec->catfile($self->os_flavor_is('Win32') ? Win32::GetShortPathName( $dir ) : $dir, $command);
Branch: 1 branch
BranchTrueFalseTotal
$self->os_flavor_is('Win32') ? : 0 90 90
169 90 ▶ push @possibles, $abs if $abs = $self->maybe_command($abs);
Branch: 1 branch
BranchTrueFalseTotal
if $abs = $self->maybe_command($abs) 0 90 90
170 }
171 }
172 9 ▶ return @possibles if wantarray;
Branch: 1 branch
BranchTrueFalseTotal
if wantarray 0 9 9
173 9 return shift @possibles;
174 }
175  
176  
177 =head3 can_redirect_error
178  
179 $useredirect = MM->can_redirect_error;
180  
181 True if on an OS where qx operator (or backticks) can redirect C<STDERR>
182 onto C<STDOUT>.
183  
184 =cut
185  
186 sub can_redirect_error {
187 117 ▶ my $self = shift;
Subroutine can_redirect_error: called CC=4 SCAR=20.1
Pod documented
188 117 ▶ $self->os_flavor_is('Unix')
Branch: 1 branch
BranchTrueFalseTotal
$self->os_flavor_is("Unix") or $self->os_flavor_is("Win32") and not $self->os_flavor_is("Win9x") or $self->os_flavor_is("OS/2") 0 117 117
Condition16%1/6
$self->os_flavor_is("Unix") or $self->os_flavor_is("Win32") and not $self->os_flavor_is("Win9x")
l!l&&r!l&&!r
11700
$self->os_flavor_is("Win32") and not $self->os_flavor_is("Win9x")
!ll&&!rl&&r
000
MC/DC0%0/3
$self->os_flavor_is("Unix") or $self->os_flavor_is("Win32") and not $self->os_flavor_is("Win9x")
$self->os_flavor_is("Unix") $self->os_flavor_is("Win32") not $self->os_flavor_is("Win9x")
Truth table25%1/4
A or B and not(C)
A= $self->os_flavor_is("Unix")B= $self->os_flavor_is("Win32")C= not $self->os_flavor_is("Win9x")
ABCresult
1XX1
0111
00X0
0100
189 or ($self->os_flavor_is('Win32') and !$self->os_flavor_is('Win9x'))
190 or $self->os_flavor_is('OS/2')
191 }
192  
193  
194 =head3 is_make_type
195  
196 my $is_dmake = $self->is_make_type('dmake');
197  
198 Returns true if C<<$self->make>> is the given type; possibilities are:
199  
200 gmake GNU make
201 dmake
202 nmake
203 bsdmake BSD pmake-derived
204  
205 =cut
206  
207 50 my %maketype2true;
208 # undocumented - so t/cd.t can still do its thing
209 2 ▶sub _clear_maketype_cache { %maketype2true = () }
Subroutine _clear_maketype_cache: called CC=1 SCAR=0.0
210  
211 sub is_make_type {
212 121 ▶ my($self, $type) = @_;
Subroutine is_make_type: called CC=10 SCAR=24.0
Pod documented
213 121 ▶ return $maketype2true{$type} if defined $maketype2true{$type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $maketype2true{$type} 102 19 121
214 19 (undef, undef, my $make_basename) = $self->splitpath($self->make);
215 19 ▶ return $maketype2true{$type} = 1
Branch: 1 branch
BranchTrueFalseTotal
if $make_basename =~ /\b$type\b/i 1 18 19
216 if $make_basename =~ /\b$type\b/i; # executable's filename
217 18 ▶ return $maketype2true{$type} = 0
Branch: 1 branch
BranchTrueFalseTotal
if $make_basename =~ /\b[gdn]make\b/i 1 17 18
218 if $make_basename =~ /\b[gdn]make\b/i; # Never fall through for dmake/nmake/gmake
219 # now have to run with "-v" and guess
220 17 ▶ my $redirect = $self->can_redirect_error ? '2>&1' : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->can_redirect_error ? : 17 0 17
221 17 ▶ my $make = $self->make || $self->{MAKE};
Condition33%1/3
$self->make || $self->{'MAKE'}
l!l&&r!l&&!r
1700
MC/DC0%0/2
$self->make || $self->{'MAKE'}
$self->make $self->{'MAKE'}
Truth table33%1/3
A || B
A= $self->makeB= $self->{'MAKE'}
ABresult
1X1
011
000
222 17 my $minus_v = `"$make" -v $redirect`;
223 17 ▶ return $maketype2true{$type} = 1
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "gmake" and $minus_v =~ /GNU make/i 2 15 17
Condition66%2/3
$type eq "gmake" and $minus_v =~ /GNU make/i
!ll&&!rl&&r
1502
MC/DC50%1/2
$type eq "gmake" and $minus_v =~ /GNU make/i
$type eq "gmake" $minus_v =~ /GNU make/i
Truth table66%2/3
A and B
A= $type eq "gmake"B= $minus_v =~ /GNU make/i
ABresult
0X0
100
111
224 if $type eq 'gmake' and $minus_v =~ /GNU make/i;
225 15 ▶ return $maketype2true{$type} = 1
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "bsdmake" and $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im 0 15 15
Condition33%1/3
$type eq "bsdmake" and $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im
!ll&&!rl&&r
1500
MC/DC0%0/2
$type eq "bsdmake" and $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im
$type eq "bsdmake" $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im
Truth table33%1/3
A and B
A= $type eq "bsdmake"B= $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im
ABresult
0X0
100
111
226 if $type eq 'bsdmake'
227 and $minus_v =~ /^usage: make \[-BeikNnqrstWwX\]/im;
228 15 $maketype2true{$type} = 0; # it wasn't whatever you asked
229 }
230  
231  
232 =head3 can_dep_space
233  
234 my $can_dep_space = $self->can_dep_space;
235  
236 Returns true if C<make> can handle (probably by quoting)
237 dependencies that contain a space. Currently known true for GNU make,
238 false for BSD pmake derivative.
239  
240 =cut
241  
242 my $cached_dep_space;
243 sub can_dep_space {
244 2 ▶ my $self = shift;
Subroutine can_dep_space: called CC=5 SCAR=24.5
Pod documented
245 2 ▶ return $cached_dep_space if defined $cached_dep_space;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cached_dep_space 0 2 2
246 2 ▶ return $cached_dep_space = 1 if $self->is_make_type('gmake');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_make_type("gmake") 2 0 2
247 0 ▶ return $cached_dep_space = 0 if $self->is_make_type('dmake'); # only on W32
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_make_type("dmake") 0 0 0
248 0 ▶ return $cached_dep_space = 0 if $self->is_make_type('bsdmake');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_make_type("bsdmake") 0 0 0
249 0 return $cached_dep_space = 0; # assume no
250 }
251  
252  
253 =head3 quote_dep
254  
255 $text = $mm->quote_dep($text);
256  
257 Method that protects Makefile single-value constants (mainly filenames),
258 so that make will still treat them as single values even if they
259 inconveniently have spaces in. If the make program being used cannot
260 achieve such protection and the given text would need it, throws an
261 exception.
262  
263 =cut
264  
265 sub quote_dep {
266 327 ▶ my ($self, $arg) = @_;
Subroutine quote_dep: called CC=3 SCAR=12.0
Pod documented
267 327 ▶ die <<EOF if $arg =~ / / and not $self->can_dep_space;
Branch: 1 branch
BranchTrueFalseTotal
if $arg =~ / / and not $self->can_dep_space 0 327 327
Condition33%1/3
$arg =~ / / and not $self->can_dep_space
!ll&&!rl&&r
32700
MC/DC0%0/2
$arg =~ / / and not $self->can_dep_space
$arg =~ / / not $self->can_dep_space
Truth table33%1/3
A and not(B)
A= $arg =~ / /B= not $self->can_dep_space
ABresult
0X0
100
111
268 Tried to use make dependency with space for make that can't:
269 '$arg'
270 EOF
271 327 $arg =~ s/( )/\\$1/g; # how GNU make does it
272 327 return $arg;
273 }
274  
275  
276 =head3 split_command
277  
278 my @cmds = $MM->split_command($cmd, @args);
279  
280 Most OS have a maximum command length they can execute at once. Large
281 modules can easily generate commands well past that limit. Its
282 necessary to split long commands up into a series of shorter commands.
283  
284 C<split_command> will return a series of @cmds each processing part of
285 the args. Collectively they will process all the arguments. Each
286 individual line in @cmds will not be longer than the
287 $self->max_exec_len being careful to take into account macro expansion.
288  
289 $cmd should include any switches and repeated initial arguments.
290  
291 If no @args are given, no @cmds will be returned.
292  
293 Pairs of arguments will always be preserved in a single command, this
294 is a heuristic for things like pm_to_blib and pod2man which work on
295 pairs of arguments. This makes things like this safe:
296  
297 $self->split_command($cmd, %pod2man);
298  
299  
300 =cut
301  
302 sub split_command {
303 823 ▶ my($self, $cmd, @args) = @_;
Subroutine split_command: called CC=6 SCAR=17.9
Pod documented
304  
305 823 my @cmds = ();
306 823 ▶ return(@cmds) unless @args;
Branch: 1 branch
BranchTrueFalseTotal
unless @args 257 566 823
307  
308 # If the command was given as a here-doc, there's probably a trailing
309 # newline.
310 566 chomp $cmd;
311  
312 # set aside 30% for macro expansion.
313 566 my $len_left = int($self->max_exec_len * 0.70);
314 566 $len_left -= length $self->_expand_macros($cmd);
315  
316 566 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
@args and do { do { my $arg_str = ""; my @next_args; while (@next_args = splice(@args, 0, 2)) { my $next_arg_str = "\t " . join(" ", @next_args, "\n"); if (not length $arg_str) { $arg_str .= $next_arg_str; } elsif (length($arg_str) + length($next_arg_str) > $len_left) { unshift @args, @next_args; last; } else { $arg_str .= $next_arg_str; } ; } ; chop $arg_str; push @cmds, $self->escape_newlines("$cmd \n$arg_str") } } 5 566 571
317 571 my $arg_str = '';
318 571 my @next_args;
319 571 ▶ while( @next_args = splice(@args, 0, 2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@next_args = splice(@args, 0, 2)) 2335 566 2901
320 # Two at a time to preserve pairs.
321 2335 my $next_arg_str = "\t ". join ' ', @next_args, "\n";
322  
323 2335 ▶ if( !length $arg_str ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not length $arg_str) { } 571 1764 2335
elsif (length($arg_str) + length($next_arg_str) > $len_left) { } 5 1759 1764
324 571 $arg_str .= $next_arg_str
325 }
326 elsif( length($arg_str) + length($next_arg_str) > $len_left ) {
327 5 unshift @args, @next_args;
328 5 last;
329 }
330 else {
331 1759 $arg_str .= $next_arg_str;
332 }
333 }
334 571 chop $arg_str;
335  
336 571 push @cmds, $self->escape_newlines("$cmd \n$arg_str");
337 } while @args;
338  
339 566 return @cmds;
340 }
341  
342  
343 sub _expand_macros {
344 566 ▶ my($self, $cmd) = @_;
Subroutine _expand_macros: called CC=2 SCAR=6.9
345  
346 566 $cmd =~ s{\$\((\w+)\)}{
347 566 ▶ defined $self->{$1} ? $self->{$1} : "\$($1)"
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{$1} ? : 564 2 566
348 }e;
349 566 return $cmd;
350 }
351  
352  
353 =head3 make_type
354  
355 Returns a suitable string describing the type of makefile being written.
356  
357 =cut
358  
359 # override if this isn't suitable!
360 74 ▶sub make_type { return 'Unix-style'; }
Subroutine make_type: called CC=1 SCAR=0.0
Pod documented
361  
362  
363 =head3 stashmeta
364  
365 my @recipelines = $MM->stashmeta($text, $file);
366  
367 Generates a set of C<@recipelines> which will result in the literal
368 C<$text> ending up in literal C<$file> when the recipe is executed. Call
369 it once, with all the text you want in C<$file>. Make macros will not
370 be expanded, so the locations will be fixed at configure-time, not
371 at build-time.
372  
373 =cut
374  
375 sub stashmeta {
376 313 ▶ my($self, $text, $file) = @_;
Subroutine stashmeta: called CC=1 SCAR=0.0
Pod documented
377 313 $self->echo($text, $file, { allow_variables => 0, append => 0 });
378 }
379  
380  
381 =head3 echo
382  
383 my @commands = $MM->echo($text);
384 my @commands = $MM->echo($text, $file);
385 my @commands = $MM->echo($text, $file, \%opts);
386  
387 Generates a set of @commands which print the $text to a $file.
388  
389 If $file is not given, output goes to STDOUT.
390  
391 If $opts{append} is true the $file will be appended to rather than
392 overwritten. Default is to overwrite.
393  
394 If $opts{allow_variables} is true, make variables of the form
395 C<$(...)> will not be escaped. Other C<$> will. Default is to escape
396 all C<$>.
397  
398 Example of use:
399  
400 my $make = join '', map "\t$_\n", $MM->echo($text, $file);
401  
402 =cut
403  
404 sub echo {
405 321 ▶ my($self, $text, $file, $opts) = @_;
Subroutine echo: called CC=7 SCAR=19.5
Pod documented
406  
407 # Compatibility with old options
408 321 ▶ if( !ref $opts ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $opts) 6 315 321
409 6 my $append = $opts;
410 6 ▶ $opts = { append => $append || 0 };
Condition100%2/2
$append || 0
l!l
15
MC/DC100%1/1
$append || 0
$append
Truth table100%2/2
A
A= $append
Aresult
11
00
411 }
412 321 ▶ $opts->{allow_variables} = 0 unless defined $opts->{allow_variables};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"allow_variables"} 7 314 321
413  
414 321 my $ql_opts = { allow_variables => $opts->{allow_variables} };
415 321 my @cmds = map { '$(NOECHO) $(ECHO) '.$self->quote_literal($_, $ql_opts) }
416 split /\n/, $text;
417 321 ▶ if( $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) 321 0 321
418 321 ▶ my $redirect = $opts->{append} ? '>>' : '>';
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'append'} ? : 2 319 321
419 321 $cmds[0] .= " $redirect $file";
420 321 $_ .= " >> $file" foreach @cmds[1..$#cmds];
421 }
422  
423 321 return @cmds;
424 }
425  
426  
427 =head3 wraplist
428  
429 my $args = $mm->wraplist(@list);
430  
431 Takes an array of items and turns them into a well-formatted list of
432 arguments. In most cases this is simply something like:
433  
434 FOO \
435 BAR \
436 BAZ
437  
438 =cut
439  
440 sub wraplist {
441 824 ▶ my $self = shift;
Subroutine wraplist: called CC=1 SCAR=0.0
Pod documented
442 824 return join " \\\n\t", @_;
443 }
444  
445  
446 =head3 maketext_filter
447  
448 my $filter_make_text = $mm->maketext_filter($make_text);
449  
450 The text of the Makefile is run through this method before writing to
451 disk. It allows systems a chance to make portability fixes to the
452 Makefile.
453  
454 By default it does nothing.
455  
456 This method is protected and not intended to be called outside of
457 MakeMaker.
458  
459 =cut
460  
461 6277 ▶sub maketext_filter { return $_[1] }
Subroutine maketext_filter: called CC=1 SCAR=0.0
Pod documented
462  
463  
464 =head3 cd I<Abstract>
465  
466 my $subdir_cmd = $MM->cd($subdir, @cmds);
467  
468 This will generate a make fragment which runs the @cmds in the given
469 $dir. The rough equivalent to this, except cross platform.
470  
471 cd $subdir && $cmd
472  
473 Currently $dir can only go down one level. "foo" is fine. "foo/bar" is
474 not. "../foo" is right out.
475  
476 The resulting $subdir_cmd has no leading tab nor trailing newline. This
477 makes it easier to embed in a make string. For example.
478  
479 my $make = sprintf <<'CODE', $subdir_cmd;
480 foo :
481 $(ECHO) what
482 %s
483 $(ECHO) mouche
484 CODE
485  
486  
487 =head3 oneliner I<Abstract>
488  
489 my $oneliner = $MM->oneliner($perl_code);
490 my $oneliner = $MM->oneliner($perl_code, \@switches);
491  
492 This will generate a perl one-liner safe for the particular platform
493 you're on based on the given $perl_code and @switches (a -e is
494 assumed) suitable for using in a make target. It will use the proper
495 shell quoting and escapes.
496  
497 $(PERLRUN) will be used as perl.
498  
499 Any newlines in $perl_code will be escaped. Leading and trailing
500 newlines will be stripped. Makes this idiom much easier:
501  
502 my $code = $MM->oneliner(<<'CODE', [...switches...]);
503 some code here
504 another line here
505 CODE
506  
507 Usage might be something like:
508  
509 # an echo emulation
510 $oneliner = $MM->oneliner('print "Foo\n"');
511 $make = '$oneliner > somefile';
512  
513 Dollar signs in the $perl_code will be protected from make using the
514 C<quote_literal> method, unless they are recognised as being a make
515 variable, C<$(varname)>, in which case they will be left for make
516 to expand. Remember to quote make macros else it might be used as a
517 bareword. For example:
518  
519 # Assign the value of the $(VERSION_FROM) make macro to $vf.
520 $oneliner = $MM->oneliner('$vf = "$(VERSION_FROM)"');
521  
522 Its currently very simple and may be expanded sometime in the figure
523 to include more flexible code and switches.
524  
525  
526 =head3 quote_literal I<Abstract>
527  
528 my $safe_text = $MM->quote_literal($text);
529 my $safe_text = $MM->quote_literal($text, \%options);
530  
531 This will quote $text so it is interpreted literally in the shell.
532  
533 For example, on Unix this would escape any single-quotes in $text and
534 put single-quotes around the whole thing.
535  
536 If $options{allow_variables} is true it will leave C<'$(FOO)'> make
537 variables untouched. If false they will be escaped like any other
538 C<$>. Defaults to true.
539  
540 =head3 escape_dollarsigns
541  
542 my $escaped_text = $MM->escape_dollarsigns($text);
543  
544 Escapes stray C<$> so they are not interpreted as make variables.
545  
546 It lets by C<$(...)>.
547  
548 =cut
549  
550 sub escape_dollarsigns {
551 3219 ▶ my($self, $text) = @_;
Subroutine escape_dollarsigns: called CC=1 SCAR=0.0
Pod documented
552  
553 # Escape dollar signs which are not starting a variable
554 3219 $text =~ s{\$ (?!\() }{\$\$}gx;
555  
556 3219 return $text;
557 }
558  
559  
560 =head3 escape_all_dollarsigns
561  
562 my $escaped_text = $MM->escape_all_dollarsigns($text);
563  
564 Escapes all C<$> so they are not interpreted as make variables.
565  
566 =cut
567  
568 sub escape_all_dollarsigns {
569 6370 ▶ my($self, $text) = @_;
Subroutine escape_all_dollarsigns: called CC=1 SCAR=0.0
Pod documented
570  
571 # Escape dollar signs
572 6370 $text =~ s{\$}{\$\$}gx;
573  
574 6370 return $text;
575 }
576  
577  
578 =head3 escape_newlines I<Abstract>
579  
580 my $escaped_text = $MM->escape_newlines($text);
581  
582 Shell escapes newlines in $text.
583  
584  
585 =head3 max_exec_len I<Abstract>
586  
587 my $max_exec_len = $MM->max_exec_len;
588  
589 Calculates the maximum command size the OS can exec. Effectively,
590 this is the max size of a shell command line.
591  
592 =for _private
593 $self->{_MAX_EXEC_LEN} is set by this method, but only for testing purposes.
594  
595  
596 =head3 make
597  
598 my $make = $MM->make;
599  
600 Returns the make variant we're generating the Makefile for. This attempts
601 to do some normalization on the information from %Config or the user.
602  
603 =cut
604  
605 sub make {
606 37 ▶ my $self = shift;
Subroutine make: called CC=1 SCAR=0.0
Pod documented
607  
608 37 my $make = lc $self->{MAKE};
609  
610 # Truncate anything like foomake6 to just foomake.
611 37 $make =~ s/^(\w+make).*/$1/;
612  
613 # Turn gnumake into gmake.
614 37 $make =~ s/^gnu/g/;
615  
616 37 return $make;
617 }
618  
619  
620 =head2 Targets
621  
622 These are methods which produce make targets.
623  
624  
625 =head3 all_target
626  
627 Generate the default target 'all'.
628  
629 =cut
630  
631 sub all_target {
632 0 ▶ my $self = shift;
Subroutine all_target: not called CC=1 SCAR=6.9
Pod documented
633  
634 0 return <<'MAKE_EXT';
635 all :: pure_all
636 $(NOECHO) $(NOOP)
637 MAKE_EXT
638  
639 }
640  
641  
642 =head3 blibdirs_target
643  
644 my $make_frag = $mm->blibdirs_target;
645  
646 Creates the blibdirs target which creates all the directories we use
647 in blib/.
648  
649 The blibdirs.ts target is deprecated. Depend on blibdirs instead.
650  
651  
652 =cut
653  
654 sub _xs_list_basenames {
655 117 ▶ my ($self) = @_;
Subroutine _xs_list_basenames: called CC=1 SCAR=0.6
656 117 map { (my $b = $_) =~ s/\.xs$//; $b } sort keys %{ $self->{XS} };
657 }
658  
659 sub blibdirs_target {
660 117 ▶ my $self = shift;
Subroutine blibdirs_target: called CC=4 SCAR=16.9
Pod documented
661  
662 117 my @dirs = map { uc "\$(INST_$_)" } qw(libdir archlib
663 autodir archautodir
664 bin script
665 man1dir man3dir
666 );
667 117 ▶ if ($self->{XSMULTI}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"XSMULTI"}) 0 117 117
668 0 for my $ext ($self->_xs_list_basenames) {
669 0 my ($v, $d, $f) = File::Spec->splitpath($ext);
670 0 my @d = File::Spec->splitdir($d);
671 0 ▶ shift @d if $d[0] eq 'lib';
Branch: 1 branch
BranchTrueFalseTotal
if $d[0] eq "lib" 0 0 0
672 0 push @dirs, $self->catdir('$(INST_ARCHLIB)', 'auto', @d, $f);
673 }
674 }
675  
676 117 my @exists = map { $_.'$(DFSEP).exists' } @dirs;
677  
678 117 my $make = sprintf <<'MAKE', join(' ', @exists);
679 blibdirs : %s
680 $(NOECHO) $(NOOP)
681  
682 # Backwards compat with 6.18 through 6.25
683 blibdirs.ts : blibdirs
684 $(NOECHO) $(NOOP)
685  
686 MAKE
687  
688 117 $make .= $self->dir_target(@dirs);
689  
690 117 return $make;
691 }
692  
693  
694 =head3 clean (o)
695  
696 Defines the clean target.
697  
698 =cut
699  
700 sub clean {
701 # --- Cleanup and Distribution Sections ---
702  
703 117 ▶ my($self, %attribs) = @_;
Subroutine clean: called CC=5 SCAR=16.9
Pod documented
704 117 my @m;
705 117 push(@m, '
706 # Delete temporary files but do not touch installed files. We don\'t delete
707 # the Makefile here so a later make realclean still has a makefile to use.
708  
709 clean :: clean_subdirs
710 ');
711  
712 117 my @files = sort values %{$self->{XS}}; # .c files from *.xs files
713 push @files, map {
714 117 my $file = $_;
715 0 map { $file.$_ } $self->{OBJ_EXT}, qw(.def _def.old .bs .bso .exp .base);
716 } $self->_xs_list_basenames;
717 117 my @dirs = qw(blib);
718  
719 # Normally these are all under blib but they might have been
720 # redefined.
721 # XXX normally this would be a good idea, but the Perl core sets
722 # INST_LIB = ../../lib rather than actually installing the files.
723 # So a "make clean" in an ext/ directory would blow away lib.
724 # Until the core is adjusted let's leave this out.
725 # push @dirs, qw($(INST_ARCHLIB) $(INST_LIB)
726 # $(INST_BIN) $(INST_SCRIPT)
727 # $(INST_MAN1DIR) $(INST_MAN3DIR)
728 # $(INST_LIBDIR) $(INST_ARCHLIBDIR) $(INST_AUTODIR)
729 # $(INST_STATIC) $(INST_DYNAMIC)
730 # );
731  
732  
733 117 ▶ if( $attribs{FILES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribs{"FILES"}) 0 117 117
734 # Use @dirs because we don't know what's in here.
735 push @dirs, ref $attribs{FILES} ?
736 0 @{$attribs{FILES}} :
737 0 ▶ split /\s+/, $attribs{FILES} ;
Branch: 1 branch
BranchTrueFalseTotal
ref $attribs{'FILES'} ? : 0 0 0
738 }
739  
740 117 push(@files, qw[$(MAKE_APERL_FILE)
741 MYMETA.json MYMETA.yml perlmain.c tmon.out mon.out so_locations
742 blibdirs.ts pm_to_blib pm_to_blib.ts
743 *$(OBJ_EXT) *$(LIB_EXT) perl.exe perl perl$(EXE_EXT)
744 $(BOOTSTRAP) $(BASEEXT).bso
745 $(BASEEXT).def lib$(BASEEXT).def
746 $(BASEEXT).exp $(BASEEXT).x
747 ]);
748  
749 117 push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.all'));
750 117 push(@files, $self->catfile('$(INST_ARCHAUTODIR)','extralibs.ld'));
751  
752 # core files
753 117 ▶ if ($^O eq 'vos') {
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq 'vos') { } 0 117 117
754 0 push(@files, qw[perl*.kp]);
755 }
756 else {
757 117 push(@files, qw[core core.*perl.*.? *perl.core]);
758 }
759  
760 117 push(@files, map { "core." . "[0-9]"x$_ } (1..5));
761  
762 # OS specific things to clean up. Use @dirs since we don't know
763 # what might be in here.
764 117 push @dirs, $self->extra_clean_files;
765  
766 # Occasionally files are repeated several times from different sources
767 117 { my(%f) = map { ($_ => 1) } @files; @files = sort keys %f; }
768 117 { my(%d) = map { ($_ => 1) } @dirs; @dirs = sort keys %d; }
769  
770 117 push @m, map "\t$_\n", $self->split_command('- $(RM_F)', @files);
771 117 push @m, map "\t$_\n", $self->split_command('- $(RM_RF)', @dirs);
772  
773 # Leave Makefile.old around for realclean
774 117 push @m, <<'MAKE';
775 $(NOECHO) $(RM_F) $(MAKEFILE_OLD)
776 - $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
777 MAKE
778  
779 117 ▶ push(@m, "\t$attribs{POSTOP}\n") if $attribs{POSTOP};
Branch: 1 branch
BranchTrueFalseTotal
if $attribs{"POSTOP"} 0 117 117
780  
781 117 join("", @m);
782 }
783  
784  
785 =head3 clean_subdirs_target
786  
787 my $make_frag = $MM->clean_subdirs_target;
788  
789 Returns the clean_subdirs target. This is used by the clean target to
790 call clean on any subdirectories which contain Makefiles.
791  
792 =cut
793  
794 sub clean_subdirs_target {
795 117 ▶ my($self) = shift;
Subroutine clean_subdirs_target: called CC=3 SCAR=11.0
Pod documented
796  
797 # No subdirectories, no cleaning.
798 117 ▶ return <<'NOOP_FRAG' unless @{$self->{DIR}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"DIR"};} 78 39 117
799 clean_subdirs :
800 $(NOECHO) $(NOOP)
801 NOOP_FRAG
802  
803  
804 39 my $clean = "clean_subdirs :\n";
805  
806 39 for my $dir (@{$self->{DIR}}) {
807 39 my $subclean = $self->oneliner(sprintf <<'CODE', $dir);
808 exit 0 unless chdir '%s'; system '$(MAKE) clean' if -f '$(FIRST_MAKEFILE)';
809 CODE
810  
811 39 $clean .= "\t$subclean\n";
812 }
813  
814 39 return $clean;
815 }
816  
817  
818 =head3 dir_target
819  
820 my $make_frag = $mm->dir_target(@directories);
821  
822 Generates targets to create the specified directories and set its
823 permission to PERM_DIR.
824  
825 Because depending on a directory to just ensure it exists doesn't work
826 too well (the modified time changes too often) dir_target() creates a
827 .exists file in the created directory. It is this you should depend on.
828 For portability purposes you should use the $(DIRFILESEP) macro rather
829 than a '/' to separate the directory from the file.
830  
831 yourdirectory$(DIRFILESEP).exists
832  
833 =cut
834  
835 sub dir_target {
836 117 ▶ my($self, @dirs) = @_;
Subroutine dir_target: called CC=2 SCAR=6.9
Pod documented
837  
838 117 my $make = '';
839 117 foreach my $dir (@dirs) {
840 936 $make .= sprintf <<'MAKE', ($dir) x 4;
841 %s$(DFSEP).exists :: Makefile.PL
842 $(NOECHO) $(MKPATH) %s
843 $(NOECHO) $(CHMOD) $(PERM_DIR) %s
844 $(NOECHO) $(TOUCH) %s$(DFSEP).exists
845  
846 MAKE
847  
848 }
849  
850 117 return $make;
851 }
852  
853  
854 =head3 distdir
855  
856 Defines the scratch directory target that will hold the distribution
857 before tar-ing (or shar-ing).
858  
859 =cut
860  
861 # For backwards compatibility.
862 50 *dist_dir = *distdir;
863  
864 sub distdir {
865 77 ▶ my($self) = shift;
Subroutine distdir: called CC=3 SCAR=11.4
Pod documented
866  
867 77 ▶ my $meta_target = $self->{NO_META} ? '' : 'distmeta';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'NO_META'} ? : 0 77 77
868 77 ▶ my $sign_target = !$self->{SIGN} ? '' : 'distsignature';
Branch: 1 branch
BranchTrueFalseTotal
!$self->{'SIGN'} ? : 77 0 77
869  
870 77 return sprintf <<'MAKE_FRAG', $meta_target, $sign_target;
871 create_distdir :
872 $(RM_RF) $(DISTVNAME)
873 $(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
874 -e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
875  
876 distdir : create_distdir %s %s
877 $(NOECHO) $(NOOP)
878  
879 MAKE_FRAG
880  
881 }
882  
883  
884 =head3 dist_test
885  
886 Defines a target that produces the distribution in the
887 scratch directory, and runs 'perl Makefile.PL; make ;make test' in that
888 subdirectory.
889  
890 =cut
891  
892 sub dist_test {
893 77 ▶ my($self) = shift;
Subroutine dist_test: called CC=1 SCAR=0.0
Pod documented
894  
895 77 my $mpl_args = join " ", map qq["$_"], @ARGV;
896  
897 77 my $test = $self->cd('$(DISTVNAME)',
898 '$(ABSPERLRUN) Makefile.PL '.$mpl_args,
899 '$(MAKE) $(PASTHRU)',
900 '$(MAKE) test $(PASTHRU)'
901 );
902  
903 77 return sprintf <<'MAKE_FRAG', $test;
904 disttest : distdir
905 %s
906  
907 MAKE_FRAG
908  
909  
910 }
911  
912  
913 =head3 xs_dlsyms_ext
914  
915 Returns file-extension for C<xs_make_dlsyms> method's output file,
916 including any "." character.
917  
918 =cut
919  
920 sub xs_dlsyms_ext {
921 0 ▶ die "Pure virtual method";
Subroutine xs_dlsyms_ext: not called CC=1 SCAR=6.9
Pod documented
922 }
923  
924 =head3 xs_dlsyms_extra
925  
926 Returns any extra text to be prepended to the C<$extra> argument of
927 C<xs_make_dlsyms>.
928  
929 =cut
930  
931 sub xs_dlsyms_extra {
932 0 ▶ '';
Subroutine xs_dlsyms_extra: not called CC=1 SCAR=6.9
Pod documented
933 }
934  
935 =head3 xs_dlsyms_iterator
936  
937 Iterates over necessary shared objects, calling C<xs_make_dlsyms> method
938 for each with appropriate arguments.
939  
940 =cut
941  
942 sub xs_dlsyms_iterator {
943 0 ▶ my ($self, $attribs) = @_;
Subroutine xs_dlsyms_iterator: not called CC=12 SCAR=50.5
Pod documented
944 0 ▶ if ($self->{XSMULTI}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'XSMULTI'}) { } 0 0 0
945 0 my @m;
946 0 for my $ext ($self->_xs_list_basenames) {
947 0 my @parts = File::Spec->splitdir($ext);
948 0 ▶ shift @parts if $parts[0] eq 'lib';
Branch: 1 branch
BranchTrueFalseTotal
if $parts[0] eq "lib" 0 0 0
949 0 my $name = join '::', @parts;
950 0 push @m, $self->xs_make_dlsyms(
951 $attribs,
952 $ext . $self->xs_dlsyms_ext,
953 "$ext.xs",
954 $name,
955 $parts[-1],
956 {}, [], {}, [],
957 $self->xs_dlsyms_extra . q!, 'FILE' => ! . neatvalue($ext),
958 );
959 }
960 0 return join "\n", @m;
961 } else {
962 return $self->xs_make_dlsyms(
963 $attribs,
964 $self->{BASEEXT} . $self->xs_dlsyms_ext,
965 'Makefile.PL',
966 $self->{NAME},
967 $self->{DLBASE},
968 $attribs->{DL_FUNCS} || $self->{DL_FUNCS} || {},
969 $attribs->{FUNCLIST} || $self->{FUNCLIST} || [],
970 $attribs->{IMPORTS} || $self->{IMPORTS} || {},
971 0 ▶ $attribs->{DL_VARS} || $self->{DL_VARS} || [],
Condition0%0/20
$attribs->{'DL_FUNCS'} || $self->{'DL_FUNCS'} || {}
l!l
00
$attribs->{"DL_FUNCS"} or $self->{"DL_FUNCS"}
l!l&&r!l&&!r
000
$attribs->{'FUNCLIST'} || $self->{'FUNCLIST'} || []
l!l
00
$attribs->{"FUNCLIST"} or $self->{"FUNCLIST"}
l!l&&r!l&&!r
000
$attribs->{'IMPORTS'} || $self->{'IMPORTS'} || {}
l!l
00
$attribs->{"IMPORTS"} or $self->{"IMPORTS"}
l!l&&r!l&&!r
000
$attribs->{'DL_VARS'} || $self->{'DL_VARS'} || []
l!l
00
$attribs->{"DL_VARS"} or $self->{"DL_VARS"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$attribs->{'DL_FUNCS'} || $self->{'DL_FUNCS'} || {}
$attribs->{"DL_FUNCS"} $self->{"DL_FUNCS"}
MC/DC0%0/2
$attribs->{'FUNCLIST'} || $self->{'FUNCLIST'} || []
$attribs->{"FUNCLIST"} $self->{"FUNCLIST"}
MC/DC0%0/2
$attribs->{'IMPORTS'} || $self->{'IMPORTS'} || {}
$attribs->{"IMPORTS"} $self->{"IMPORTS"}
MC/DC0%0/2
$attribs->{'DL_VARS'} || $self->{'DL_VARS'} || []
$attribs->{"DL_VARS"} $self->{"DL_VARS"}
Truth table0%0/3
A or B
A= $attribs->{"DL_FUNCS"}B= $self->{"DL_FUNCS"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $attribs->{"FUNCLIST"}B= $self->{"FUNCLIST"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $attribs->{"IMPORTS"}B= $self->{"IMPORTS"}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $attribs->{"DL_VARS"}B= $self->{"DL_VARS"}
ABresult
1X1
011
000
972 $self->xs_dlsyms_extra,
973 );
974 }
975 }
976  
977 =head3 xs_make_dlsyms
978  
979 $self->xs_make_dlsyms(
980 \%attribs, # hashref from %attribs in caller
981 "$self->{BASEEXT}.def", # output file for Makefile target
982 'Makefile.PL', # dependency
983 $self->{NAME}, # shared object's "name"
984 $self->{DLBASE}, # last ::-separated part of name
985 $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {}, # various params
986 $attribs{FUNCLIST} || $self->{FUNCLIST} || [],
987 $attribs{IMPORTS} || $self->{IMPORTS} || {},
988 $attribs{DL_VARS} || $self->{DL_VARS} || [],
989 # optional extra param that will be added as param to Mksymlists
990 );
991  
992 Utility method that returns Makefile snippet to call C<Mksymlists>.
993  
994 =cut
995  
996 sub xs_make_dlsyms {
997 0 ▶ my ($self, $attribs, $target, $dep, $name, $dlbase, $funcs, $funclist, $imports, $vars, $extra) = @_;
Subroutine xs_make_dlsyms: not called CC=2 SCAR=17.9
Pod documented
998 0 my @m = (
999 "\n$target: $dep\n",
1000 q! $(PERLRUN) -MExtUtils::Mksymlists \\
1001 -e "Mksymlists('NAME'=>\"!, $name,
1002 q!\", 'DLBASE' => '!,$dlbase,
1003 # The above two lines quoted differently to work around
1004 # a bug in the 4DOS/4NT command line interpreter. The visible
1005 # result of the bug was files named q('extension_name',) *with the
1006 # single quotes and the comma* in the extension build directories.
1007 q!', 'DL_FUNCS' => !,neatvalue($funcs),
1008 q!, 'FUNCLIST' => !,neatvalue($funclist),
1009 q!, 'IMPORTS' => !,neatvalue($imports),
1010 q!, 'DL_VARS' => !, neatvalue($vars)
1011 );
1012 0 ▶ push @m, $extra if defined $extra;
Branch: 1 branch
BranchTrueFalseTotal
if defined $extra 0 0 0
1013 0 push @m, qq!);"\n!;
1014 0 join '', @m;
1015 }
1016  
1017 =head3 dynamic (o)
1018  
1019 Defines the dynamic target.
1020  
1021 =cut
1022  
1023 sub dynamic {
1024 # --- Dynamic Loading Sections ---
1025  
1026 117 ▶ my($self) = shift;
Subroutine dynamic: called CC=1 SCAR=0.0
Pod documented
1027 117 '
1028 dynamic :: $(FIRST_MAKEFILE) config $(INST_BOOT) $(INST_DYNAMIC)
1029 $(NOECHO) $(NOOP)
1030 ';
1031 }
1032  
1033  
1034 =head3 makemakerdflt_target
1035  
1036 my $make_frag = $mm->makemakerdflt_target
1037  
1038 Returns a make fragment with the makemakerdeflt_target specified.
1039 This target is the first target in the Makefile, is the default target
1040 and simply points off to 'all' just in case any make variant gets
1041 confused or something gets snuck in before the real 'all' target.
1042  
1043 =cut
1044  
1045 sub makemakerdflt_target {
1046 117 ▶ return <<'MAKE_FRAG';
Subroutine makemakerdflt_target: called CC=1 SCAR=0.0
Pod documented
1047 makemakerdflt : all
1048 $(NOECHO) $(NOOP)
1049 MAKE_FRAG
1050  
1051 }
1052  
1053  
1054 =head3 manifypods_target
1055  
1056 my $manifypods_target = $self->manifypods_target;
1057  
1058 Generates the manifypods target. This target generates man pages from
1059 all POD files in MAN1PODS and MAN3PODS.
1060  
1061 =cut
1062  
1063 sub manifypods_target {
1064 117 ▶ my($self) = shift;
Subroutine manifypods_target: called CC=5 SCAR=16.1
Pod documented
1065  
1066 117 my $man1pods = '';
1067 117 my $man3pods = '';
1068 117 my $dependencies = '';
1069  
1070 # populate manXpods & dependencies:
1071 117 foreach my $name (sort keys %{$self->{MAN1PODS}}, sort keys %{$self->{MAN3PODS}}) {
1072 8 $dependencies .= " \\\n\t$name";
1073 }
1074  
1075 117 my $manify = <<END;
1076 manifypods : pure_all config $dependencies
1077 END
1078  
1079 117 my @man_cmds;
1080 117 foreach my $section (qw(1 3)) {
1081 234 my $pods = $self->{"MAN${section}PODS"};
1082 234 ▶ my $p2m = sprintf <<'CMD', $section, $] > 5.008 ? " -u" : "";
Branch: 1 branch
BranchTrueFalseTotal
$] > 5.008 ? : 234 0 234
1083 $(NOECHO) $(POD2MAN) --section=%s --perm_rw=$(PERM_RW)%s
1084 CMD
1085 234 push @man_cmds, $self->split_command($p2m, map {($_,$pods->{$_})} sort keys %$pods);
1086 }
1087  
1088 117 ▶ $manify .= "\t\$(NOECHO) \$(NOOP)\n" unless @man_cmds;
Branch: 1 branch
BranchTrueFalseTotal
unless @man_cmds 109 8 117
1089 117 $manify .= join '', map { "$_\n" } @man_cmds;
1090  
1091 117 return $manify;
1092 }
1093  
1094 {
1095 50 my $has_cpan_meta;
1096 sub _has_cpan_meta {
1097 547 ▶ return $has_cpan_meta if defined $has_cpan_meta;
Subroutine _has_cpan_meta: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $has_cpan_meta 530 17 547
1098 17 return $has_cpan_meta = !!eval {
1099 17 require CPAN::Meta;
1100 16 CPAN::Meta->VERSION(2.112150);
1101 16 1;
1102 };
1103 }
1104 }
1105  
1106 =head3 metafile_target
1107  
1108 my $target = $mm->metafile_target;
1109  
1110 Generate the metafile target.
1111  
1112 Writes the file META.yml (YAML encoded meta-data) and META.json
1113 (JSON encoded meta-data) about the module in the distdir.
1114 The format follows Module::Build's as closely as possible.
1115  
1116 =cut
1117  
1118 50 sub metafile_target {
1119 124 ▶ my $self = shift;
Subroutine metafile_target: called CC=5 SCAR=16.1
Pod documented
1120 124 ▶ return <<'MAKE_FRAG' if $self->{NO_META} or ! _has_cpan_meta();
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"NO_META"} or not _has_cpan_meta() 26 98 124
Condition66%2/3
$self->{"NO_META"} or not _has_cpan_meta()
l!l&&r!l&&!r
02698
MC/DC50%1/2
$self->{"NO_META"} or not _has_cpan_meta()
$self->{"NO_META"} not _has_cpan_meta()
Truth table66%2/3
A or not(B)
A= $self->{"NO_META"}B= not _has_cpan_meta()
ABresult
1X1
011
000
1121 metafile :
1122 $(NOECHO) $(NOOP)
1123 MAKE_FRAG
1124  
1125 my $metadata = $self->metafile_data(
1126 $self->{META_ADD} || {},
1127 $self->{META_MERGE} || {},
1128 98 ▶ );
Condition100%4/4
$self->{'META_ADD'} || {}
l!l
197
$self->{'META_MERGE'} || {}
l!l
197
MC/DC100%1/1
$self->{'META_ADD'} || {}
$self->{'META_ADD'}
MC/DC100%1/1
$self->{'META_MERGE'} || {}
$self->{'META_MERGE'}
Truth table100%2/2
A
A= $self->{'META_ADD'}
Aresult
11
00
Truth table100%2/2
A
A= $self->{'META_MERGE'}
Aresult
11
00
1129  
1130 98 my $meta = $self->_fix_metadata_before_conversion( $metadata );
1131  
1132 98 my @write_metayml = $self->stashmeta(
1133 $meta->as_string({version => "1.4"}), 'META_new.yml'
1134 );
1135 98 my @write_metajson = $self->stashmeta(
1136 $meta->as_string({version => "2.0"}), 'META_new.json'
1137 );
1138  
1139 98 my $metayml = join("\n\t", @write_metayml);
1140 98 my $metajson = join("\n\t", @write_metajson);
1141 98 return sprintf <<'MAKE_FRAG', $metayml, $metajson;
1142 metafile : create_distdir
1143 $(NOECHO) $(ECHO) Generating META.yml
1144 %s
1145 -$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
1146 $(NOECHO) $(ECHO) Generating META.json
1147 %s
1148 -$(NOECHO) $(MV) META_new.json $(DISTVNAME)/META.json
1149 MAKE_FRAG
1150  
1151 }
1152  
1153 =begin private
1154  
1155 =head3 _fix_metadata_before_conversion
1156  
1157 $mm->_fix_metadata_before_conversion( \%metadata );
1158  
1159 Fixes errors in the metadata before it's handed off to CPAN::Meta for
1160 conversion. This hopefully results in something that can be used further
1161 on, no guarantee is made though.
1162  
1163 =end private
1164  
1165 =cut
1166  
1167 sub _fix_metadata_before_conversion {
1168 188 ▶ my ( $self, $metadata ) = @_;
Subroutine _fix_metadata_before_conversion: called CC=19 SCAR=31.4
1169  
1170 # we should never be called unless this already passed but
1171 # prefer to be defensive in case somebody else calls this
1172  
1173 188 ▶ return unless _has_cpan_meta;
Branch: 1 branch
BranchTrueFalseTotal
unless _has_cpan_meta() 0 188 188
1174  
1175 my $bad_version = $metadata->{version} &&
1176 188 ▶ !CPAN::Meta::Validator->new->version( 'version', $metadata->{version} );
Condition100%3/3
$metadata->{'version'} && !'CPAN::Meta::Validator'->new->version('version', $metadata->{'version'})
!ll&&!rl&&r
401408
MC/DC100%2/2
$metadata->{'version'} && !'CPAN::Meta::Validator'->new->version('version', $metadata->{'version'})
$metadata->{'version'} !'CPAN::Meta::Validator'->new->version('version', $metadata->{'version'})
Truth table100%3/3
A && not(B)
A= $metadata->{'version'}B= !'CPAN::Meta::Validator'->new->version('version', $metadata->{'version'})
ABresult
0X0
100
111
1177 # just delete all invalid versions
1178 188 ▶ if( $bad_version ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bad_version) 8 180 188
1179 8 warn "Can't parse version '$metadata->{version}'\n";
1180 8 $metadata->{version} = '';
1181 }
1182  
1183 188 my $validator2 = CPAN::Meta::Validator->new( $metadata );
1184 188 my @errors;
1185 188 ▶ push @errors, $validator2->errors if !$validator2->is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $validator2->is_valid 4 184 188
1186 188 my $validator14 = CPAN::Meta::Validator->new(
1187 {
1188 %$metadata,
1189 'meta-spec' => { version => 1.4 },
1190 }
1191 );
1192 188 ▶ push @errors, $validator14->errors if !$validator14->is_valid;
Branch: 1 branch
BranchTrueFalseTotal
unless $validator14->is_valid 188 0 188
1193 # fix non-camelcase custom resource keys (only other trick we know)
1194 188 for my $error ( @errors ) {
1195 384 my ( $key ) = ( $error =~ /Custom resource '(.*)' must be in CamelCase./ );
1196 384 ▶ next if !$key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 383 1 384
1197  
1198 # first try to remove all non-alphabetic chars
1199 1 ( my $new_key = $key ) =~ s/[^_a-zA-Z]//g;
1200  
1201 # if that doesn't work, uppercase first one
1202 1 ▶ $new_key = ucfirst $new_key if !$validator14->custom_1( $new_key );
Branch: 1 branch
BranchTrueFalseTotal
unless $validator14->custom_1($new_key) 0 1 1
1203  
1204 # copy to new key if that worked
1205 1 ▶ $metadata->{resources}{$new_key} = $metadata->{resources}{$key}
Branch: 1 branch
BranchTrueFalseTotal
if $validator14->custom_1($new_key) 1 0 1
1206 if $validator14->custom_1( $new_key );
1207  
1208 # and delete old one in any case
1209 1 delete $metadata->{resources}{$key};
1210 }
1211  
1212 # paper over validation issues, but still complain, necessary because
1213 # there's no guarantee that the above will fix ALL errors
1214 188 my $meta = eval { CPAN::Meta->create( $metadata, { lazy_validation => 1 } ) };
1215 188 ▶ warn $@ if $@ and
Branch: 1 branch
BranchTrueFalseTotal
if $@ and not $@ =~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/ 0 188 188
Condition33%1/3
$@ and not $@ =~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/
!ll&&!rl&&r
18800
MC/DC0%0/2
$@ and not $@ =~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/
$@ not $@ =~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/
Truth table33%1/3
A and not(B)
A= $@B= not $@ =~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/
ABresult
0X0
100
111
1216 $@ !~ /encountered CODE.*, but JSON can only represent references to arrays or hashes/;
1217  
1218 # use the original metadata straight if the conversion failed
1219 # or if it can't be stringified.
1220 188 ▶ if( !$meta ||
Branch: 1 branch
BranchTrueFalseTotal
unless ($meta and eval { do { $meta->as_string({"version", $METASPEC_V}) } } and eval { do { $meta->as_string } }) 0 188 188
Condition33%2/6
$meta and eval { do { $meta->as_string({"version", $METASPEC_V}) } } and eval { do { $meta->as_string } }
!ll&&!rl&&r
00188
$meta and eval { do { $meta->as_string({"version", $METASPEC_V}) } }
!ll&&!rl&&r
00188
MC/DC0%0/3
$meta and eval { do { $meta->as_string({"version", $METASPEC_V}) } } and eval { do { $meta->as_string } }
$meta eval { do { $meta->as_string({"version", $METASPEC_V}) } } eval { do { $meta->as_string } }
Truth table25%1/4
A and B and C
A= $metaB= eval { do { $meta->as_string({"version", $METASPEC_V}) } }C= eval { do { $meta->as_string } }
ABCresult
0XX0
10X0
1100
1111
1221 188 !eval { $meta->as_string( { version => $METASPEC_V } ) } ||
1222 188 !eval { $meta->as_string }
1223 ) {
1224 0 $meta = bless $metadata, 'CPAN::Meta';
1225 }
1226  
1227 188 my $now_license = $meta->as_struct({ version => 2 })->{license};
1228 188 ▶ if ($self->{LICENSE} and $self->{LICENSE} ne 'unknown' and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LICENSE"} and $self->{"LICENSE"} ne "unknown" and @{$now_license;} == 1 and $now_license->[0] eq "unknown") 2 186 188
Condition66%6/9
$self->{"LICENSE"} and $self->{"LICENSE"} ne "unknown" and @{$now_license;} == 1 and $now_license->[0] eq "unknown"
!ll&&!rl&&r
18602
$self->{"LICENSE"} and $self->{"LICENSE"} ne "unknown" and @{$now_license;} == 1
!ll&&!rl&&r
18602
$self->{"LICENSE"} and $self->{"LICENSE"} ne "unknown"
!ll&&!rl&&r
18602
MC/DC25%1/4
$self->{"LICENSE"} and $self->{"LICENSE"} ne "unknown" and @{$now_license;} == 1 and $now_license->[0] eq "unknown"
$self->{"LICENSE"} $self->{"LICENSE"} ne "unknown" @{$now_license;} == 1 $now_license->[0] eq "unknown"
Truth table40%2/5
A and B and C and D
A= $self->{"LICENSE"}B= $self->{"LICENSE"} ne "unknown"C= @{$now_license;} == 1D= $now_license->[0] eq "unknown"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1229 2 @{$now_license} == 1 and $now_license->[0] eq 'unknown'
1230 ) {
1231 2 warn "Invalid LICENSE value '$self->{LICENSE}' ignored\n";
1232 }
1233  
1234 188 $meta;
1235 }
1236  
1237  
1238 =begin private
1239  
1240 =head3 _sort_pairs
1241  
1242 my @pairs = _sort_pairs($sort_sub, \%hash);
1243  
1244 Sorts the pairs of a hash based on keys ordered according
1245 to C<$sort_sub>.
1246  
1247 =end private
1248  
1249 =cut
1250  
1251 sub _sort_pairs {
1252 13 ▶ my $sort = shift;
Subroutine _sort_pairs: called CC=1 SCAR=0.0
1253 13 my $pairs = shift;
1254 13 return map { $_ => $pairs->{$_} }
1255 sort $sort
1256 keys %$pairs;
1257 }
1258  
1259  
1260 # Taken from Module::Build::Base
1261 sub _hash_merge {
1262 6 ▶ my ($self, $h, $k, $v) = @_;
Subroutine _hash_merge: called CC=5 SCAR=16.1
1263 6 ▶ if (ref $h->{$k} eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $h->{$k} eq 'ARRAY') { } 1 5 6
elsif (ref $h->{$k} eq 'HASH') { } 2 3 5
1264 1 ▶ push @{$h->{$k}}, ref $v ? @$v : $v;
Branch: 1 branch
BranchTrueFalseTotal
ref $v ? : 1 0 1
1265 } elsif (ref $h->{$k} eq 'HASH') {
1266 2 $self->_hash_merge($h->{$k}, $_, $v->{$_}) foreach keys %$v;
1267 } else {
1268 3 $h->{$k} = $v;
1269 }
1270 }
1271  
1272  
1273 =head3 metafile_data
1274  
1275 my $metadata_hashref = $mm->metafile_data(\%meta_add, \%meta_merge);
1276  
1277 Returns the data which MakeMaker turns into the META.yml file
1278 and the META.json file. It is always in version 2.0 of the format.
1279  
1280 Values of %meta_add will overwrite any existing metadata in those
1281 keys. %meta_merge will be merged with them.
1282  
1283 =cut
1284  
1285 sub metafile_data {
1286 226 ▶ my $self = shift;
Subroutine metafile_data: called CC=16 SCAR=27.8
Pod documented
1287 226 my($meta_add, $meta_merge) = @_;
1288  
1289 226 ▶ $meta_add ||= {};
Condition100%2/2
$meta_add ||= {}
l!l
2206
MC/DC100%1/1
$meta_add ||= {}
$meta_add
Truth table100%2/2
A
A= $meta_add
Aresult
11
00
1290 226 ▶ $meta_merge ||= {};
Condition100%2/2
$meta_merge ||= {}
l!l
2197
MC/DC100%1/1
$meta_merge ||= {}
$meta_merge
Truth table100%2/2
A
A= $meta_merge
Aresult
11
00
1291  
1292 226 my $version = _normalize_version($self->{VERSION});
1293 226 ▶ my $release_status = ($version =~ /_/) ? 'unstable' : 'stable';
Branch: 1 branch
BranchTrueFalseTotal
$version =~ /_/ ? : 2 224 226
1294 my %meta = (
1295 # required
1296 abstract => $self->{ABSTRACT} || 'unknown',
1297 author => defined($self->{AUTHOR}) ? $self->{AUTHOR} : ['unknown'],
1298 dynamic_config => 1,
1299 generated_by => "ExtUtils::MakeMaker version $ExtUtils::MakeMaker::VERSION",
1300 license => [ $self->{LICENSE} || 'unknown' ],
1301 'meta-spec' => {
1302 url => $METASPEC_URL,
1303 version => $METASPEC_V,
1304 },
1305 name => $self->{DISTNAME},
1306 226 ▶ release_status => $release_status,
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'AUTHOR'} ? : 13 213 226
Condition100%4/4
$self->{'ABSTRACT'} || 'unknown'
l!l
2224
$self->{'LICENSE'} || 'unknown'
l!l
2224
MC/DC100%1/1
$self->{'ABSTRACT'} || 'unknown'
$self->{'ABSTRACT'}
MC/DC100%1/1
$self->{'LICENSE'} || 'unknown'
$self->{'LICENSE'}
Truth table100%2/2
A
A= $self->{'ABSTRACT'}
Aresult
11
00
Truth table100%2/2
A
A= $self->{'LICENSE'}
Aresult
11
00
1307 version => $version,
1308  
1309 # optional
1310 no_index => { directory => [qw(t inc)] },
1311 );
1312 226 $self->_add_requirements_to_meta(\%meta);
1313  
1314 226 ▶ if (!eval { require JSON::PP; require CPAN::Meta::Converter; CPAN::Meta::Converter->VERSION(2.141170) }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require JSON::PP; require CPAN::Meta::Converter; "CPAN::Meta::Converter"->VERSION("2.14117") } }) 0 226 226
1315 0 return \%meta;
1316 }
1317  
1318 # needs to be based on the original version
1319 226 my $v1_add = _metaspec_version($meta_add) !~ /^2/;
1320  
1321 226 for my $frag ($meta_add, $meta_merge) {
1322 452 $frag = CPAN::Meta::Converter->new($frag, default_version => "1.4")->upgrade_fragment;
1323 }
1324  
1325 # if we upgraded a 1.x _ADD fragment, we gave it a prereqs key that
1326 # will override all prereqs, which is more than the user asked for;
1327 # instead, we'll go inside the prereqs and override all those
1328 226 ▶ while( my($key, $val) = each %$meta_add ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$meta_add) 230 226 456
1329 230 ▶ if ($v1_add and $key eq 'prereqs') {
Branch: 2 branches
BranchTrueFalseTotal
if ($v1_add and $key eq 'prereqs') { } 2 228 230
elsif ($key ne 'meta-spec') { } 2 226 228
Condition66%2/3
$v1_add and $key eq "prereqs"
!ll&&!rl&&r
02282
MC/DC50%1/2
$v1_add and $key eq "prereqs"
$v1_add $key eq "prereqs"
Truth table66%2/3
A and B
A= $v1_addB= $key eq "prereqs"
ABresult
0X0
100
111
1330 2 $meta{$key}{$_} = $val->{$_} for keys %$val;
1331 } elsif ($key ne 'meta-spec') {
1332 2 $meta{$key} = $val;
1333 }
1334 }
1335  
1336 226 ▶ while( my($key, $val) = each %$meta_merge ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$meta_merge) 230 226 456
1337 230 ▶ next if $key eq 'meta-spec';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "meta-spec" 226 4 230
1338 4 $self->_hash_merge(\%meta, $key, $val);
1339 }
1340  
1341 226 return \%meta;
1342 }
1343  
1344  
1345 =begin private
1346  
1347 =cut
1348  
1349 sub _add_requirements_to_meta {
1350 345 ▶ my ( $self, $meta ) = @_;
Subroutine _add_requirements_to_meta: called CC=6 SCAR=17.9
1351 # Check the original args so we can tell between the user setting it
1352 # to an empty hash and it just being initialized.
1353 $meta->{prereqs}{configure}{requires} = $self->{ARGS}{CONFIGURE_REQUIRES}
1354 ? $self->{CONFIGURE_REQUIRES}
1355 345 ▶ : { 'ExtUtils::MakeMaker' => 0, };
Branch: 1 branch
BranchTrueFalseTotal
$self->{'ARGS'}{'CONFIGURE_REQUIRES'} ? : 6 339 345
1356 $meta->{prereqs}{build}{requires} = $self->{ARGS}{BUILD_REQUIRES}
1357 ? $self->{BUILD_REQUIRES}
1358 345 ▶ : { 'ExtUtils::MakeMaker' => 0, };
Branch: 1 branch
BranchTrueFalseTotal
$self->{'ARGS'}{'BUILD_REQUIRES'} ? : 6 339 345
1359 $meta->{prereqs}{test}{requires} = $self->{TEST_REQUIRES}
1360 345 ▶ if $self->{ARGS}{TEST_REQUIRES};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ARGS"}{"TEST_REQUIRES"} 6 339 345
1361 $meta->{prereqs}{runtime}{requires} = $self->{PREREQ_PM}
1362 345 ▶ if $self->{ARGS}{PREREQ_PM};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ARGS"}{"PREREQ_PM"} 88 257 345
1363 $meta->{prereqs}{runtime}{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION})
1364 345 ▶ if $self->{MIN_PERL_VERSION};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MIN_PERL_VERSION"} 18 327 345
1365 }
1366  
1367 # spec version of given fragment - if not given, assume 1.4
1368 sub _metaspec_version {
1369 226 ▶ my ( $meta ) = @_;
Subroutine _metaspec_version: called CC=3 SCAR=12.5
1370 return $meta->{'meta-spec'}->{version}
1371 if defined $meta->{'meta-spec'}
1372 226 ▶ and defined $meta->{'meta-spec'}->{version};
Branch: 1 branch
BranchTrueFalseTotal
if defined $meta->{"meta-spec"} and defined $meta->{"meta-spec"}{"version"} 0 226 226
Condition33%1/3
defined $meta->{"meta-spec"} and defined $meta->{"meta-spec"}{"version"}
!ll&&!rl&&r
22600
MC/DC0%0/2
defined $meta->{"meta-spec"} and defined $meta->{"meta-spec"}{"version"}
defined $meta->{"meta-spec"} defined $meta->{"meta-spec"}{"version"}
Truth table33%1/3
A and B
A= defined $meta->{"meta-spec"}B= defined $meta->{"meta-spec"}{"version"}
ABresult
0X0
100
111
1373 226 return '1.4';
1374 }
1375  
1376 sub _add_requirements_to_meta_v1_4 {
1377 0 ▶ my ( $self, $meta ) = @_;
Subroutine _add_requirements_to_meta_v1_4: not called CC=6 SCAR=37.4
1378 # Check the original args so we can tell between the user setting it
1379 # to an empty hash and it just being initialized.
1380 0 ▶ if( $self->{ARGS}{CONFIGURE_REQUIRES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ARGS'}{'CONFIGURE_REQUIRES'}) { } 0 0 0
1381 0 $meta->{configure_requires} = $self->{CONFIGURE_REQUIRES};
1382 } else {
1383 $meta->{configure_requires} = {
1384 0 'ExtUtils::MakeMaker' => 0,
1385 };
1386 }
1387 0 ▶ if( $self->{ARGS}{BUILD_REQUIRES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ARGS'}{'BUILD_REQUIRES'}) { } 0 0 0
1388 0 $meta->{build_requires} = $self->{BUILD_REQUIRES};
1389 } else {
1390 $meta->{build_requires} = {
1391 0 'ExtUtils::MakeMaker' => 0,
1392 };
1393 }
1394 0 ▶ if( $self->{ARGS}{TEST_REQUIRES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ARGS"}{"TEST_REQUIRES"}) 0 0 0
1395 $meta->{build_requires} = {
1396 0 %{ $meta->{build_requires} },
1397 0 %{ $self->{TEST_REQUIRES} },
1398 };
1399 }
1400 $meta->{requires} = $self->{PREREQ_PM}
1401 0 ▶ if defined $self->{PREREQ_PM};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"PREREQ_PM"} 0 0 0
1402 $meta->{requires}{perl} = _normalize_version($self->{MIN_PERL_VERSION})
1403 0 ▶ if $self->{MIN_PERL_VERSION};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MIN_PERL_VERSION"} 0 0 0
1404 }
1405  
1406 # Adapted from Module::Build::Base
1407 sub _normalize_version {
1408 244 ▶ my ($version) = @_;
Subroutine _normalize_version: called CC=4 SCAR=14.0
1409 244 ▶ $version = 0 unless defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 1 243 244
1410  
1411 244 ▶ if ( ref $version eq 'version' ) { # version objects
Branch: 2 branches
BranchTrueFalseTotal
if (ref $version eq 'version') { } 4 240 244
elsif ($version =~ /^[^v][^.]*\.[^.]+\./) { } 0 240 240
1412 4 $version = $version->stringify;
1413 }
1414 elsif ( $version =~ /^[^v][^.]*\.[^.]+\./ ) { # no leading v, multiple dots
1415 # normalize string tuples without "v": "1.2.3" -> "v1.2.3"
1416 0 $version = "v$version";
1417 }
1418 else {
1419 # leave alone
1420 }
1421 244 return $version;
1422 }
1423  
1424 =head3 _dump_hash
1425  
1426 $yaml = _dump_hash(\%options, %hash);
1427  
1428 Implements a fake YAML dumper for a hash given
1429 as a list of pairs. No quoting/escaping is done. Keys
1430 are supposed to be strings. Values are undef, strings,
1431 hash refs or array refs of strings.
1432  
1433 Supported options are:
1434  
1435 delta => STR - indentation delta
1436 use_header => BOOL - whether to include a YAML header
1437 indent => STR - a string of spaces
1438 default: ''
1439  
1440 max_key_length => INT - maximum key length used to align
1441 keys and values of the same hash
1442 default: 20
1443 key_sort => CODE - a sort sub
1444 It may be undef, which means no sorting by keys
1445 default: sub { lc $a cmp lc $b }
1446  
1447 customs => HASH - special options for certain keys
1448 (whose values are hashes themselves)
1449 may contain: max_key_length, key_sort, customs
1450  
1451 =end private
1452  
1453 =cut
1454  
1455 sub _dump_hash {
1456 26 ▶ croak "first argument should be a hash ref" unless ref $_[0] eq 'HASH';
Subroutine _dump_hash: called CC=22 SCAR=31.7
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "HASH" 0 26 26
1457 26 my $options = shift;
1458 26 my %hash = @_;
1459  
1460 # Use a list to preserve order.
1461 26 my @pairs;
1462  
1463 my $k_sort
1464 = exists $options->{key_sort} ? $options->{key_sort}
1465 26 ▶ : sub { lc $a cmp lc $b };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
exists $options->{'key_sort'} ? : 13 13 26
1466 26 ▶ if ($k_sort) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k_sort) { } 13 13 26
1467 13 ▶ croak "'key_sort' should be a coderef" unless ref $k_sort eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $k_sort eq "CODE" 0 13 13
1468 13 @pairs = _sort_pairs($k_sort, \%hash);
1469 } else { # list of pairs, no sorting
1470 13 @pairs = @_;
1471 }
1472  
1473 26 ▶ my $yaml = $options->{use_header} ? "--- #YAML:1.0\n" : '';
Branch: 1 branch
BranchTrueFalseTotal
$options->{'use_header'} ? : 13 13 26
1474 26 ▶ my $indent = $options->{indent} || '';
Condition100%2/2
$options->{'indent'} || ''
l!l
1313
MC/DC100%1/1
$options->{'indent'} || ''
$options->{'indent'}
Truth table100%2/2
A
A= $options->{'indent'}
Aresult
11
00
1475 my $k_length = min(
1476 ($options->{max_key_length} || 20),
1477 26 ▶ max(map { length($_) + 1 } grep { !ref $hash{$_} } keys %hash)
Condition50%1/2
$options->{'max_key_length'} || 20
l!l
026
MC/DC0%0/1
$options->{'max_key_length'} || 20
$options->{'max_key_length'}
Truth table50%1/2
A
A= $options->{'max_key_length'}
Aresult
11
00
1478 );
1479 26 ▶ my $customs = $options->{customs} || {};
Condition50%1/2
$options->{'customs'} || {}
l!l
026
MC/DC0%0/1
$options->{'customs'} || {}
$options->{'customs'}
Truth table50%1/2
A
A= $options->{'customs'}
Aresult
11
00
1480  
1481 # printf format for key
1482 26 my $k_format = "%-${k_length}s";
1483  
1484 26 ▶ while( @pairs ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@pairs) 84 24 108
1485 84 my($key, $val) = splice @pairs, 0, 2;
1486 84 ▶ $val = '~' unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 2 82 84
1487 84 ▶ if(ref $val eq 'HASH') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $val eq 'HASH') { } 14 70 84
elsif (ref $val eq 'ARRAY') { } 5 65 70
elsif (ref $val and not blessed($val)) { } 1 64 65
1488 14 ▶ if ( keys %$val ) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$val) { } 13 1 14
1489 my %k_options = ( # options for recursive call
1490 delta => $options->{delta},
1491 use_header => 0,
1492 indent => $indent . $options->{delta},
1493 13 );
1494 13 ▶ if (exists $customs->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $customs->{$key}) 0 13 13
1495 0 my %k_custom = %{$customs->{$key}};
1496 0 foreach my $k (qw(key_sort max_key_length customs)) {
1497 0 ▶ $k_options{$k} = $k_custom{$k} if exists $k_custom{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $k_custom{$k} 0 0 0
1498 }
1499 }
1500 13 $yaml .= $indent . "$key:\n"
1501 . _dump_hash(\%k_options, %$val);
1502 }
1503 else {
1504 1 $yaml .= $indent . "$key: {}\n";
1505 }
1506 }
1507 elsif (ref $val eq 'ARRAY') {
1508 5 ▶ if( @$val ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$val) { } 4 1 5
1509 4 $yaml .= $indent . "$key:\n";
1510  
1511 4 for (@$val) {
1512 7 ▶ croak "only nested arrays of non-refs are supported" if ref $_;
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ 1 6 7
1513 6 $yaml .= $indent . $options->{delta} . "- $_\n";
1514 }
1515 }
1516 else {
1517 1 $yaml .= $indent . "$key: []\n";
1518 }
1519 }
1520 ▶ elsif( ref $val and !blessed($val) ) {
Condition66%2/3
ref $val and not blessed($val)
!ll&&!rl&&r
6401
MC/DC50%1/2
ref $val and not blessed($val)
ref $val not blessed($val)
Truth table66%2/3
A and not(B)
A= ref $valB= not blessed($val)
ABresult
0X0
100
111
1521 1 croak "only nested hashes, arrays and objects are supported";
1522 }
1523 else { # if it's an object, just stringify it
1524 64 $yaml .= $indent . sprintf "$k_format %s\n", "$key:", $val;
1525 }
1526 };
1527  
1528 24 return $yaml;
1529  
1530 }
1531  
1532 sub blessed {
1533 1 ▶ return eval { $_[0]->isa("UNIVERSAL"); };
Subroutine blessed: called CC=1 SCAR=0.0
Pod undocumented
1534 }
1535  
1536 sub max {
1537 26 ▶ return (sort { $b <=> $a } @_)[0];
Subroutine max: called CC=1 SCAR=0.0
Pod undocumented
1538 }
1539  
1540 sub min {
1541 26 ▶ return (sort { $a <=> $b } @_)[0];
Subroutine min: called CC=1 SCAR=0.0
Pod undocumented
1542 }
1543  
1544 =head3 metafile_file
1545  
1546 my $meta_yml = $mm->metafile_file(@metadata_pairs);
1547  
1548 Turns the @metadata_pairs into YAML.
1549  
1550 This method does not implement a complete YAML dumper, being limited
1551 to dump a hash with values which are strings, undef's or nested hashes
1552 and arrays of strings. No quoting/escaping is done.
1553  
1554 =cut
1555  
1556 sub metafile_file {
1557 13 ▶ my $self = shift;
Subroutine metafile_file: called CC=1 SCAR=0.0
Pod documented
1558  
1559 13 my %dump_options = (
1560 use_header => 1,
1561 delta => ' ' x 4,
1562 key_sort => undef,
1563 );
1564 13 return _dump_hash(\%dump_options, @_);
1565  
1566 }
1567  
1568  
1569 =head3 distmeta_target
1570  
1571 my $make_frag = $mm->distmeta_target;
1572  
1573 Generates the distmeta target to add META.yml and META.json to the MANIFEST
1574 in the distdir.
1575  
1576 =cut
1577  
1578 sub distmeta_target {
1579 117 ▶ my $self = shift;
Subroutine distmeta_target: called CC=1 SCAR=0.0
Pod documented
1580  
1581 117 my @add_meta = (
1582 $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']),
1583 exit unless -e q{META.yml};
1584 eval { maniadd({q{META.yml} => q{Module YAML meta-data (added by MakeMaker)}}) }
1585 or die "Could not add META.yml to MANIFEST: ${'@'}"
1586 CODE
1587 $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd'])
1588 exit unless -f q{META.json};
1589 eval { maniadd({q{META.json} => q{Module JSON meta-data (added by MakeMaker)}}) }
1590 or die "Could not add META.json to MANIFEST: ${'@'}"
1591 CODE
1592 );
1593  
1594 117 my @add_meta_to_distdir = map { $self->cd('$(DISTVNAME)', $_) } @add_meta;
1595  
1596 117 return sprintf <<'MAKE', @add_meta_to_distdir;
1597 distmeta : create_distdir metafile
1598 $(NOECHO) %s
1599 $(NOECHO) %s
1600  
1601 MAKE
1602  
1603 }
1604  
1605  
1606 =head3 mymeta
1607  
1608 my $mymeta = $mm->mymeta;
1609  
1610 Generate MYMETA information as a hash either from an existing CPAN Meta file
1611 (META.json or META.yml) or from internal data.
1612  
1613 =cut
1614  
1615 sub mymeta {
1616 119 ▶ my $self = shift;
Subroutine mymeta: called CC=5 SCAR=16.2
Pod documented
1617 119 ▶ my $file = shift || ''; # for testing
Condition100%2/2
shift() || ''
l!l
4115
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1618  
1619 119 my $mymeta = $self->_mymeta_from_meta($file);
1620 119 my $v2 = 1;
1621  
1622 119 ▶ unless ( $mymeta ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($mymeta) 115 4 119
1623 $mymeta = $self->metafile_data(
1624 $self->{META_ADD} || {},
1625 $self->{META_MERGE} || {},
1626 115 ▶ );
Condition50%2/4
$self->{'META_ADD'} || {}
l!l
0115
$self->{'META_MERGE'} || {}
l!l
0115
MC/DC0%0/1
$self->{'META_ADD'} || {}
$self->{'META_ADD'}
MC/DC0%0/1
$self->{'META_MERGE'} || {}
$self->{'META_MERGE'}
Truth table50%1/2
A
A= $self->{'META_ADD'}
Aresult
11
00
Truth table50%1/2
A
A= $self->{'META_MERGE'}
Aresult
11
00
1627 115 $v2 = 0;
1628 }
1629  
1630 # Overwrite the non-configure dependency hashes
1631 119 $self->_add_requirements_to_meta($mymeta);
1632  
1633 119 $mymeta->{dynamic_config} = 0;
1634  
1635 119 return $mymeta;
1636 }
1637  
1638  
1639 sub _mymeta_from_meta {
1640 119 ▶ my $self = shift;
Subroutine _mymeta_from_meta: called CC=10 SCAR=23.6
1641 119 ▶ my $metafile = shift || ''; # for testing
Condition100%2/2
shift() || ''
l!l
4115
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
1642  
1643 119 ▶ return unless _has_cpan_meta();
Branch: 1 branch
BranchTrueFalseTotal
unless _has_cpan_meta() 26 93 119
1644  
1645 93 my $meta;
1646 93 for my $file ( $metafile, "META.json", "META.yml" ) {
1647 271 ▶ next unless -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 267 4 271
1648 4 eval {
1649 4 $meta = CPAN::Meta->load_file($file)->as_struct( { version => 2 } );
1650 };
1651 4 ▶ last if $meta;
Branch: 1 branch
BranchTrueFalseTotal
if $meta 4 0 4
1652 }
1653 93 ▶ return unless $meta;
Branch: 1 branch
BranchTrueFalseTotal
unless $meta 89 4 93
1654  
1655 # META.yml before 6.25_01 cannot be trusted. META.yml lived in the source directory.
1656 # There was a good chance the author accidentally uploaded a stale META.yml if they
1657 # rolled their own tarball rather than using "make dist".
1658 4 ▶ if ($meta->{generated_by} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($meta->{"generated_by"} and $meta->{"generated_by"} =~ /ExtUtils::MakeMaker version ([\d\._]+)/) 4 0 4
Condition33%1/3
$meta->{"generated_by"} and $meta->{"generated_by"} =~ /ExtUtils::MakeMaker version ([\d\._]+)/
!ll&&!rl&&r
004
MC/DC0%0/2
$meta->{"generated_by"} and $meta->{"generated_by"} =~ /ExtUtils::MakeMaker version ([\d\._]+)/
$meta->{"generated_by"} $meta->{"generated_by"} =~ /ExtUtils::MakeMaker version ([\d\._]+)/
Truth table33%1/3
A and B
A= $meta->{"generated_by"}B= $meta->{"generated_by"} =~ /ExtUtils::MakeMaker version ([\d\._]+)/
ABresult
0X0
100
111
1659 $meta->{generated_by} =~ /ExtUtils::MakeMaker version ([\d\._]+)/) {
1660 4 my $eummv = do { local $^W = 0; $1+0; };
1661 4 ▶ if ($eummv < 6.2501) {
Branch: 1 branch
BranchTrueFalseTotal
if ($eummv < "6.2501") 0 4 4
1662 0 return;
1663 }
1664 }
1665  
1666 4 return $meta;
1667 }
1668  
1669 =head3 write_mymeta
1670  
1671 $self->write_mymeta( $mymeta );
1672  
1673 Write MYMETA information to MYMETA.json and MYMETA.yml.
1674  
1675 =cut
1676  
1677 sub write_mymeta {
1678 116 ▶ my $self = shift;
Subroutine write_mymeta: called CC=2 SCAR=6.9
Pod documented
1679 116 my $mymeta = shift;
1680  
1681 116 ▶ return unless _has_cpan_meta();
Branch: 1 branch
BranchTrueFalseTotal
unless _has_cpan_meta() 26 90 116
1682  
1683 90 my $meta_obj = $self->_fix_metadata_before_conversion( $mymeta );
1684  
1685 90 $meta_obj->save( 'MYMETA.json', { version => "2.0" } );
1686 90 $meta_obj->save( 'MYMETA.yml', { version => "1.4" } );
1687 90 return 1;
1688 }
1689  
1690 =head3 realclean (o)
1691  
1692 Defines the realclean target.
1693  
1694 =cut
1695  
1696 sub realclean {
1697 117 ▶ my($self, %attribs) = @_;
Subroutine realclean: called CC=6 SCAR=20.4
Pod documented
1698  
1699 117 my @dirs = qw($(DISTVNAME));
1700 117 my @files = qw($(FIRST_MAKEFILE) $(MAKEFILE_OLD));
1701  
1702 # Special exception for the perl core where INST_* is not in blib.
1703 # This cleans up the files built from the ext/ directory (all XS).
1704 117 ▶ if( $self->{PERL_CORE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"PERL_CORE"}) 0 117 117
1705 0 push @dirs, qw($(INST_AUTODIR) $(INST_ARCHAUTODIR));
1706 0 push @files, values %{$self->{PM}};
1707 }
1708  
1709 117 ▶ if( $self->has_link_code ){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_link_code) 0 117 117
1710 0 push @files, qw($(OBJECT));
1711 }
1712  
1713 117 ▶ if( $attribs{FILES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attribs{"FILES"}) 0 117 117
1714 0 ▶ if( ref $attribs{FILES} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribs{'FILES'}) { } 0 0 0
1715 0 push @dirs, @{ $attribs{FILES} };
1716 }
1717 else {
1718 0 push @dirs, split /\s+/, $attribs{FILES};
1719 }
1720 }
1721  
1722 # Occasionally files are repeated several times from different sources
1723 117 { my(%f) = map { ($_ => 1) } @files; @files = sort keys %f; }
1724 117 { my(%d) = map { ($_ => 1) } @dirs; @dirs = sort keys %d; }
1725  
1726 117 my $rm_cmd = join "\n\t", map { "$_" }
1727 $self->split_command('- $(RM_F)', @files);
1728 117 my $rmf_cmd = join "\n\t", map { "$_" }
1729 $self->split_command('- $(RM_RF)', @dirs);
1730  
1731 117 my $m = sprintf <<'MAKE', $rm_cmd, $rmf_cmd;
1732 # Delete temporary files (via clean) and also delete dist files
1733 realclean purge :: realclean_subdirs
1734 %s
1735 %s
1736 MAKE
1737  
1738 117 ▶ $m .= "\t$attribs{POSTOP}\n" if $attribs{POSTOP};
Branch: 1 branch
BranchTrueFalseTotal
if $attribs{"POSTOP"} 0 117 117
1739  
1740 117 return $m;
1741 }
1742  
1743  
1744 =head3 realclean_subdirs_target
1745  
1746 my $make_frag = $MM->realclean_subdirs_target;
1747  
1748 Returns the realclean_subdirs target. This is used by the realclean
1749 target to call realclean on any subdirectories which contain Makefiles.
1750  
1751 =cut
1752  
1753 sub realclean_subdirs_target {
1754 117 ▶ my $self = shift;
Subroutine realclean_subdirs_target: called CC=4 SCAR=13.9
Pod documented
1755 117 my @m = <<'EOF';
1756 # so clean is forced to complete before realclean_subdirs runs
1757 realclean_subdirs : clean
1758 EOF
1759 117 ▶ return join '', @m, "\t\$(NOECHO) \$(NOOP)\n" unless @{$self->{DIR}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"DIR"};} 78 39 117
1760 39 foreach my $dir (@{$self->{DIR}}) {
1761 39 foreach my $makefile ('$(MAKEFILE_OLD)', '$(FIRST_MAKEFILE)' ) {
1762 78 my $subrclean .= $self->oneliner(_sprintf562 <<'CODE', $dir, $makefile);
1763 chdir '%1$s'; system '$(MAKE) $(USEMAKEFILE) %2$s realclean' if -f '%2$s';
1764 CODE
1765 78 push @m, "\t- $subrclean\n";
1766 }
1767 }
1768 39 return join '', @m;
1769 }
1770  
1771  
1772 =head3 signature_target
1773  
1774 my $target = $mm->signature_target;
1775  
1776 Generate the signature target.
1777  
1778 Writes the file SIGNATURE with "cpansign -s".
1779  
1780 =cut
1781  
1782 sub signature_target {
1783 117 ▶ my $self = shift;
Subroutine signature_target: called CC=1 SCAR=0.0
Pod documented
1784  
1785 117 return <<'MAKE_FRAG';
1786 signature :
1787 cpansign -s
1788 MAKE_FRAG
1789  
1790 }
1791  
1792  
1793 =head3 distsignature_target
1794  
1795 my $make_frag = $mm->distsignature_target;
1796  
1797 Generates the distsignature target to add SIGNATURE to the MANIFEST in the
1798 distdir.
1799  
1800 =cut
1801  
1802 sub distsignature_target {
1803 117 ▶ my $self = shift;
Subroutine distsignature_target: called CC=1 SCAR=0.0
Pod documented
1804  
1805 117 my $add_sign = $self->oneliner(<<'CODE', ['-MExtUtils::Manifest=maniadd']);
1806 eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }
1807 or die "Could not add SIGNATURE to MANIFEST: ${'@'}"
1808 CODE
1809  
1810 117 my $sign_dist = $self->cd('$(DISTVNAME)' => 'cpansign -s');
1811  
1812 # cpansign -s complains if SIGNATURE is in the MANIFEST yet does not
1813 # exist
1814 117 my $touch_sig = $self->cd('$(DISTVNAME)' => '$(TOUCH) SIGNATURE');
1815 117 my $add_sign_to_dist = $self->cd('$(DISTVNAME)' => $add_sign );
1816  
1817 117 return sprintf <<'MAKE', $add_sign_to_dist, $touch_sig, $sign_dist
1818 distsignature : distmeta
1819 $(NOECHO) %s
1820 $(NOECHO) %s
1821 %s
1822  
1823 MAKE
1824  
1825 }
1826  
1827  
1828 =head3 special_targets
1829  
1830 my $make_frag = $mm->special_targets
1831  
1832 Returns a make fragment containing any targets which have special
1833 meaning to make. For example, .SUFFIXES and .PHONY.
1834  
1835 =cut
1836  
1837 sub special_targets {
1838 117 ▶ my $make_frag = <<'MAKE_FRAG';
Subroutine special_targets: called CC=2 SCAR=7.1
Pod documented
1839 .SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
1840  
1841 .PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir pure_all subdirs clean_subdirs makemakerdflt manifypods realclean_subdirs subdirs_dynamic subdirs_pure_nolink subdirs_static subdirs-test_dynamic subdirs-test_static test_dynamic test_static
1842  
1843 MAKE_FRAG
1844  
1845 117 ▶ $make_frag .= <<'MAKE_FRAG' if $ENV{CLEARCASE_ROOT};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"CLEARCASE_ROOT"} 0 117 117
1846 .NO_CONFIG_REC: Makefile
1847  
1848 MAKE_FRAG
1849  
1850 117 return $make_frag;
1851 }
1852  
1853  
1854  
1855  
1856 =head2 Init methods
1857  
1858 Methods which help initialize the MakeMaker object and macros.
1859  
1860  
1861 =head3 init_ABSTRACT
1862  
1863 $mm->init_ABSTRACT
1864  
1865 =cut
1866  
1867 sub init_ABSTRACT {
1868 119 ▶ my $self = shift;
Subroutine init_ABSTRACT: called CC=7 SCAR=23.6
Pod documented
1869  
1870 119 ▶ if( $self->{ABSTRACT_FROM} and $self->{ABSTRACT} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ABSTRACT_FROM"} and $self->{"ABSTRACT"}) 0 119 119
Condition66%2/3
$self->{"ABSTRACT_FROM"} and $self->{"ABSTRACT"}
!ll&&!rl&&r
11810
MC/DC0%0/2
$self->{"ABSTRACT_FROM"} and $self->{"ABSTRACT"}
$self->{"ABSTRACT_FROM"} $self->{"ABSTRACT"}
Truth table66%2/3
A and B
A= $self->{"ABSTRACT_FROM"}B= $self->{"ABSTRACT"}
ABresult
0X0
100
111
1871 0 warn "Both ABSTRACT_FROM and ABSTRACT are set. ".
1872 "Ignoring ABSTRACT_FROM.\n";
1873 0 return;
1874 }
1875  
1876 119 ▶ if ($self->{ABSTRACT_FROM}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ABSTRACT_FROM"}) 1 118 119
1877 1 ▶ $self->{ABSTRACT} = $self->parse_abstract($self->{ABSTRACT_FROM}) or
Branch: 1 branch
BranchTrueFalseTotal
$self->{"ABSTRACT"} = $self->parse_abstract($self->{"ABSTRACT_FROM"}) or carp('WARNING: Setting ABSTRACT via file ' . qq['$self->{"ABSTRACT_FROM"}' failed\n]) 0 1 1
1878 carp "WARNING: Setting ABSTRACT via file ".
1879 "'$self->{ABSTRACT_FROM}' failed\n";
1880 }
1881  
1882 119 ▶ if ($self->{ABSTRACT} && $self->{ABSTRACT} =~ m![[:cntrl:]]+!) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ABSTRACT"} and $self->{"ABSTRACT"} =~ /[[:cntrl:]]+/) 0 119 119
Condition66%2/3
$self->{"ABSTRACT"} and $self->{"ABSTRACT"} =~ /[[:cntrl:]]+/
!ll&&!rl&&r
11810
MC/DC0%0/2
$self->{"ABSTRACT"} and $self->{"ABSTRACT"} =~ /[[:cntrl:]]+/
$self->{"ABSTRACT"} $self->{"ABSTRACT"} =~ /[[:cntrl:]]+/
Truth table66%2/3
A and B
A= $self->{"ABSTRACT"}B= $self->{"ABSTRACT"} =~ /[[:cntrl:]]+/
ABresult
0X0
100
111
1883 0 warn "WARNING: ABSTRACT contains control character(s),".
1884 " they will be removed\n";
1885 0 $self->{ABSTRACT} =~ s![[:cntrl:]]+!!g;
1886 0 return;
1887 }
1888 }
1889  
1890 =head3 init_INST
1891  
1892 $mm->init_INST;
1893  
1894 Called by init_main. Sets up all INST_* variables except those related
1895 to XS code. Those are handled in init_xs.
1896  
1897 =cut
1898  
1899 sub init_INST {
1900 120 ▶ my($self) = shift;
Subroutine init_INST: called CC=8 SCAR=21.4
Pod documented
1901  
1902 120 ▶ $self->{INST_ARCHLIB} ||= $self->catdir($Curdir,"blib","arch");
Condition66%2/3
$self->{"INST_ARCHLIB"} ||= $self->catdir($Curdir, "blib", "arch")
l!l&&r!l&&!r
40800
MC/DC0%0/2
$self->{"INST_ARCHLIB"} ||= $self->catdir($Curdir, "blib", "arch")
$self->{"INST_ARCHLIB"} $self->catdir($Curdir, "blib", "arch")
Truth table66%2/3
A ||= B
A= $self->{"INST_ARCHLIB"}B= $self->catdir($Curdir, "blib", "arch")
ABresult
1X1
011
000
1903 120 ▶ $self->{INST_BIN} ||= $self->catdir($Curdir,'blib','bin');
Condition66%2/3
$self->{"INST_BIN"} ||= $self->catdir($Curdir, "blib", "bin")
l!l&&r!l&&!r
40800
MC/DC0%0/2
$self->{"INST_BIN"} ||= $self->catdir($Curdir, "blib", "bin")
$self->{"INST_BIN"} $self->catdir($Curdir, "blib", "bin")
Truth table66%2/3
A ||= B
A= $self->{"INST_BIN"}B= $self->catdir($Curdir, "blib", "bin")
ABresult
1X1
011
000
1904  
1905 # INST_LIB typically pre-set if building an extension after
1906 # perl has been built and installed. Setting INST_LIB allows
1907 # you to build directly into, say $Config{privlibexp}.
1908 120 ▶ unless ($self->{INST_LIB}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"INST_LIB"}) 80 40 120
1909 80 ▶ if ($self->{PERL_CORE}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'PERL_CORE'}) { } 0 80 80
1910 0 $self->{INST_LIB} = $self->{INST_ARCHLIB} = $self->{PERL_LIB};
1911 } else {
1912 80 $self->{INST_LIB} = $self->catdir($Curdir,"blib","lib");
1913 }
1914 }
1915  
1916 120 my @parentdir = split(/::/, $self->{PARENT_NAME});
1917 120 $self->{INST_LIBDIR} = $self->catdir('$(INST_LIB)', @parentdir);
1918 120 $self->{INST_ARCHLIBDIR} = $self->catdir('$(INST_ARCHLIB)', @parentdir);
1919 120 $self->{INST_AUTODIR} = $self->catdir('$(INST_LIB)', 'auto',
1920 '$(FULLEXT)');
1921 120 $self->{INST_ARCHAUTODIR} = $self->catdir('$(INST_ARCHLIB)', 'auto',
1922 '$(FULLEXT)');
1923  
1924 120 ▶ $self->{INST_SCRIPT} ||= $self->catdir($Curdir,'blib','script');
Condition66%2/3
$self->{"INST_SCRIPT"} ||= $self->catdir($Curdir, "blib", "script")
l!l&&r!l&&!r
40800
MC/DC0%0/2
$self->{"INST_SCRIPT"} ||= $self->catdir($Curdir, "blib", "script")
$self->{"INST_SCRIPT"} $self->catdir($Curdir, "blib", "script")
Truth table66%2/3
A ||= B
A= $self->{"INST_SCRIPT"}B= $self->catdir($Curdir, "blib", "script")
ABresult
1X1
011
000
1925  
1926 120 ▶ $self->{INST_MAN1DIR} ||= $self->catdir($Curdir,'blib','man1');
Condition66%2/3
$self->{"INST_MAN1DIR"} ||= $self->catdir($Curdir, "blib", "man1")
l!l&&r!l&&!r
41790
MC/DC0%0/2
$self->{"INST_MAN1DIR"} ||= $self->catdir($Curdir, "blib", "man1")
$self->{"INST_MAN1DIR"} $self->catdir($Curdir, "blib", "man1")
Truth table66%2/3
A ||= B
A= $self->{"INST_MAN1DIR"}B= $self->catdir($Curdir, "blib", "man1")
ABresult
1X1
011
000
1927 120 ▶ $self->{INST_MAN3DIR} ||= $self->catdir($Curdir,'blib','man3');
Condition66%2/3
$self->{"INST_MAN3DIR"} ||= $self->catdir($Curdir, "blib", "man3")
l!l&&r!l&&!r
40800
MC/DC0%0/2
$self->{"INST_MAN3DIR"} ||= $self->catdir($Curdir, "blib", "man3")
$self->{"INST_MAN3DIR"} $self->catdir($Curdir, "blib", "man3")
Truth table66%2/3
A ||= B
A= $self->{"INST_MAN3DIR"}B= $self->catdir($Curdir, "blib", "man3")
ABresult
1X1
011
000
1928  
1929 120 return 1;
1930 }
1931  
1932  
1933 =head3 init_INSTALL
1934  
1935 $mm->init_INSTALL;
1936  
1937 Called by init_main. Sets up all INSTALL_* variables (except
1938 INSTALLDIRS) and *PREFIX.
1939  
1940 =cut
1941  
1942 sub init_INSTALL {
1943 119 ▶ my($self) = shift;
Subroutine init_INSTALL: called CC=4 SCAR=14.3
Pod documented
1944  
1945 119 ▶ if( $self->{ARGS}{INSTALL_BASE} and $self->{ARGS}{PREFIX} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ARGS"}{"INSTALL_BASE"} and $self->{"ARGS"}{"PREFIX"}) 0 119 119
Condition66%2/3
$self->{"ARGS"}{"INSTALL_BASE"} and $self->{"ARGS"}{"PREFIX"}
!ll&&!rl&&r
11720
MC/DC0%0/2
$self->{"ARGS"}{"INSTALL_BASE"} and $self->{"ARGS"}{"PREFIX"}
$self->{"ARGS"}{"INSTALL_BASE"} $self->{"ARGS"}{"PREFIX"}
Truth table66%2/3
A and B
A= $self->{"ARGS"}{"INSTALL_BASE"}B= $self->{"ARGS"}{"PREFIX"}
ABresult
0X0
100
111
1946 0 die "Only one of PREFIX or INSTALL_BASE can be given. Not both.\n";
1947 }
1948  
1949 119 ▶ if( $self->{ARGS}{INSTALL_BASE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'ARGS'}{'INSTALL_BASE'}) { } 2 117 119
1950 2 $self->init_INSTALL_from_INSTALL_BASE;
1951 }
1952 else {
1953 117 $self->init_INSTALL_from_PREFIX;
1954 }
1955 }
1956  
1957  
1958 =head3 init_INSTALL_from_PREFIX
1959  
1960 $mm->init_INSTALL_from_PREFIX;
1961  
1962 =cut
1963  
1964 sub init_INSTALL_from_PREFIX {
1965 117 ▶ my $self = shift;
Subroutine init_INSTALL_from_PREFIX: called CC=48 SCAR=47.6
Pod documented
1966  
1967 117 $self->init_lib2arch;
1968  
1969 # There are often no Config.pm defaults for these new man variables so
1970 # we fall back to the old behavior which is to use installman*dir
1971 117 foreach my $num (1, 3) {
1972 234 my $k = 'installsiteman'.$num.'dir';
1973  
1974 $self->{uc $k} ||= uc "\$(installman${num}dir)"
1975 234 ▶ unless $Config{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless $ExtUtils::MM_Any::Config{$k} 234 0 234
Condition66%2/3
$$self{uc $k} ||= uc "\$(installman${num}dir)"
l!l&&r!l&&!r
12330
MC/DC0%0/2
$$self{uc $k} ||= uc "\$(installman${num}dir)"
$$self{uc $k} uc "\$(installman${num}dir)"
Truth table66%2/3
A ||= B
A= $$self{uc $k}B= uc "\$(installman${num}dir)"
ABresult
1X1
011
000
1976 }
1977  
1978 117 foreach my $num (1, 3) {
1979 234 my $k = 'installvendorman'.$num.'dir';
1980  
1981 234 ▶ unless( $Config{$k} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ExtUtils::MM_Any::Config{$k}) 232 2 234
1982 $self->{uc $k} ||= $Config{usevendorprefix}
1983 232 ▶ ? uc "\$(installman${num}dir)"
Branch: 1 branch
BranchTrueFalseTotal
$ExtUtils::MM_Any::Config{'usevendorprefix'} ? : 6 225 231
Condition100%3/3
$$self{uc $k} ||= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? uc "\$(installman${num}dir)" : ""
l!l&&r!l&&!r
16225
MC/DC100%2/2
$$self{uc $k} ||= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? uc "\$(installman${num}dir)" : ""
$$self{uc $k} $ExtUtils::MM_Any::Config{"usevendorprefix"} ? uc "\$(installman${num}dir)" : ""
Truth table100%3/3
A ||= B
A= $$self{uc $k}B= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? uc "\$(installman${num}dir)" : ""
ABresult
1X1
011
000
1984 : '';
1985 }
1986 }
1987  
1988 $self->{INSTALLSITEBIN} ||= '$(INSTALLBIN)'
1989 117 ▶ unless $Config{installsitebin};
Branch: 1 branch
BranchTrueFalseTotal
unless $ExtUtils::MM_Any::Config{"installsitebin"} 0 117 117
Condition0%0/2
$self->{"INSTALLSITEBIN"} ||= "\$(INSTALLBIN)"
l!l
00
MC/DC0%0/1
$self->{"INSTALLSITEBIN"} ||= "\$(INSTALLBIN)"
$self->{"INSTALLSITEBIN"}
Truth table0%0/2
A
A= $self->{"INSTALLSITEBIN"}
Aresult
11
00
1990 $self->{INSTALLSITESCRIPT} ||= '$(INSTALLSCRIPT)'
1991 117 ▶ unless $Config{installsitescript};
Branch: 1 branch
BranchTrueFalseTotal
unless $ExtUtils::MM_Any::Config{"installsitescript"} 0 117 117
Condition0%0/2
$self->{"INSTALLSITESCRIPT"} ||= "\$(INSTALLSCRIPT)"
l!l
00
MC/DC0%0/1
$self->{"INSTALLSITESCRIPT"} ||= "\$(INSTALLSCRIPT)"
$self->{"INSTALLSITESCRIPT"}
Truth table0%0/2
A
A= $self->{"INSTALLSITESCRIPT"}
Aresult
11
00
1992  
1993 117 ▶ unless( $Config{installvendorbin} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ExtUtils::MM_Any::Config{"installvendorbin"}) 117 0 117
1994 $self->{INSTALLVENDORBIN} ||= $Config{usevendorprefix}
1995 ? $Config{installbin}
1996 117 ▶ : '';
Branch: 1 branch
BranchTrueFalseTotal
$ExtUtils::MM_Any::Config{'usevendorprefix'} ? : 4 113 117
Condition66%2/3
$self->{"INSTALLVENDORBIN"} ||= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installbin"} : ""
l!l&&r!l&&!r
04113
MC/DC50%1/2
$self->{"INSTALLVENDORBIN"} ||= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installbin"} : ""
$self->{"INSTALLVENDORBIN"} $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installbin"} : ""
Truth table66%2/3
A ||= B
A= $self->{"INSTALLVENDORBIN"}B= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installbin"} : ""
ABresult
1X1
011
000
1997 }
1998 117 ▶ unless( $Config{installvendorscript} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ExtUtils::MM_Any::Config{"installvendorscript"}) 117 0 117
1999 $self->{INSTALLVENDORSCRIPT} ||= $Config{usevendorprefix}
2000 ? $Config{installscript}
2001 117 ▶ : '';
Branch: 1 branch
BranchTrueFalseTotal
$ExtUtils::MM_Any::Config{'usevendorprefix'} ? : 4 113 117
Condition66%2/3
$self->{"INSTALLVENDORSCRIPT"} ||= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installscript"} : ""
l!l&&r!l&&!r
04113
MC/DC50%1/2
$self->{"INSTALLVENDORSCRIPT"} ||= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installscript"} : ""
$self->{"INSTALLVENDORSCRIPT"} $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installscript"} : ""
Truth table66%2/3
A ||= B
A= $self->{"INSTALLVENDORSCRIPT"}B= $ExtUtils::MM_Any::Config{"usevendorprefix"} ? $ExtUtils::MM_Any::Config{"installscript"} : ""
ABresult
1X1
011
000
2002 }
2003  
2004  
2005 my $iprefix = $Config{installprefixexp} || $Config{installprefix} ||
2006 117 ▶ $Config{prefixexp} || $Config{prefix} || '';
Condition36%4/11
$ExtUtils::MM_Any::Config{'installprefixexp'} || $ExtUtils::MM_Any::Config{'installprefix'} || $ExtUtils::MM_Any::Config{'prefixexp'} || $ExtUtils::MM_Any::Config{'prefix'} || ''
l!l
1170
$ExtUtils::MM_Any::Config{"installprefixexp"} or $ExtUtils::MM_Any::Config{"installprefix"} or $ExtUtils::MM_Any::Config{"prefixexp"} or $ExtUtils::MM_Any::Config{"prefix"}
l!l&&r!l&&!r
11700
$ExtUtils::MM_Any::Config{"installprefixexp"} or $ExtUtils::MM_Any::Config{"installprefix"} or $ExtUtils::MM_Any::Config{"prefixexp"}
l!l&&r!l&&!r
11700
$ExtUtils::MM_Any::Config{"installprefixexp"} or $ExtUtils::MM_Any::Config{"installprefix"}
l!l&&r!l&&!r
11700
MC/DC0%0/4
$ExtUtils::MM_Any::Config{'installprefixexp'} || $ExtUtils::MM_Any::Config{'installprefix'} || $ExtUtils::MM_Any::Config{'prefixexp'} || $ExtUtils::MM_Any::Config{'prefix'} || ''
$ExtUtils::MM_Any::Config{"installprefixexp"} $ExtUtils::MM_Any::Config{"installprefix"} $ExtUtils::MM_Any::Config{"prefixexp"} $ExtUtils::MM_Any::Config{"prefix"}
Truth table20%1/5
A or B or C or D
A= $ExtUtils::MM_Any::Config{"installprefixexp"}B= $ExtUtils::MM_Any::Config{"installprefix"}C= $ExtUtils::MM_Any::Config{"prefixexp"}D= $ExtUtils::MM_Any::Config{"prefix"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
2007 117 ▶ my $vprefix = $Config{usevendorprefix} ? $Config{vendorprefixexp} : '';
Branch: 1 branch
BranchTrueFalseTotal
$ExtUtils::MM_Any::Config{'usevendorprefix'} ? : 4 113 117
2008 117 ▶ my $sprefix = $Config{siteprefixexp} || '';
Condition50%1/2
$ExtUtils::MM_Any::Config{'siteprefixexp'} || ''
l!l
1170
MC/DC0%0/1
$ExtUtils::MM_Any::Config{'siteprefixexp'} || ''
$ExtUtils::MM_Any::Config{'siteprefixexp'}
Truth table50%1/2
A
A= $ExtUtils::MM_Any::Config{'siteprefixexp'}
Aresult
11
00
2009  
2010 # 5.005_03 doesn't have a siteprefix.
2011 117 ▶ $sprefix = $iprefix unless $sprefix;
Branch: 1 branch
BranchTrueFalseTotal
unless $sprefix 0 117 117
2012  
2013  
2014 117 ▶ $self->{PREFIX} ||= '';
Condition100%2/2
$self->{"PREFIX"} ||= ""
l!l
2115
MC/DC100%1/1
$self->{"PREFIX"} ||= ""
$self->{"PREFIX"}
Truth table100%2/2
A
A= $self->{"PREFIX"}
Aresult
11
00
2015  
2016 117 ▶ if( $self->{PREFIX} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'PREFIX'}) { } 2 115 117
2017 2 @{$self}{qw(PERLPREFIX SITEPREFIX VENDORPREFIX)} =
2018 ('$(PREFIX)') x 3;
2019 }
2020 else {
2021 115 ▶ $self->{PERLPREFIX} ||= $iprefix;
Condition33%1/3
$self->{"PERLPREFIX"} ||= $iprefix
l!l&&r!l&&!r
01150
MC/DC0%0/2
$self->{"PERLPREFIX"} ||= $iprefix
$self->{"PERLPREFIX"} $iprefix
Truth table33%1/3
A ||= B
A= $self->{"PERLPREFIX"}B= $iprefix
ABresult
1X1
011
000
2022 115 ▶ $self->{SITEPREFIX} ||= $sprefix;
Condition33%1/3
$self->{"SITEPREFIX"} ||= $sprefix
l!l&&r!l&&!r
01150
MC/DC0%0/2
$self->{"SITEPREFIX"} ||= $sprefix
$self->{"SITEPREFIX"} $sprefix
Truth table33%1/3
A ||= B
A= $self->{"SITEPREFIX"}B= $sprefix
ABresult
1X1
011
000
2023 115 ▶ $self->{VENDORPREFIX} ||= $vprefix;
Condition66%2/3
$self->{"VENDORPREFIX"} ||= $vprefix
l!l&&r!l&&!r
04111
MC/DC50%1/2
$self->{"VENDORPREFIX"} ||= $vprefix
$self->{"VENDORPREFIX"} $vprefix
Truth table66%2/3
A ||= B
A= $self->{"VENDORPREFIX"}B= $vprefix
ABresult
1X1
011
000
2024  
2025 # Lots of MM extension authors like to use $(PREFIX) so we
2026 # put something sensible in there no matter what.
2027 115 $self->{PREFIX} = '$('.uc $self->{INSTALLDIRS}.'PREFIX)';
2028 }
2029  
2030 117 my $arch = $Config{archname};
2031 117 my $version = $Config{version};
2032  
2033 # default style
2034 117 ▶ my $libstyle = $Config{installstyle} || 'lib/perl5';
Condition50%1/2
$ExtUtils::MM_Any::Config{'installstyle'} || 'lib/perl5'
l!l
1170
MC/DC0%0/1
$ExtUtils::MM_Any::Config{'installstyle'} || 'lib/perl5'
$ExtUtils::MM_Any::Config{'installstyle'}
Truth table50%1/2
A
A= $ExtUtils::MM_Any::Config{'installstyle'}
Aresult
11
00
2035 117 my $manstyle = '';
2036  
2037 117 ▶ if( $self->{LIBSTYLE} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LIBSTYLE"}) 0 117 117
2038 0 $libstyle = $self->{LIBSTYLE};
2039 0 ▶ $manstyle = $self->{LIBSTYLE} eq 'lib/perl5' ? 'lib/perl5' : '';
Branch: 1 branch
BranchTrueFalseTotal
$self->{'LIBSTYLE'} eq 'lib/perl5' ? : 0 0 0
2040 }
2041  
2042 # Some systems, like VOS, set installman*dir to '' if they can't
2043 # read man pages.
2044 117 for my $num (1, 3) {
2045 $self->{'INSTALLMAN'.$num.'DIR'} ||= 'none'
2046 234 ▶ unless $Config{'installman'.$num.'dir'};
Branch: 1 branch
BranchTrueFalseTotal
unless $ExtUtils::MM_Any::Config{'installman' . $num . 'dir'} 218 16 234
Condition100%2/2
$$self{'INSTALLMAN' . $num . 'DIR'} ||= "none"
l!l
5213
MC/DC100%1/1
$$self{'INSTALLMAN' . $num . 'DIR'} ||= "none"
$$self{'INSTALLMAN' . $num . 'DIR'}
Truth table100%2/2
A
A= $$self{'INSTALLMAN' . $num . 'DIR'}
Aresult
11
00
2047 }
2048  
2049 117 my %bin_layouts =
2050 (
2051 bin => { s => $iprefix,
2052 t => 'perl',
2053 d => 'bin' },
2054 vendorbin => { s => $vprefix,
2055 t => 'vendor',
2056 d => 'bin' },
2057 sitebin => { s => $sprefix,
2058 t => 'site',
2059 d => 'bin' },
2060 script => { s => $iprefix,
2061 t => 'perl',
2062 d => 'bin' },
2063 vendorscript=> { s => $vprefix,
2064 t => 'vendor',
2065 d => 'bin' },
2066 sitescript => { s => $sprefix,
2067 t => 'site',
2068 d => 'bin' },
2069 );
2070  
2071 117 my %man_layouts =
2072 (
2073 man1dir => { s => $iprefix,
2074 t => 'perl',
2075 d => 'man/man1',
2076 style => $manstyle, },
2077 siteman1dir => { s => $sprefix,
2078 t => 'site',
2079 d => 'man/man1',
2080 style => $manstyle, },
2081 vendorman1dir => { s => $vprefix,
2082 t => 'vendor',
2083 d => 'man/man1',
2084 style => $manstyle, },
2085  
2086 man3dir => { s => $iprefix,
2087 t => 'perl',
2088 d => 'man/man3',
2089 style => $manstyle, },
2090 siteman3dir => { s => $sprefix,
2091 t => 'site',
2092 d => 'man/man3',
2093 style => $manstyle, },
2094 vendorman3dir => { s => $vprefix,
2095 t => 'vendor',
2096 d => 'man/man3',
2097 style => $manstyle, },
2098 );
2099  
2100 117 my %lib_layouts =
2101 (
2102 privlib => { s => $iprefix,
2103 t => 'perl',
2104 d => '',
2105 style => $libstyle, },
2106 vendorlib => { s => $vprefix,
2107 t => 'vendor',
2108 d => '',
2109 style => $libstyle, },
2110 sitelib => { s => $sprefix,
2111 t => 'site',
2112 d => 'site_perl',
2113 style => $libstyle, },
2114  
2115 archlib => { s => $iprefix,
2116 t => 'perl',
2117 d => "$version/$arch",
2118 style => $libstyle },
2119 vendorarch => { s => $vprefix,
2120 t => 'vendor',
2121 d => "$version/$arch",
2122 style => $libstyle },
2123 sitearch => { s => $sprefix,
2124 t => 'site',
2125 d => "site_perl/$version/$arch",
2126 style => $libstyle },
2127 );
2128  
2129  
2130 # Special case for LIB.
2131 117 ▶ if( $self->{LIB} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"LIB"}) 0 117 117
2132 0 foreach my $var (keys %lib_layouts) {
2133 0 my $Installvar = uc "install$var";
2134  
2135 0 ▶ if( $var =~ /arch/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($var =~ /arch/) { } 0 0 0
2136 $self->{$Installvar} ||=
2137 0 ▶ $self->catdir($self->{LIB}, $Config{archname});
Condition0%0/3
$self->{$Installvar} ||= $self->catdir($self->{"LIB"}, $ExtUtils::MM_Any::Config{"archname"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{$Installvar} ||= $self->catdir($self->{"LIB"}, $ExtUtils::MM_Any::Config{"archname"})
$self->{$Installvar} $self->catdir($self->{"LIB"}, $ExtUtils::MM_Any::Config{"archname"})
Truth table0%0/3
A ||= B
A= $self->{$Installvar}B= $self->catdir($self->{"LIB"}, $ExtUtils::MM_Any::Config{"archname"})
ABresult
1X1
011
000
2138 }
2139 else {
2140 0 ▶ $self->{$Installvar} ||= $self->{LIB};
Condition0%0/3
$self->{$Installvar} ||= $self->{"LIB"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{$Installvar} ||= $self->{"LIB"}
$self->{$Installvar} $self->{"LIB"}
Truth table0%0/3
A ||= B
A= $self->{$Installvar}B= $self->{"LIB"}
ABresult
1X1
011
000
2141 }
2142 }
2143 }
2144  
2145 117 my %type2prefix = ( perl => 'PERLPREFIX',
2146 site => 'SITEPREFIX',
2147 vendor => 'VENDORPREFIX'
2148 );
2149  
2150 117 my %layouts = (%bin_layouts, %man_layouts, %lib_layouts);
2151 117 ▶ while( my($var, $layout) = each(%layouts) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %layouts) 2106 117 2223
2152 2106 my($s, $t, $d, $style) = @{$layout}{qw(s t d style)};
2153 2106 my $r = '$('.$type2prefix{$t}.')';
2154  
2155 2106 ▶ warn "Prefixing $var\n" if $Verbose >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $ExtUtils::MM_Any::Verbose >= 2 0 2106 2106
2156  
2157 2106 my $installvar = "install$var";
2158 2106 my $Installvar = uc $installvar;
2159 2106 ▶ next if $self->{$Installvar};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{$Installvar} 468 1638 2106
2160  
2161 1638 ▶ $d = "$style/$d" if $style;
Branch: 1 branch
BranchTrueFalseTotal
if $style 702 936 1638
2162 1638 $self->prefixify($installvar, $s, $r, $d);
2163  
2164 1638 ▶ warn " $Installvar == $self->{$Installvar}\n"
Branch: 1 branch
BranchTrueFalseTotal
if $ExtUtils::MM_Any::Verbose >= 2 0 1638 1638
2165 if $Verbose >= 2;
2166 }
2167  
2168 # Generate these if they weren't figured out.
2169 117 ▶ $self->{VENDORARCHEXP} ||= $self->{INSTALLVENDORARCH};
Condition66%2/3
$self->{"VENDORARCHEXP"} ||= $self->{"INSTALLVENDORARCH"}
l!l&&r!l&&!r
02115
MC/DC50%1/2
$self->{"VENDORARCHEXP"} ||= $self->{"INSTALLVENDORARCH"}
$self->{"VENDORARCHEXP"} $self->{"INSTALLVENDORARCH"}
Truth table66%2/3
A ||= B
A= $self->{"VENDORARCHEXP"}B= $self->{"INSTALLVENDORARCH"}
ABresult
1X1
011
000
2170 117 ▶ $self->{VENDORLIBEXP} ||= $self->{INSTALLVENDORLIB};
Condition66%2/3
$self->{"VENDORLIBEXP"} ||= $self->{"INSTALLVENDORLIB"}
l!l&&r!l&&!r
02115
MC/DC50%1/2
$self->{"VENDORLIBEXP"} ||= $self->{"INSTALLVENDORLIB"}
$self->{"VENDORLIBEXP"} $self->{"INSTALLVENDORLIB"}
Truth table66%2/3
A ||= B
A= $self->{"VENDORLIBEXP"}B= $self->{"INSTALLVENDORLIB"}
ABresult
1X1
011
000
2171  
2172 117 return 1;
2173 }
2174  
2175  
2176 =head3 init_from_INSTALL_BASE
2177  
2178 $mm->init_from_INSTALL_BASE
2179  
2180 =cut
2181  
2182 my %map = (
2183 lib => [qw(lib perl5)],
2184 50 arch => [('lib', 'perl5', $Config{archname})],
2185 bin => [qw(bin)],
2186 man1dir => [qw(man man1)],
2187 man3dir => [qw(man man3)]
2188 );
2189 50 $map{script} = $map{bin};
2190  
2191 sub init_INSTALL_from_INSTALL_BASE {
2192 2 ▶ my $self = shift;
Subroutine init_INSTALL_from_INSTALL_BASE: called CC=8 SCAR=22.7
Pod undocumented
2193  
2194 2 @{$self}{qw(PREFIX VENDORPREFIX SITEPREFIX PERLPREFIX)} =
2195 '$(INSTALL_BASE)';
2196  
2197 2 my %install;
2198 2 foreach my $thing (keys %map) {
2199 12 foreach my $dir (('', 'SITE', 'VENDOR')) {
2200 36 my $uc_thing = uc $thing;
2201 36 my $key = "INSTALL".$dir.$uc_thing;
2202  
2203 $install{$key} ||=
2204 36 ▶ $self->catdir('$(INSTALL_BASE)', @{$map{$thing}});
Condition33%1/3
$install{$key} ||= $self->catdir("\$(INSTALL_BASE)", @{$map{$thing};})
l!l&&r!l&&!r
0360
MC/DC0%0/2
$install{$key} ||= $self->catdir("\$(INSTALL_BASE)", @{$map{$thing};})
$install{$key} $self->catdir("\$(INSTALL_BASE)", @{$map{$thing};})
Truth table33%1/3
A ||= B
A= $install{$key}B= $self->catdir("\$(INSTALL_BASE)", @{$map{$thing};})
ABresult
1X1
011
000
2205 }
2206 }
2207  
2208 # Adjust for variable quirks.
2209 2 ▶ $install{INSTALLARCHLIB} ||= delete $install{INSTALLARCH};
Condition33%1/3
$install{"INSTALLARCHLIB"} ||= delete $install{"INSTALLARCH"}
l!l&&r!l&&!r
020
MC/DC0%0/2
$install{"INSTALLARCHLIB"} ||= delete $install{"INSTALLARCH"}
$install{"INSTALLARCHLIB"} delete $install{"INSTALLARCH"}
Truth table33%1/3
A ||= B
A= $install{"INSTALLARCHLIB"}B= delete $install{"INSTALLARCH"}
ABresult
1X1
011
000
2210 2 ▶ $install{INSTALLPRIVLIB} ||= delete $install{INSTALLLIB};
Condition33%1/3
$install{"INSTALLPRIVLIB"} ||= delete $install{"INSTALLLIB"}
l!l&&r!l&&!r
020
MC/DC0%0/2
$install{"INSTALLPRIVLIB"} ||= delete $install{"INSTALLLIB"}
$install{"INSTALLPRIVLIB"} delete $install{"INSTALLLIB"}
Truth table33%1/3
A ||= B
A= $install{"INSTALLPRIVLIB"}B= delete $install{"INSTALLLIB"}
ABresult
1X1
011
000
2211  
2212 2 foreach my $key (keys %install) {
2213 36 ▶ $self->{$key} ||= $install{$key};
Condition33%1/3
$self->{$key} ||= $install{$key}
l!l&&r!l&&!r
0360
MC/DC0%0/2
$self->{$key} ||= $install{$key}
$self->{$key} $install{$key}
Truth table33%1/3
A ||= B
A= $self->{$key}B= $install{$key}
ABresult
1X1
011
000
2214 }
2215  
2216 2 return 1;
2217 }
2218  
2219  
2220 =head3 init_VERSION I<Abstract>
2221  
2222 $mm->init_VERSION
2223  
2224 Initialize macros representing versions of MakeMaker and other tools
2225  
2226 MAKEMAKER: path to the MakeMaker module.
2227  
2228 MM_VERSION: ExtUtils::MakeMaker Version
2229  
2230 MM_REVISION: ExtUtils::MakeMaker version control revision (for backwards
2231 compat)
2232  
2233 VERSION: version of your module
2234  
2235 VERSION_MACRO: which macro represents the version (usually 'VERSION')
2236  
2237 VERSION_SYM: like version but safe for use as an RCS revision number
2238  
2239 DEFINE_VERSION: -D line to set the module version when compiling
2240  
2241 XS_VERSION: version in your .xs file. Defaults to $(VERSION)
2242  
2243 XS_VERSION_MACRO: which macro represents the XS version.
2244  
2245 XS_DEFINE_VERSION: -D line to set the xs version when compiling.
2246  
2247 Called by init_main.
2248  
2249 =cut
2250  
2251 sub init_VERSION {
2252 119 ▶ my($self) = shift;
Subroutine init_VERSION: called CC=8 SCAR=20.9
Pod documented
2253  
2254 119 $self->{MAKEMAKER} = $ExtUtils::MakeMaker::Filename;
2255 119 $self->{MM_VERSION} = $ExtUtils::MakeMaker::VERSION;
2256 119 $self->{MM_REVISION}= $ExtUtils::MakeMaker::Revision;
2257 119 ▶ $self->{VERSION_FROM} ||= '';
Condition100%2/2
$self->{"VERSION_FROM"} ||= ""
l!l
6059
MC/DC100%1/1
$self->{"VERSION_FROM"} ||= ""
$self->{"VERSION_FROM"}
Truth table100%2/2
A
A= $self->{"VERSION_FROM"}
Aresult
11
00
2258  
2259 119 ▶ if ($self->{VERSION_FROM}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"VERSION_FROM"}) 60 59 119
2260 60 $self->{VERSION} = $self->parse_version($self->{VERSION_FROM});
2261 60 ▶ if( $self->{VERSION} eq 'undef' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"VERSION"} eq "undef") 0 60 60
2262 0 carp("WARNING: Setting VERSION via file ".
2263 "'$self->{VERSION_FROM}' failed\n");
2264 }
2265 }
2266  
2267 119 ▶ if (defined $self->{VERSION}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'VERSION'}) { } 73 46 119
2268 73 ▶ if ( $self->{VERSION} !~ /^\s*v?[\d_\.]+\s*$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"VERSION"} =~ /^\s*v?[\d_\.]+\s*$/) 2 71 73
2269 2 require version;
2270 2 my $normal = eval { version->new( $self->{VERSION} ) };
2271 2 ▶ $self->{VERSION} = $normal if defined $normal;
Branch: 1 branch
BranchTrueFalseTotal
if defined $normal 0 2 2
2272 }
2273 73 $self->{VERSION} =~ s/^\s+//;
2274 73 $self->{VERSION} =~ s/\s+$//;
2275 }
2276 else {
2277 46 $self->{VERSION} = '';
2278 }
2279  
2280  
2281 119 $self->{VERSION_MACRO} = 'VERSION';
2282 119 ($self->{VERSION_SYM} = $self->{VERSION}) =~ s/\W/_/g;
2283 119 $self->{DEFINE_VERSION} = '-D$(VERSION_MACRO)=\"$(VERSION)\"';
2284  
2285  
2286 # Graham Barr and Paul Marquess had some ideas how to ensure
2287 # version compatibility between the *.pm file and the
2288 # corresponding *.xs file. The bottom line was, that we need an
2289 # XS_VERSION macro that defaults to VERSION:
2290 119 ▶ $self->{XS_VERSION} ||= $self->{VERSION};
Condition66%2/3
$self->{"XS_VERSION"} ||= $self->{"VERSION"}
l!l&&r!l&&!r
07247
MC/DC50%1/2
$self->{"XS_VERSION"} ||= $self->{"VERSION"}
$self->{"XS_VERSION"} $self->{"VERSION"}
Truth table66%2/3
A ||= B
A= $self->{"XS_VERSION"}B= $self->{"VERSION"}
ABresult
1X1
011
000
2291  
2292 119 $self->{XS_VERSION_MACRO} = 'XS_VERSION';
2293 119 $self->{XS_DEFINE_VERSION} = '-D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"';
2294  
2295 }
2296  
2297  
2298 =head3 init_tools
2299  
2300 $MM->init_tools();
2301  
2302 Initializes the simple macro definitions used by tools_other() and
2303 places them in the $MM object. These use conservative cross platform
2304 versions and should be overridden with platform specific versions for
2305 performance.
2306  
2307 Defines at least these macros.
2308  
2309 Macro Description
2310  
2311 NOOP Do nothing
2312 NOECHO Tell make not to display the command itself
2313  
2314 SHELL Program used to run shell commands
2315  
2316 ECHO Print text adding a newline on the end
2317 RM_F Remove a file
2318 RM_RF Remove a directory
2319 TOUCH Update a file's timestamp
2320 TEST_F Test for a file's existence
2321 TEST_S Test the size of a file
2322 CP Copy a file
2323 CP_NONEMPTY Copy a file if it is not empty
2324 MV Move a file
2325 CHMOD Change permissions on a file
2326 FALSE Exit with non-zero
2327 TRUE Exit with zero
2328  
2329 UMASK_NULL Nullify umask
2330 DEV_NULL Suppress all command output
2331  
2332 =cut
2333  
2334 sub init_tools {
2335 120 ▶ my $self = shift;
Subroutine init_tools: called CC=36 SCAR=50.0
Pod documented
2336  
2337 120 ▶ $self->{ECHO} ||= $self->oneliner('binmode STDOUT, qq{:raw}; print qq{@ARGV}', ['-l']);
Condition33%1/3
$self->{"ECHO"} ||= $self->oneliner("binmode STDOUT, qq{:raw}; print qq{\@ARGV}", ["-l"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"ECHO"} ||= $self->oneliner("binmode STDOUT, qq{:raw}; print qq{\@ARGV}", ["-l"])
$self->{"ECHO"} $self->oneliner("binmode STDOUT, qq{:raw}; print qq{\@ARGV}", ["-l"])
Truth table33%1/3
A ||= B
A= $self->{"ECHO"}B= $self->oneliner("binmode STDOUT, qq{:raw}; print qq{\@ARGV}", ["-l"])
ABresult
1X1
011
000
2338 120 ▶ $self->{ECHO_N} ||= $self->oneliner('print qq{@ARGV}');
Condition33%1/3
$self->{"ECHO_N"} ||= $self->oneliner("print qq{\@ARGV}")
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"ECHO_N"} ||= $self->oneliner("print qq{\@ARGV}")
$self->{"ECHO_N"} $self->oneliner("print qq{\@ARGV}")
Truth table33%1/3
A ||= B
A= $self->{"ECHO_N"}B= $self->oneliner("print qq{\@ARGV}")
ABresult
1X1
011
000
2339  
2340 120 ▶ $self->{TOUCH} ||= $self->oneliner('touch', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"TOUCH"} ||= $self->oneliner("touch", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"TOUCH"} ||= $self->oneliner("touch", ["-MExtUtils::Command"])
$self->{"TOUCH"} $self->oneliner("touch", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"TOUCH"}B= $self->oneliner("touch", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2341 120 ▶ $self->{CHMOD} ||= $self->oneliner('chmod', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"CHMOD"} ||= $self->oneliner("chmod", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"CHMOD"} ||= $self->oneliner("chmod", ["-MExtUtils::Command"])
$self->{"CHMOD"} $self->oneliner("chmod", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"CHMOD"}B= $self->oneliner("chmod", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2342 120 ▶ $self->{RM_F} ||= $self->oneliner('rm_f', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"RM_F"} ||= $self->oneliner("rm_f", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"RM_F"} ||= $self->oneliner("rm_f", ["-MExtUtils::Command"])
$self->{"RM_F"} $self->oneliner("rm_f", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"RM_F"}B= $self->oneliner("rm_f", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2343 120 ▶ $self->{RM_RF} ||= $self->oneliner('rm_rf', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"RM_RF"} ||= $self->oneliner("rm_rf", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"RM_RF"} ||= $self->oneliner("rm_rf", ["-MExtUtils::Command"])
$self->{"RM_RF"} $self->oneliner("rm_rf", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"RM_RF"}B= $self->oneliner("rm_rf", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2344 120 ▶ $self->{TEST_F} ||= $self->oneliner('test_f', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"TEST_F"} ||= $self->oneliner("test_f", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"TEST_F"} ||= $self->oneliner("test_f", ["-MExtUtils::Command"])
$self->{"TEST_F"} $self->oneliner("test_f", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"TEST_F"}B= $self->oneliner("test_f", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2345 120 ▶ $self->{TEST_S} ||= $self->oneliner('test_s', ["-MExtUtils::Command::MM"]);
Condition33%1/3
$self->{"TEST_S"} ||= $self->oneliner("test_s", ["-MExtUtils::Command::MM"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"TEST_S"} ||= $self->oneliner("test_s", ["-MExtUtils::Command::MM"])
$self->{"TEST_S"} $self->oneliner("test_s", ["-MExtUtils::Command::MM"])
Truth table33%1/3
A ||= B
A= $self->{"TEST_S"}B= $self->oneliner("test_s", ["-MExtUtils::Command::MM"])
ABresult
1X1
011
000
2346 120 ▶ $self->{CP_NONEMPTY} ||= $self->oneliner('cp_nonempty', ["-MExtUtils::Command::MM"]);
Condition33%1/3
$self->{"CP_NONEMPTY"} ||= $self->oneliner("cp_nonempty", ["-MExtUtils::Command::MM"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"CP_NONEMPTY"} ||= $self->oneliner("cp_nonempty", ["-MExtUtils::Command::MM"])
$self->{"CP_NONEMPTY"} $self->oneliner("cp_nonempty", ["-MExtUtils::Command::MM"])
Truth table33%1/3
A ||= B
A= $self->{"CP_NONEMPTY"}B= $self->oneliner("cp_nonempty", ["-MExtUtils::Command::MM"])
ABresult
1X1
011
000
2347 120 ▶ $self->{FALSE} ||= $self->oneliner('exit 1');
Condition33%1/3
$self->{"FALSE"} ||= $self->oneliner("exit 1")
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"FALSE"} ||= $self->oneliner("exit 1")
$self->{"FALSE"} $self->oneliner("exit 1")
Truth table33%1/3
A ||= B
A= $self->{"FALSE"}B= $self->oneliner("exit 1")
ABresult
1X1
011
000
2348 120 ▶ $self->{TRUE} ||= $self->oneliner('exit 0');
Condition33%1/3
$self->{"TRUE"} ||= $self->oneliner("exit 0")
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"TRUE"} ||= $self->oneliner("exit 0")
$self->{"TRUE"} $self->oneliner("exit 0")
Truth table33%1/3
A ||= B
A= $self->{"TRUE"}B= $self->oneliner("exit 0")
ABresult
1X1
011
000
2349  
2350 120 ▶ $self->{MKPATH} ||= $self->oneliner('mkpath', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"MKPATH"} ||= $self->oneliner("mkpath", ["-MExtUtils::Command"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"MKPATH"} ||= $self->oneliner("mkpath", ["-MExtUtils::Command"])
$self->{"MKPATH"} $self->oneliner("mkpath", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"MKPATH"}B= $self->oneliner("mkpath", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2351  
2352 120 ▶ $self->{CP} ||= $self->oneliner('cp', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"CP"} ||= $self->oneliner("cp", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"CP"} ||= $self->oneliner("cp", ["-MExtUtils::Command"])
$self->{"CP"} $self->oneliner("cp", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"CP"}B= $self->oneliner("cp", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2353 120 ▶ $self->{MV} ||= $self->oneliner('mv', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"MV"} ||= $self->oneliner("mv", ["-MExtUtils::Command"])
l!l&&r!l&&!r
12000
MC/DC0%0/2
$self->{"MV"} ||= $self->oneliner("mv", ["-MExtUtils::Command"])
$self->{"MV"} $self->oneliner("mv", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"MV"}B= $self->oneliner("mv", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2354  
2355 $self->{MOD_INSTALL} ||=
2356 120 ▶ $self->oneliner(<<'CODE', ['-MExtUtils::Install']);
Condition33%1/3
$self->{"MOD_INSTALL"} ||= $self->oneliner("install([ from_to => {\@ARGV}, verbose => '\$(VERBINST)', uninstall_shadows => '\$(UNINST)', dir_mode => '\$(PERM_DIR)' ]);\n", ["-MExtUtils::Install"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"MOD_INSTALL"} ||= $self->oneliner("install([ from_to => {\@ARGV}, verbose => '\$(VERBINST)', uninstall_shadows => '\$(UNINST)', dir_mode => '\$(PERM_DIR)' ]);\n", ["-MExtUtils::Install"])
$self->{"MOD_INSTALL"} $self->oneliner("install([ from_to => {\@ARGV}, verbose => '\$(VERBINST)', uninstall_shadows => '\$(UNINST)', dir_mode => '\$(PERM_DIR)' ]);\n", ["-MExtUtils::Install"])
Truth table33%1/3
A ||= B
A= $self->{"MOD_INSTALL"}B= $self->oneliner("install([ from_to => {\@ARGV}, verbose => '\$(VERBINST)', uninstall_shadows => '\$(UNINST)', dir_mode => '\$(PERM_DIR)' ]);\n", ["-MExtUtils::Install"])
ABresult
1X1
011
000
2357 install([ from_to => {@ARGV}, verbose => '$(VERBINST)', uninstall_shadows => '$(UNINST)', dir_mode => '$(PERM_DIR)' ]);
2358 CODE
2359 120 ▶ $self->{DOC_INSTALL} ||= $self->oneliner('perllocal_install', ["-MExtUtils::Command::MM"]);
Condition33%1/3
$self->{"DOC_INSTALL"} ||= $self->oneliner("perllocal_install", ["-MExtUtils::Command::MM"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"DOC_INSTALL"} ||= $self->oneliner("perllocal_install", ["-MExtUtils::Command::MM"])
$self->{"DOC_INSTALL"} $self->oneliner("perllocal_install", ["-MExtUtils::Command::MM"])
Truth table33%1/3
A ||= B
A= $self->{"DOC_INSTALL"}B= $self->oneliner("perllocal_install", ["-MExtUtils::Command::MM"])
ABresult
1X1
011
000
2360 120 ▶ $self->{UNINSTALL} ||= $self->oneliner('uninstall', ["-MExtUtils::Command::MM"]);
Condition33%1/3
$self->{"UNINSTALL"} ||= $self->oneliner("uninstall", ["-MExtUtils::Command::MM"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"UNINSTALL"} ||= $self->oneliner("uninstall", ["-MExtUtils::Command::MM"])
$self->{"UNINSTALL"} $self->oneliner("uninstall", ["-MExtUtils::Command::MM"])
Truth table33%1/3
A ||= B
A= $self->{"UNINSTALL"}B= $self->oneliner("uninstall", ["-MExtUtils::Command::MM"])
ABresult
1X1
011
000
2361 $self->{WARN_IF_OLD_PACKLIST} ||=
2362 120 ▶ $self->oneliner('warn_if_old_packlist', ["-MExtUtils::Command::MM"]);
Condition33%1/3
$self->{"WARN_IF_OLD_PACKLIST"} ||= $self->oneliner("warn_if_old_packlist", ["-MExtUtils::Command::MM"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"WARN_IF_OLD_PACKLIST"} ||= $self->oneliner("warn_if_old_packlist", ["-MExtUtils::Command::MM"])
$self->{"WARN_IF_OLD_PACKLIST"} $self->oneliner("warn_if_old_packlist", ["-MExtUtils::Command::MM"])
Truth table33%1/3
A ||= B
A= $self->{"WARN_IF_OLD_PACKLIST"}B= $self->oneliner("warn_if_old_packlist", ["-MExtUtils::Command::MM"])
ABresult
1X1
011
000
2363 120 ▶ $self->{FIXIN} ||= $self->oneliner('MY->fixin(shift)', ["-MExtUtils::MY"]);
Condition33%1/3
$self->{"FIXIN"} ||= $self->oneliner("MY->fixin(shift)", ["-MExtUtils::MY"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"FIXIN"} ||= $self->oneliner("MY->fixin(shift)", ["-MExtUtils::MY"])
$self->{"FIXIN"} $self->oneliner("MY->fixin(shift)", ["-MExtUtils::MY"])
Truth table33%1/3
A ||= B
A= $self->{"FIXIN"}B= $self->oneliner("MY->fixin(shift)", ["-MExtUtils::MY"])
ABresult
1X1
011
000
2364 120 ▶ $self->{EQUALIZE_TIMESTAMP} ||= $self->oneliner('eqtime', ["-MExtUtils::Command"]);
Condition33%1/3
$self->{"EQUALIZE_TIMESTAMP"} ||= $self->oneliner("eqtime", ["-MExtUtils::Command"])
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"EQUALIZE_TIMESTAMP"} ||= $self->oneliner("eqtime", ["-MExtUtils::Command"])
$self->{"EQUALIZE_TIMESTAMP"} $self->oneliner("eqtime", ["-MExtUtils::Command"])
Truth table33%1/3
A ||= B
A= $self->{"EQUALIZE_TIMESTAMP"}B= $self->oneliner("eqtime", ["-MExtUtils::Command"])
ABresult
1X1
011
000
2365  
2366 120 ▶ $self->{UNINST} ||= 0;
Condition50%1/2
$self->{"UNINST"} ||= 0
l!l
0120
MC/DC0%0/1
$self->{"UNINST"} ||= 0
$self->{"UNINST"}
Truth table50%1/2
A
A= $self->{"UNINST"}
Aresult
11
00
2367 120 ▶ $self->{VERBINST} ||= 0;
Condition50%1/2
$self->{"VERBINST"} ||= 0
l!l
0120
MC/DC0%0/1
$self->{"VERBINST"} ||= 0
$self->{"VERBINST"}
Truth table50%1/2
A
A= $self->{"VERBINST"}
Aresult
11
00
2368  
2369 120 ▶ $self->{SHELL} ||= $Config{sh};
Condition33%1/3
$self->{"SHELL"} ||= $ExtUtils::MM_Any::Config{"sh"}
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"SHELL"} ||= $ExtUtils::MM_Any::Config{"sh"}
$self->{"SHELL"} $ExtUtils::MM_Any::Config{"sh"}
Truth table33%1/3
A ||= B
A= $self->{"SHELL"}B= $ExtUtils::MM_Any::Config{"sh"}
ABresult
1X1
011
000
2370  
2371 # UMASK_NULL is not used by MakeMaker but some CPAN modules
2372 # make use of it.
2373 120 ▶ $self->{UMASK_NULL} ||= "umask 0";
Condition50%1/2
$self->{"UMASK_NULL"} ||= "umask 0"
l!l
0120
MC/DC0%0/1
$self->{"UMASK_NULL"} ||= "umask 0"
$self->{"UMASK_NULL"}
Truth table50%1/2
A
A= $self->{"UMASK_NULL"}
Aresult
11
00
2374  
2375 # Not the greatest default, but its something.
2376 120 ▶ $self->{DEV_NULL} ||= "> /dev/null 2>&1";
Condition50%1/2
$self->{"DEV_NULL"} ||= "> /dev/null 2>&1"
l!l
0120
MC/DC0%0/1
$self->{"DEV_NULL"} ||= "> /dev/null 2>&1"
$self->{"DEV_NULL"}
Truth table50%1/2
A
A= $self->{"DEV_NULL"}
Aresult
11
00
2377  
2378 120 ▶ $self->{NOOP} ||= '$(TRUE)';
Condition50%1/2
$self->{"NOOP"} ||= "\$(TRUE)"
l!l
0120
MC/DC0%0/1
$self->{"NOOP"} ||= "\$(TRUE)"
$self->{"NOOP"}
Truth table50%1/2
A
A= $self->{"NOOP"}
Aresult
11
00
2379 120 ▶ $self->{NOECHO} = '@' unless defined $self->{NOECHO};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"NOECHO"} 120 0 120
2380  
2381 120 ▶ $self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
Condition60%3/5
$self->{"FIRST_MAKEFILE"} ||= $self->{"MAKEFILE"} || "Makefile"
l!l&&r!l&&!r
11190
$self->{'MAKEFILE'} || 'Makefile'
l!l
0119
MC/DC0%0/2
$self->{"FIRST_MAKEFILE"} ||= $self->{"MAKEFILE"} || "Makefile"
$self->{"FIRST_MAKEFILE"} $self->{'MAKEFILE'}
Truth table33%1/3
A ||= B
A= $self->{"FIRST_MAKEFILE"}B= $self->{'MAKEFILE'}
ABresult
1X1
011
000
2382 120 ▶ $self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
Condition33%1/3
$self->{"MAKEFILE"} ||= $self->{"FIRST_MAKEFILE"}
l!l&&r!l&&!r
01200
MC/DC0%0/2
$self->{"MAKEFILE"} ||= $self->{"FIRST_MAKEFILE"}
$self->{"MAKEFILE"} $self->{"FIRST_MAKEFILE"}
Truth table33%1/3
A ||= B
A= $self->{"MAKEFILE"}B= $self->{"FIRST_MAKEFILE"}
ABresult
1X1
011
000
2383 120 ▶ $self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
Condition50%1/2
$self->{"MAKEFILE_OLD"} ||= $self->{"MAKEFILE"} . '.old'
l!l
0120
MC/DC0%0/1
$self->{"MAKEFILE_OLD"} ||= $self->{"MAKEFILE"} . '.old'
$self->{"MAKEFILE_OLD"}
Truth table50%1/2
A
A= $self->{"MAKEFILE_OLD"}
Aresult
11
00
2384 120 ▶ $self->{MAKE_APERL_FILE} ||= $self->{MAKEFILE}.'.aperl';
Condition50%1/2
$self->{"MAKE_APERL_FILE"} ||= $self->{"MAKEFILE"} . '.aperl'
l!l
0120
MC/DC0%0/1
$self->{"MAKE_APERL_FILE"} ||= $self->{"MAKEFILE"} . '.aperl'
$self->{"MAKE_APERL_FILE"}
Truth table50%1/2
A
A= $self->{"MAKE_APERL_FILE"}
Aresult
11
00
2385  
2386 # Not everybody uses -f to indicate "use this Makefile instead"
2387 120 ▶ $self->{USEMAKEFILE} ||= '-f';
Condition50%1/2
$self->{"USEMAKEFILE"} ||= "-f"
l!l
0120
MC/DC0%0/1
$self->{"USEMAKEFILE"} ||= "-f"
$self->{"USEMAKEFILE"}
Truth table50%1/2
A
A= $self->{"USEMAKEFILE"}
Aresult
11
00
2388  
2389 # Some makes require a wrapper around macros passed in on the command
2390 # line.
2391 120 ▶ $self->{MACROSTART} ||= '';
Condition50%1/2
$self->{"MACROSTART"} ||= ""
l!l
0120
MC/DC0%0/1
$self->{"MACROSTART"} ||= ""
$self->{"MACROSTART"}
Truth table50%1/2
A
A= $self->{"MACROSTART"}
Aresult
11
00
2392 120 ▶ $self->{MACROEND} ||= '';
Condition50%1/2
$self->{"MACROEND"} ||= ""
l!l
0120
MC/DC0%0/1
$self->{"MACROEND"} ||= ""
$self->{"MACROEND"}
Truth table50%1/2
A
A= $self->{"MACROEND"}
Aresult
11
00
2393  
2394 120 return;
2395 }
2396  
2397  
2398 =head3 init_others
2399  
2400 $MM->init_others();
2401  
2402 Initializes the macro definitions having to do with compiling and
2403 linking used by tools_other() and places them in the $MM object.
2404  
2405 If there is no description, its the same as the parameter to
2406 WriteMakefile() documented in ExtUtils::MakeMaker.
2407  
2408 =cut
2409  
2410 sub init_others {
2411 119 ▶ my $self = shift;
Subroutine init_others: called CC=19 SCAR=40.3
Pod documented
2412  
2413 119 $self->{LD_RUN_PATH} = "";
2414  
2415 119 $self->{LIBS} = $self->_fix_libs($self->{LIBS});
2416  
2417 # Compute EXTRALIBS, BSLOADLIBS and LDLOADLIBS from $self->{LIBS}
2418 118 foreach my $libs ( @{$self->{LIBS}} ){
2419 119 $libs =~ s/^\s*(.*\S)\s*$/$1/; # remove leading and trailing whitespace
2420 119 my(@libs) = $self->extliblist($libs);
2421 119 ▶ if ($libs[0] or $libs[1] or $libs[2]){
Branch: 1 branch
BranchTrueFalseTotal
if ($libs[0] or $libs[1] or $libs[2]) 0 119 119
Condition33%2/6
$libs[0] or $libs[1] or $libs[2]
l!l&&r!l&&!r
00119
$libs[0] or $libs[1]
l!l&&r!l&&!r
00119
MC/DC0%0/3
$libs[0] or $libs[1] or $libs[2]
$libs[0] $libs[1] $libs[2]
Truth table25%1/4
A or B or C
A= $libs[0]B= $libs[1]C= $libs[2]
ABCresult
1XX1
01X1
0011
0000
2422 # LD_RUN_PATH now computed by ExtUtils::Liblist
2423 ($self->{EXTRALIBS}, $self->{BSLOADLIBS},
2424 0 $self->{LDLOADLIBS}, $self->{LD_RUN_PATH}) = @libs;
2425 0 last;
2426 }
2427 }
2428  
2429 118 ▶ if ( $self->{OBJECT} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'OBJECT'}) { } 0 118 118
elsif ($self->{'MAGICXS'} || $self->{'XSMULTI'} and @{$self->{'O_FILES'} or [];}) { } 0 118 118
2430 0 ▶ $self->{OBJECT} = join(" ", @{$self->{OBJECT}}) if ref $self->{OBJECT};
Branch: 1 branch
BranchTrueFalseTotal
if ref $self->{"OBJECT"} 0 0 0
2431 0 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
2432 0 ▶ } elsif ( ($self->{MAGICXS} || $self->{XSMULTI}) && @{$self->{O_FILES}||[]} ) {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"O_FILES"} or [] 0 0 0
Condition33%2/6
$self->{"MAGICXS"} || $self->{"XSMULTI"} and @{$self->{"O_FILES"} or [];}
!ll&&!rl&&r
11800
$self->{"MAGICXS"} or $self->{"XSMULTI"}
l!l&&r!l&&!r
00118
MC/DC0%0/3
$self->{"MAGICXS"} || $self->{"XSMULTI"} and @{$self->{"O_FILES"} or [];}
$self->{"MAGICXS"} $self->{"XSMULTI"} @{$self->{"O_FILES"} or [];}
Truth table20%1/5
A or B and C
A= $self->{"MAGICXS"}B= $self->{"XSMULTI"}C= @{$self->{"O_FILES"} or [];}
ABCresult
00X0
1X00
0100
1X11
0111
2433 0 $self->{OBJECT} = join(" ", @{$self->{O_FILES}});
2434 0 $self->{OBJECT} =~ s!\.o(bj)?\b!\$(OBJ_EXT)!g;
2435 } else {
2436 # init_dirscan should have found out, if we have C files
2437 118 $self->{OBJECT} = "";
2438 118 ▶ $self->{OBJECT} = '$(BASEEXT)$(OBJ_EXT)' if @{$self->{C}||[]};
Branch: 2 branches
BranchTrueFalseTotal
if @{$self->{"C"} or [];} 0 118 118
$self->{"C"} or [] 0 118 118
2439 }
2440 118 $self->{OBJECT} =~ s/\n+/ \\\n\t/g;
2441  
2442 118 ▶ $self->{BOOTDEP} = (-f "$self->{BASEEXT}_BS") ? "$self->{BASEEXT}_BS" : "";
Branch: 1 branch
BranchTrueFalseTotal
-f "$self->{'BASEEXT'}_BS" ? : 0 118 118
2443 118 ▶ $self->{PERLMAINCC} ||= '$(CC)';
Condition50%1/2
$self->{"PERLMAINCC"} ||= "\$(CC)"
l!l
0118
MC/DC0%0/1
$self->{"PERLMAINCC"} ||= "\$(CC)"
$self->{"PERLMAINCC"}
Truth table50%1/2
A
A= $self->{"PERLMAINCC"}
Aresult
11
00
2444 118 ▶ $self->{LDFROM} = '$(OBJECT)' unless $self->{LDFROM};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"LDFROM"} 118 0 118
2445  
2446 # Sanity check: don't define LINKTYPE = dynamic if we're skipping
2447 # the 'dynamic' section of MM. We don't have this problem with
2448 # 'static', since we either must use it (%Config says we can't
2449 # use dynamic loading) or the caller asked for it explicitly.
2450 118 ▶ if (!$self->{LINKTYPE}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"LINKTYPE"}) 78 40 118
2451 $self->{LINKTYPE} = $self->{SKIPHASH}{'dynamic'}
2452 ? 'static'
2453 78 ▶ : ($Config{usedl} ? 'dynamic' : 'static');
Branch: 2 branches
BranchTrueFalseTotal
$self->{'SKIPHASH'}{'dynamic'} ? : 0 78 78
$ExtUtils::MM_Any::Config{'usedl'} ? : 78 0 78
2454 }
2455  
2456 118 return;
2457 }
2458  
2459  
2460 # Lets look at $self->{LIBS} carefully: It may be an anon array, a string or
2461 # undefined. In any case we turn it into an anon array
2462 sub _fix_libs {
2463 127 ▶ my($self, $libs) = @_;
Subroutine _fix_libs: called CC=4 SCAR=13.9
2464  
2465 127 ▶ return !defined $libs ? [''] :
Branch: 3 branches
BranchTrueFalseTotal
!defined($libs) ? : 116 11 127
!ref($libs) ? : 4 7 11
!defined($libs->[0]) ? : 1 5 6
2466 !ref $libs ? [$libs] :
2467 !defined $libs->[0] ? [''] :
2468 $libs ;
2469 }
2470  
2471  
2472 =head3 tools_other
2473  
2474 my $make_frag = $MM->tools_other;
2475  
2476 Returns a make fragment containing definitions for the macros init_others()
2477 initializes.
2478  
2479 =cut
2480  
2481 sub tools_other {
2482 117 ▶ my($self) = shift;
Subroutine tools_other: called CC=3 SCAR=11.0
Pod documented
2483 117 my @m;
2484  
2485 # We set PM_FILTER as late as possible so it can see all the earlier
2486 # on macro-order sensitive makes such as nmake.
2487 117 for my $tool (qw{ SHELL CHMOD CP MV NOOP NOECHO RM_F RM_RF TEST_F TOUCH
2488 UMASK_NULL DEV_NULL MKPATH EQUALIZE_TIMESTAMP
2489 FALSE TRUE
2490 ECHO ECHO_N
2491 UNINST VERBINST
2492 MOD_INSTALL DOC_INSTALL UNINSTALL
2493 WARN_IF_OLD_PACKLIST
2494 MACROSTART MACROEND
2495 USEMAKEFILE
2496 PM_FILTER
2497 FIXIN
2498 CP_NONEMPTY
2499 } )
2500 {
2501 3510 ▶ next unless defined $self->{$tool};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{$tool} 117 3393 3510
2502 3393 push @m, "$tool = $self->{$tool}\n";
2503 }
2504  
2505 117 return join "", @m;
2506 }
2507  
2508  
2509 =head3 init_DIRFILESEP I<Abstract>
2510  
2511 $MM->init_DIRFILESEP;
2512 my $dirfilesep = $MM->{DIRFILESEP};
2513  
2514 Initializes the DIRFILESEP macro which is the separator between the
2515 directory and filename in a filepath. ie. / on Unix, \ on Win32 and
2516 nothing on VMS.
2517  
2518 For example:
2519  
2520 # instead of $(INST_ARCHAUTODIR)/extralibs.ld
2521 $(INST_ARCHAUTODIR)$(DIRFILESEP)extralibs.ld
2522  
2523 Something of a hack but it prevents a lot of code duplication between
2524 MM_* variants.
2525  
2526 Do not use this as a separator between directories. Some operating
2527 systems use different separators between subdirectories as between
2528 directories and filenames (for example: VOLUME:[dir1.dir2]file on VMS).
2529  
2530 =head3 init_linker I<Abstract>
2531  
2532 $mm->init_linker;
2533  
2534 Initialize macros which have to do with linking.
2535  
2536 PERL_ARCHIVE: path to libperl.a equivalent to be linked to dynamic
2537 extensions.
2538  
2539 PERL_ARCHIVE_AFTER: path to a library which should be put on the
2540 linker command line I<after> the external libraries to be linked to
2541 dynamic extensions. This may be needed if the linker is one-pass, and
2542 Perl includes some overrides for C RTL functions, such as malloc().
2543  
2544 EXPORT_LIST: name of a file that is passed to linker to define symbols
2545 to be exported.
2546  
2547 Some OSes do not need these in which case leave it blank.
2548  
2549  
2550 =head3 init_platform
2551  
2552 $mm->init_platform
2553  
2554 Initialize any macros which are for platform specific use only.
2555  
2556 A typical one is the version number of your OS specific module.
2557 (ie. MM_Unix_VERSION or MM_VMS_VERSION).
2558  
2559 =cut
2560  
2561 sub init_platform {
2562 0 ▶ return '';
Subroutine init_platform: not called CC=1 SCAR=6.9
Pod documented
2563 }
2564  
2565  
2566 =head3 init_MAKE
2567  
2568 $mm->init_MAKE
2569  
2570 Initialize MAKE from either a MAKE environment variable or $Config{make}.
2571  
2572 =cut
2573  
2574 sub init_MAKE {
2575 119 ▶ my $self = shift;
Subroutine init_MAKE: called CC=3 SCAR=14.2
Pod documented
2576  
2577 119 ▶ $self->{MAKE} ||= $ENV{MAKE} || $Config{make};
Condition33%2/6
$self->{"MAKE"} ||= $ENV{"MAKE"} || $ExtUtils::MM_Any::Config{"make"}
l!l&&r!l&&!r
01190
$ENV{'MAKE'} || $ExtUtils::MM_Any::Config{'make'}
l!l&&r!l&&!r
01190
MC/DC0%0/3
$self->{"MAKE"} ||= $ENV{"MAKE"} || $ExtUtils::MM_Any::Config{"make"}
$self->{"MAKE"} $ENV{'MAKE'} $ExtUtils::MM_Any::Config{'make'}
Truth table0%0/4
A ||= B || C
A= $self->{"MAKE"}B= $ENV{'MAKE'}C= $ExtUtils::MM_Any::Config{'make'}
ABCresult
1XX1
01X1
0011
0000
2578 }
2579  
2580  
2581 =head2 Tools
2582  
2583 A grab bag of methods to generate specific macros and commands.
2584  
2585  
2586  
2587 =head3 manifypods
2588  
2589 Defines targets and routines to translate the pods into manpages and
2590 put them into the INST_* directories.
2591  
2592 =cut
2593  
2594 sub manifypods {
2595 117 ▶ my $self = shift;
Subroutine manifypods: called CC=1 SCAR=0.0
Pod documented
2596  
2597 117 my $POD2MAN_macro = $self->POD2MAN_macro();
2598 117 my $manifypods_target = $self->manifypods_target();
2599  
2600 117 return <<END_OF_TARGET;
2601  
2602 $POD2MAN_macro
2603  
2604 $manifypods_target
2605  
2606 END_OF_TARGET
2607  
2608 }
2609  
2610  
2611 =head3 POD2MAN_macro
2612  
2613 my $pod2man_macro = $self->POD2MAN_macro
2614  
2615 Returns a definition for the POD2MAN macro. This is a program
2616 which emulates the pod2man utility. You can add more switches to the
2617 command by simply appending them on the macro.
2618  
2619 Typical usage:
2620  
2621 $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) podfile1 man_page1 ...
2622  
2623 =cut
2624  
2625 sub POD2MAN_macro {
2626 117 ▶ my $self = shift;
Subroutine POD2MAN_macro: called CC=1 SCAR=0.0
Pod documented
2627  
2628 # Need the trailing '--' so perl stops gobbling arguments and - happens
2629 # to be an alternative end of line separator on VMS so we quote it
2630 117 return <<'END_OF_DEF';
2631 POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
2632 POD2MAN = $(POD2MAN_EXE)
2633 END_OF_DEF
2634 }
2635  
2636  
2637 =head3 test_via_harness
2638  
2639 my $command = $mm->test_via_harness($perl, $tests);
2640  
2641 Returns a $command line which runs the given set of $tests with
2642 Test::Harness and the given $perl.
2643  
2644 Used on the t/*.t files.
2645  
2646 =cut
2647  
2648 sub test_via_harness {
2649 158 ▶ my($self, $perl, $tests) = @_;
Subroutine test_via_harness: called CC=1 SCAR=0.0
Pod documented
2650  
2651 158 return qq{\t$perl "-MExtUtils::Command::MM" "-MTest::Harness" }.
2652 qq{"-e" "undef *Test::Harness::Switches; test_harness(\$(TEST_VERBOSE), '\$(INST_LIB)', '\$(INST_ARCHLIB)')" $tests\n};
2653 }
2654  
2655 =head3 test_via_script
2656  
2657 my $command = $mm->test_via_script($perl, $script);
2658  
2659 Returns a $command line which just runs a single test without
2660 Test::Harness. No checks are done on the results, they're just
2661 printed.
2662  
2663 Used for test.pl, since they don't always follow Test::Harness
2664 formatting.
2665  
2666 =cut
2667  
2668 sub test_via_script {
2669 236 ▶ my($self, $perl, $script) = @_;
Subroutine test_via_script: called CC=1 SCAR=0.0
Pod documented
2670 236 return qq{\t$perl "-I\$(INST_LIB)" "-I\$(INST_ARCHLIB)" $script\n};
2671 }
2672  
2673  
2674 =head3 tool_autosplit
2675  
2676 Defines a simple perl call that runs autosplit. May be deprecated by
2677 pm_to_blib soon.
2678  
2679 =cut
2680  
2681 sub tool_autosplit {
2682 117 ▶ my($self, %attribs) = @_;
Subroutine tool_autosplit: called CC=2 SCAR=7.0
Pod documented
2683  
2684 117 ▶ my $maxlen = $attribs{MAXLEN} ? '$$AutoSplit::Maxlen=$attribs{MAXLEN};'
Branch: 1 branch
BranchTrueFalseTotal
$attribs{'MAXLEN'} ? : 0 117 117
2685 : '';
2686  
2687 117 my $asplit = $self->oneliner(sprintf <<'PERL_CODE', $maxlen);
2688 use AutoSplit; %s autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)
2689 PERL_CODE
2690  
2691 117 return sprintf <<'MAKE_FRAG', $asplit;
2692 # Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
2693 AUTOSPLITFILE = %s
2694  
2695 MAKE_FRAG
2696  
2697 }
2698  
2699  
2700 =head3 arch_check
2701  
2702 my $arch_ok = $mm->arch_check(
2703 $INC{"Config.pm"},
2704 File::Spec->catfile($Config{archlibexp}, "Config.pm")
2705 );
2706  
2707 A sanity check that what Perl thinks the architecture is and what
2708 Config thinks the architecture is are the same. If they're not it
2709 will return false and show a diagnostic message.
2710  
2711 When building Perl it will always return true, as nothing is installed
2712 yet.
2713  
2714 The interface is a bit odd because this is the result of a
2715 quick refactoring. Don't rely on it.
2716  
2717 =cut
2718  
2719 sub arch_check {
2720 123 ▶ my $self = shift;
Subroutine arch_check: called CC=4 SCAR=13.9
Pod documented
2721 123 my($pconfig, $cconfig) = @_;
2722  
2723 123 ▶ return 1 if $self->{PERL_SRC};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"PERL_SRC"} 1 122 123
2724  
2725 122 my($pvol, $pthinks) = $self->splitpath($pconfig);
2726 122 my($cvol, $cthinks) = $self->splitpath($cconfig);
2727  
2728 122 $pthinks = $self->canonpath($pthinks);
2729 122 $cthinks = $self->canonpath($cthinks);
2730  
2731 122 my $ret = 1;
2732 122 ▶ if ($pthinks ne $cthinks) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pthinks ne $cthinks) 2 120 122
2733 2 print "Have $pthinks\n";
2734 2 print "Want $cthinks\n";
2735  
2736 2 $ret = 0;
2737  
2738 2 my $arch = (grep length, $self->splitdir($pthinks))[-1];
2739  
2740 2 ▶ print <<END unless $self->{UNINSTALLED_PERL};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"UNINSTALLED_PERL"} 1 1 2
2741 Your perl and your Config.pm seem to have different ideas about the
2742 architecture they are running on.
2743 Perl thinks: [$arch]
2744 Config says: [$Config{archname}]
2745 This may or may not cause problems. Please check your installation of perl
2746 if you have problems building this extension.
2747 END
2748 }
2749  
2750 122 return $ret;
2751 }
2752  
2753  
2754  
2755 =head2 File::Spec wrappers
2756  
2757 ExtUtils::MM_Any is a subclass of File::Spec. The methods noted here
2758 override File::Spec.
2759  
2760  
2761  
2762 =head3 catfile
2763  
2764 File::Spec <= 0.83 has a bug where the file part of catfile is not
2765 canonicalized. This override fixes that bug.
2766  
2767 =cut
2768  
2769 sub catfile {
2770 2874 ▶ my $self = shift;
Subroutine catfile: called CC=1 SCAR=0.0
Pod documented
2771 2874 return $self->canonpath($self->SUPER::catfile(@_));
2772 }
2773  
2774  
2775  
2776 =head2 Misc
2777  
2778 Methods I can't really figure out where they should go yet.
2779  
2780  
2781 =head3 find_tests
2782  
2783 my $test = $mm->find_tests;
2784  
2785 Returns a string suitable for feeding to the shell to return all
2786 tests in t/*.t.
2787  
2788 =cut
2789  
2790 sub find_tests {
2791 79 ▶ my($self) = shift;
Subroutine find_tests: called CC=2 SCAR=7.2
Pod documented
2792 79 ▶ return -d 't' ? 't/*.t' : '';
Branch: 1 branch
BranchTrueFalseTotal
-d 't' ? : 79 0 79
2793 }
2794  
2795 =head3 find_tests_recursive
2796  
2797 my $tests = $mm->find_tests_recursive;
2798  
2799 Returns a string suitable for feeding to the shell to return all
2800 tests in t/ but recursively. Equivalent to
2801  
2802 my $tests = $mm->find_tests_recursive_in('t');
2803  
2804 =cut
2805  
2806 sub find_tests_recursive {
2807 0 ▶ my $self = shift;
Subroutine find_tests_recursive: not called CC=1 SCAR=6.9
Pod documented
2808 0 return $self->find_tests_recursive_in('t');
2809 }
2810  
2811 =head3 find_tests_recursive_in
2812  
2813 my $tests = $mm->find_tests_recursive_in($dir);
2814  
2815 Returns a string suitable for feeding to the shell to return all
2816 tests in $dir recursively.
2817  
2818 =cut
2819  
2820 sub find_tests_recursive_in {
2821 0 ▶ my($self, $dir) = @_;
Subroutine find_tests_recursive_in: not called CC=2 SCAR=17.9
Pod documented
2822 0 ▶ return '' unless -d $dir;
Branch: 1 branch
BranchTrueFalseTotal
unless -d $dir 0 0 0
2823  
2824 0 require File::Find;
2825  
2826 0 my $base_depth = grep { $_ ne '' } File::Spec->splitdir( (File::Spec->splitpath($dir))[1] );
2827 0 my %depths;
2828  
2829 my $wanted = sub {
2830 0 ▶ return unless m!\.t$!;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless /\.t$/ 0 0 0
2831 0 my ($volume,$directories,$file) =
2832 File::Spec->splitpath( $File::Find::name );
2833 0 my $depth = grep { $_ ne '' } File::Spec->splitdir( $directories );
2834 0 $depth -= $base_depth;
2835 0 $depths{ $depth } = 1;
2836 0 };
2837  
2838 0 File::Find::find( $wanted, $dir );
2839  
2840 return join ' ',
2841 0 map { $dir . '/*' x $_ . '.t' }
2842 0 sort { $a <=> $b }
2843 keys %depths;
2844 }
2845  
2846 =head3 extra_clean_files
2847  
2848 my @files_to_clean = $MM->extra_clean_files;
2849  
2850 Returns a list of OS specific files to be removed in the clean target in
2851 addition to the usual set.
2852  
2853 =cut
2854  
2855 # An empty method here tickled a perl 5.8.1 bug and would return its object.
2856 sub extra_clean_files {
2857 117 ▶ return;
Subroutine extra_clean_files: called CC=1 SCAR=0.0
Pod documented
2858 }
2859  
2860  
2861 =head3 installvars
2862  
2863 my @installvars = $mm->installvars;
2864  
2865 A list of all the INSTALL* variables without the INSTALL prefix. Useful
2866 for iteration or building related variable sets.
2867  
2868 =cut
2869  
2870 sub installvars {
2871 237 ▶ return qw(PRIVLIB SITELIB VENDORLIB
Subroutine installvars: called CC=1 SCAR=0.0
Pod documented
2872 ARCHLIB SITEARCH VENDORARCH
2873 BIN SITEBIN VENDORBIN
2874 SCRIPT SITESCRIPT VENDORSCRIPT
2875 MAN1DIR SITEMAN1DIR VENDORMAN1DIR
2876 MAN3DIR SITEMAN3DIR VENDORMAN3DIR
2877 );
2878 }
2879  
2880  
2881 =head3 libscan
2882  
2883 my $wanted = $self->libscan($path);
2884  
2885 Takes a path to a file or dir and returns an empty string if we don't
2886 want to include this file in the library. Otherwise it returns the
2887 the $path unchanged.
2888  
2889 Mainly used to exclude version control administrative directories from
2890 installation.
2891  
2892 =cut
2893  
2894 sub libscan {
2895 687 ▶ my($self,$path) = @_;
Subroutine libscan: called CC=2 SCAR=6.9
Pod documented
2896 687 my($dirs,$file) = ($self->splitpath($path))[1,2];
2897 687 ▶ return '' if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/,
Branch: 1 branch
BranchTrueFalseTotal
if grep /^(?:RCS|CVS|SCCS|\.svn|_darcs)$/, $self->splitdir($dirs), $file 4 683 687
2898 $self->splitdir($dirs), $file;
2899  
2900 683 return $path;
2901 }
2902  
2903  
2904 =head3 platform_constants
2905  
2906 my $make_frag = $mm->platform_constants
2907  
2908 Returns a make fragment defining all the macros initialized in
2909 init_platform() rather than put them in constants().
2910  
2911 =cut
2912  
2913 sub platform_constants {
2914 0 ▶ return '';
Subroutine platform_constants: not called CC=1 SCAR=6.9
Pod documented
2915 }
2916  
2917 =head3 post_constants (o)
2918  
2919 Returns an empty string per default. Dedicated to overrides from
2920 within Makefile.PL after all constants have been defined.
2921  
2922 =cut
2923  
2924 sub post_constants {
2925 118 ▶ "";
Subroutine post_constants: called CC=1 SCAR=0.0
Pod documented
2926 }
2927  
2928 =head3 post_initialize (o)
2929  
2930 Returns an empty string per default. Used in Makefile.PLs to add some
2931 chunk of text to the Makefile after the object is initialized.
2932  
2933 =cut
2934  
2935 sub post_initialize {
2936 119 ▶ "";
Subroutine post_initialize: called CC=1 SCAR=0.0
Pod documented
2937 }
2938  
2939 =head3 postamble (o)
2940  
2941 Returns an empty string. Can be used in Makefile.PLs to write some
2942 text to the Makefile at the end.
2943  
2944 =cut
2945  
2946 sub postamble {
2947 117 ▶ "";
Subroutine postamble: called CC=1 SCAR=0.0
Pod documented
2948 }
2949  
2950 =begin private
2951  
2952 =head3 _PREREQ_PRINT
2953  
2954 $self->_PREREQ_PRINT;
2955  
2956 Implements PREREQ_PRINT.
2957  
2958 Refactored out of MakeMaker->new().
2959  
2960 =end private
2961  
2962 =cut
2963  
2964 sub _PREREQ_PRINT {
2965 0 ▶ my $self = shift;
Subroutine _PREREQ_PRINT: not called CC=3 SCAR=24.8
2966  
2967 0 require Data::Dumper;
2968 0 my @what = ('PREREQ_PM');
2969 0 ▶ push @what, 'MIN_PERL_VERSION' if $self->{MIN_PERL_VERSION};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"MIN_PERL_VERSION"} 0 0 0
2970 0 ▶ push @what, 'BUILD_REQUIRES' if $self->{BUILD_REQUIRES};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"BUILD_REQUIRES"} 0 0 0
2971 0 print Data::Dumper->Dump([@{$self}{@what}], \@what);
2972 0 exit 0;
2973 }
2974  
2975  
2976 =begin private
2977  
2978 =head3 _PRINT_PREREQ
2979  
2980 $mm->_PRINT_PREREQ;
2981  
2982 Implements PRINT_PREREQ, a slightly different version of PREREQ_PRINT
2983 added by Redhat to, I think, support generating RPMs from Perl modules.
2984  
2985 Should not include BUILD_REQUIRES as RPMs do not include them.
2986  
2987 Refactored out of MakeMaker->new().
2988  
2989 =end private
2990  
2991 =cut
2992  
2993 sub _PRINT_PREREQ {
2994 0 ▶ my $self = shift;
Subroutine _PRINT_PREREQ: not called CC=2 SCAR=17.9
2995  
2996 0 my $prereqs= $self->{PREREQ_PM};
2997 0 my @prereq = map { [$_, $prereqs->{$_}] } keys %$prereqs;
2998  
2999 0 ▶ if ( $self->{MIN_PERL_VERSION} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"MIN_PERL_VERSION"}) 0 0 0
3000 0 push @prereq, ['perl' => $self->{MIN_PERL_VERSION}];
3001 }
3002  
3003 0 print join(" ", map { "perl($_->[0])>=$_->[1] " }
3004 0 sort { $a->[0] cmp $b->[0] } @prereq), "\n";
3005 0 exit 0;
3006 }
3007  
3008  
3009 =begin private
3010  
3011 =head3 _perl_header_files
3012  
3013 my $perl_header_files= $self->_perl_header_files;
3014  
3015 returns a sorted list of header files as found in PERL_SRC or $archlibexp/CORE.
3016  
3017 Used by perldepend() in MM_Unix and MM_VMS via _perl_header_files_fragment()
3018  
3019 =end private
3020  
3021 =cut
3022  
3023 sub _perl_header_files {
3024 0 ▶ my $self = shift;
Subroutine _perl_header_files: not called CC=4 SCAR=30.0
3025  
3026 0 ▶ my $header_dir = $self->{PERL_SRC} || $ENV{PERL_SRC} || $self->catdir($Config{archlibexp}, 'CORE');
Condition0%0/6
$self->{'PERL_SRC'} || $ENV{'PERL_SRC'} || $self->catdir($ExtUtils::MM_Any::Config{'archlibexp'}, 'CORE')
l!l&&r!l&&!r
000
$self->{"PERL_SRC"} or $ENV{"PERL_SRC"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->{'PERL_SRC'} || $ENV{'PERL_SRC'} || $self->catdir($ExtUtils::MM_Any::Config{'archlibexp'}, 'CORE')
$self->{"PERL_SRC"} $ENV{"PERL_SRC"} $self->catdir($ExtUtils::MM_Any::Config{'archlibexp'}, 'CORE')
Truth table0%0/4
A or B || C
A= $self->{"PERL_SRC"}B= $ENV{"PERL_SRC"}C= $self->catdir($ExtUtils::MM_Any::Config{'archlibexp'}, 'CORE')
ABCresult
1XX1
01X1
0011
0000
3027 0 ▶ opendir my $dh, $header_dir
Branch: 1 branch
BranchTrueFalseTotal
opendir my $dh, $header_dir or die "Failed to opendir '${header_dir}' to find header files: $!" 0 0 0
3028 or die "Failed to opendir '$header_dir' to find header files: $!";
3029  
3030 # we need to use a temporary here as the sort in scalar context would have undefined results.
3031 0 my @perl_headers= sort grep { /\.h\z/ } readdir($dh);
3032  
3033 0 closedir $dh;
3034  
3035 0 return @perl_headers;
3036 }
3037  
3038 =begin private
3039  
3040 =head3 _perl_header_files_fragment ($o, $separator)
3041  
3042 my $perl_header_files_fragment= $self->_perl_header_files_fragment("/");
3043  
3044 return a Makefile fragment which holds the list of perl header files which
3045 XS code depends on $(PERL_INC), and sets up the dependency for the $(OBJECT) file.
3046  
3047 The $separator argument defaults to "". MM_VMS will set it to "" and MM_UNIX to "/"
3048 in perldepend(). This reason child subclasses need to control this is that in
3049 VMS the $(PERL_INC) directory will already have delimiters in it, but in
3050 UNIX $(PERL_INC) will need a slash between it an the filename. Hypothetically
3051 win32 could use "\\" (but it doesn't need to).
3052  
3053 =end private
3054  
3055 =cut
3056  
3057 sub _perl_header_files_fragment {
3058 0 ▶ my ($self, $separator)= @_;
Subroutine _perl_header_files_fragment: not called CC=2 SCAR=17.9
3059 0 ▶ $separator ||= "";
Condition0%0/2
$separator ||= ""
l!l
00
MC/DC0%0/1
$separator ||= ""
$separator
Truth table0%0/2
A
A= $separator
Aresult
11
00
3060 return join("\\\n",
3061 "PERL_HDRS = ",
3062 map {
3063 0 sprintf( " \$(PERL_INCDEP)%s%s ", $separator, $_ )
3064 } $self->_perl_header_files()
3065 ) . "\n\n"
3066 . "\$(OBJECT) : \$(PERL_HDRS)\n";
3067 }
3068  
3069  
3070 =head1 AUTHOR
3071  
3072 Michael G Schwern <schwern@pobox.com> and the denizens of
3073 makemaker@perl.org with code from ExtUtils::MM_Unix and
3074 ExtUtils::MM_Win32.
3075  
3076  
3077 =cut
3078  
3079 50 1;
« lib/ExtUtils/Command/MM.pm ↑ Summary lib/ExtUtils/MM_Cygwin.pm »