File Coverage

lib/ExtUtils/Mkbootstrap.pm
Criterion Covered Total %
statement 37 38 97.4
branch 17 18 94.4
condition n/a
subroutine 3 3 100.0
total 57 59 96.6


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