lib/ExtUtils/MM_Any.pm

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