| 1 |
package ExtUtils::Mkbootstrap; |
| 2 |
|
| 3 |
$VERSION = 1.15; |
| 4 |
|
| 5 |
use Config; |
| 6 |
use Exporter; |
| 7 |
@ISA=('Exporter'); |
| 8 |
@EXPORT='&Mkbootstrap'; |
| 9 |
|
| 10 |
sub Mkbootstrap { |
| 11 |
my($baseext, @bsloadlibs)=@_; |
| 12 |
@bsloadlibs = grep($_, @bsloadlibs); # strip empty libs |
| 13 |
|
| 14 |
print STDOUT " bsloadlibs=@bsloadlibs\n" if $Verbose; |
| 15 |
|
| 16 |
# We need DynaLoader here because we and/or the *_BS file may |
| 17 |
# call dl_findfile(). We don't say `use' here because when |
| 18 |
# first building perl extensions the DynaLoader will not have |
| 19 |
# been built when MakeMaker gets first used. |
| 20 |
require DynaLoader; |
| 21 |
|
| 22 |
rename "$baseext.bs", "$baseext.bso" |
| 23 |
if -s "$baseext.bs"; |
| 24 |
|
| 25 |
if (-f "${baseext}_BS"){ |
| 26 |
$_ = "${baseext}_BS"; |
| 27 |
package DynaLoader; # execute code as if in DynaLoader |
| 28 |
local($osname, $dlsrc) = (); # avoid warnings |
| 29 |
($osname, $dlsrc) = @Config::Config{qw(osname dlsrc)}; |
| 30 |
$bscode = ""; |
| 31 |
unshift @INC, "."; |
| 32 |
require $_; |
| 33 |
shift @INC; |
| 34 |
} |
| 35 |
|
| 36 |
if ($Config{'dlsrc'} =~ /^dl_dld/){ |
| 37 |
package DynaLoader; |
| 38 |
push(@dl_resolve_using, dl_findfile('-lc')); |
| 39 |
} |
| 40 |
|
| 41 |
my(@all) = (@bsloadlibs, @DynaLoader::dl_resolve_using); |
| 42 |
my($method) = ''; |
| 43 |
if (@all){ |
| 44 |
open BS, ">$baseext.bs" |
| 45 |
or die "Unable to open $baseext.bs: $!"; |
| 46 |
print STDOUT "Writing $baseext.bs\n"; |
| 47 |
print STDOUT " containing: @all" if $Verbose; |
| 48 |
print BS "# $baseext DynaLoader bootstrap file for $^O architecture.\n"; |
| 49 |
print BS "# Do not edit this file, changes will be lost.\n"; |
| 50 |
print BS "# This file was automatically generated by the\n"; |
| 51 |
print BS "# Mkbootstrap routine in ExtUtils::Mkbootstrap (v$VERSION).\n"; |
| 52 |
print BS "\@DynaLoader::dl_resolve_using = "; |
| 53 |
# If @all contains names in the form -lxxx or -Lxxx then it's asking for |
| 54 |
# runtime library location so we automatically add a call to dl_findfile() |
| 55 |
if (" @all" =~ m/ -[lLR]/){ |
| 56 |
print BS " dl_findfile(qw(\n @all\n ));\n"; |
| 57 |
}else{ |
| 58 |
print BS " qw(@all);\n"; |
| 59 |
} |
| 60 |
# write extra code if *_BS says so |
| 61 |
print BS $DynaLoader::bscode if $DynaLoader::bscode; |
| 62 |
print BS "\n1;\n"; |
| 63 |
close BS; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
1; |
| 68 |
|
| 69 |
__END__ |
| 70 |
|
| 71 |
=head1 NAME |
| 72 |
|
| 73 |
ExtUtils::Mkbootstrap - make a bootstrap file for use by DynaLoader |
| 74 |
|
| 75 |
=head1 SYNOPSIS |
| 76 |
|
| 77 |
C<Mkbootstrap> |
| 78 |
|
| 79 |
=head1 DESCRIPTION |
| 80 |
|
| 81 |
Mkbootstrap typically gets called from an extension Makefile. |
| 82 |
|
| 83 |
There is no C<*.bs> file supplied with the extension. Instead, there may |
| 84 |
be a C<*_BS> file which has code for the special cases, like posix for |
| 85 |
berkeley db on the NeXT. |
| 86 |
|
| 87 |
This file will get parsed, and produce a maybe empty |
| 88 |
C<@DynaLoader::dl_resolve_using> array for the current architecture. |
| 89 |
That will be extended by $BSLOADLIBS, which was computed by |
| 90 |
ExtUtils::Liblist::ext(). If this array still is empty, we do nothing, |
| 91 |
else we write a .bs file with an C<@DynaLoader::dl_resolve_using> |
| 92 |
array. |
| 93 |
|
| 94 |
The C<*_BS> file can put some code into the generated C<*.bs> file by |
| 95 |
placing it in C<$bscode>. This is a handy 'escape' mechanism that may |
| 96 |
prove useful in complex situations. |
| 97 |
|
| 98 |
If @DynaLoader::dl_resolve_using contains C<-L*> or C<-l*> entries then |
| 99 |
Mkbootstrap will automatically add a dl_findfile() call to the |
| 100 |
generated C<*.bs> file. |
| 101 |
|
| 102 |
=cut |