home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / ExtUtils / Mkbootstrap.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  2.7 KB  |  96 lines

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