1 package ExtUtils::Mkbootstrap;
3 # There's just too much Dynaloader incest here to turn on strict vars.
6 our $VERSION = '6.49_01';
9 our @ISA = ('Exporter');
10 our @EXPORT = ('&Mkbootstrap');
18 my($baseext, @bsloadlibs)=@_;
19 @bsloadlibs = grep($_, @bsloadlibs); # strip empty libs
21 print STDOUT " bsloadlibs=@bsloadlibs\n" if $Verbose;
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.
29 rename "$baseext.bs", "$baseext.bso"
32 if (-f "${baseext}_BS"){
34 package DynaLoader; # execute code as if in DynaLoader
35 local($osname, $dlsrc) = (); # avoid warnings
36 ($osname, $dlsrc) = @Config::Config{qw(osname dlsrc)};
43 if ($Config{'dlsrc'} =~ /^dl_dld/){
45 push(@dl_resolve_using, dl_findfile('-lc'));
48 my(@all) = (@bsloadlibs, @DynaLoader::dl_resolve_using);
51 open my $bs, ">", "$baseext.bs"
52 or die "Unable to open $baseext.bs: $!";
53 print STDOUT "Writing $baseext.bs\n";
54 print STDOUT " containing: @all" if $Verbose;
55 print $bs "# $baseext DynaLoader bootstrap file for $^O architecture.\n";
56 print $bs "# Do not edit this file, changes will be lost.\n";
57 print $bs "# This file was automatically generated by the\n";
58 print $bs "# Mkbootstrap routine in ExtUtils::Mkbootstrap (v$VERSION).\n";
59 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 if (" @all" =~ m/ -[lLR]/){
63 print $bs " dl_findfile(qw(\n @all\n ));\n";
65 print $bs " qw(@all);\n";
67 # write extra code if *_BS says so
68 print $bs $DynaLoader::bscode if $DynaLoader::bscode;
80 ExtUtils::Mkbootstrap - make a bootstrap file for use by DynaLoader
88 Mkbootstrap typically gets called from an extension Makefile.
90 There is no C<*.bs> file supplied with the extension. Instead, there may
91 be a C<*_BS> file which has code for the special cases, like posix for
92 berkeley db on the NeXT.
94 This file will get parsed, and produce a maybe empty
95 C<@DynaLoader::dl_resolve_using> array for the current architecture.
96 That will be extended by $BSLOADLIBS, which was computed by
97 ExtUtils::Liblist::ext(). If this array still is empty, we do nothing,
98 else we write a .bs file with an C<@DynaLoader::dl_resolve_using>
101 The C<*_BS> file can put some code into the generated C<*.bs> file by
102 placing it in C<$bscode>. This is a handy 'escape' mechanism that may
103 prove useful in complex situations.
105 If @DynaLoader::dl_resolve_using contains C<-L*> or C<-l*> entries then
106 Mkbootstrap will automatically add a dl_findfile() call to the
107 generated C<*.bs> file.