Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.1 KiB

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