File Coverage

lib/ExtUtils/Mkbootstrap.pm
Criterion Covered Total %
statement 43 43 100.0
branch 16 18 88.8
condition 5 6 83.3
subroutine 5 5 100.0
pod 0 1 0.0
total 69 73 94.5


line stmt bran cond sub pod time code
1             package ExtUtils::Mkbootstrap;
2              
3 2     2   56459 use strict;
  2         5  
  2         96  
4 2     2   13 use warnings;
  2         5  
  2         370  
5              
6             our $VERSION = '7.78';
7             $VERSION =~ tr/_//d;
8              
9             require Exporter;
10             our @ISA = ('Exporter');
11             our @EXPORT = ('&Mkbootstrap');
12              
13 2     2   16 use Config;
  2         5  
  2         486  
14              
15             our $Verbose = 0;
16              
17              
18             sub Mkbootstrap {
19 7     7 0 164290 my($baseext, @bsloadlibs)=@_;
20 7         22 @bsloadlibs = grep($_, @bsloadlibs); # strip empty libs
21              
22 7 100       44 print " bsloadlibs=@bsloadlibs\n" if $Verbose;
23              
24             # We need DynaLoader here because we and/or the *_BS file may
25             # call dl_findfile(). We don't say `use' here because when
26             # first building perl extensions the DynaLoader will not have
27             # been built when MakeMaker gets first used.
28 7         68 require DynaLoader;
29              
30 7 100       290 rename "$baseext.bs", "$baseext.bso"
31             if -s "$baseext.bs";
32              
33 7 100       246 if (-f "${baseext}_BS"){
34 1         4 $_ = "${baseext}_BS";
35             package DynaLoader; # execute code as if in DynaLoader
36 2     2   15 no strict 'vars';
  2         5  
  2         1300  
37 1         4 local($osname, $dlsrc) = (); # avoid warnings
38 1         31 ($osname, $dlsrc) = @Config::Config{qw(osname dlsrc)};
39 1         5 $bscode = "";
40 1         3 unshift @INC, ".";
41 1         254 require $_;
42 1         21 shift @INC;
43             }
44              
45 7         22 my(@all) = (@bsloadlibs, @DynaLoader::dl_resolve_using);
46 7         14 my($method) = '';
47 7 100 66     43 if (@all || (defined $DynaLoader::bscode && length $DynaLoader::bscode)){
      100        
48 3 50       296 open my $bs, ">", "$baseext.bs"
49             or die "Unable to open $baseext.bs: $!";
50 3         25 print "Writing $baseext.bs\n";
51 3 100       30 print " containing: @all" if $Verbose;
52 3         47 print $bs "# $baseext DynaLoader bootstrap file for $^O architecture.\n";
53 3         8 print $bs "# Do not edit this file, changes will be lost.\n";
54 3         5 print $bs "# This file was automatically generated by the\n";
55 3         872 print $bs "# Mkbootstrap routine in ExtUtils::Mkbootstrap (v$VERSION).\n";
56 3 50       10 if (@all) {
57 3         6 print $bs "\@DynaLoader::dl_resolve_using = ";
58             # If @all contains names in the form -lxxx or -Lxxx then it's asking for
59             # runtime library location so we automatically add a call to dl_findfile()
60 3 100       15 if (" @all" =~ m/ -[lLR]/){
61 1         3 print $bs " dl_findfile(qw(\n @all\n ));\n";
62             } else {
63 2         4 print $bs " qw(@all);\n";
64             }
65             }
66             # write extra code if *_BS says so
67 3 100       9 print $bs $DynaLoader::bscode if $DynaLoader::bscode;
68 3         3 print $bs "\n1;\n";
69 3         286 close $bs;
70             }
71             }
72              
73             1;
74              
75             __END__