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.

134 lines
3.7 KiB

  1. package ExtUtils::MM_OS2;
  2. #use Config;
  3. #use Cwd;
  4. #use File::Basename;
  5. require Exporter;
  6. Exporter::import('ExtUtils::MakeMaker',
  7. qw( $Verbose &neatvalue));
  8. unshift @MM::ISA, 'ExtUtils::MM_OS2';
  9. sub dlsyms {
  10. my($self,%attribs) = @_;
  11. my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
  12. my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
  13. my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
  14. my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
  15. my(@m);
  16. (my $boot = $self->{NAME}) =~ s/:/_/g;
  17. if (not $self->{SKIPHASH}{'dynamic'}) {
  18. push(@m,"
  19. $self->{BASEEXT}.def: Makefile.PL
  20. ",
  21. ' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
  22. Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ',
  23. '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ',
  24. '"INSTALLDIRS" => "$(INSTALLDIRS)", ',
  25. '"DL_FUNCS" => ',neatvalue($funcs),
  26. ', "FUNCLIST" => ',neatvalue($funclist),
  27. ', "IMPORTS" => ',neatvalue($imports),
  28. ', "DL_VARS" => ', neatvalue($vars), ');\'
  29. ');
  30. }
  31. if (%{$self->{IMPORTS}}) {
  32. # Make import files (needed for static build)
  33. -d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp";
  34. open IMP, '>tmpimp.imp' or die "Can't open tmpimp.imp";
  35. my ($name, $exp);
  36. while (($name, $exp)= each %{$self->{IMPORTS}}) {
  37. my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'";
  38. print IMP "$name $lib $id ?\n";
  39. }
  40. close IMP or die "Can't close tmpimp.imp";
  41. # print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n";
  42. system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp"
  43. and die "Cannot make import library: $!, \$?=$?";
  44. unlink <tmp_imp/*>;
  45. system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}"
  46. and die "Cannot extract import objects: $!, \$?=$?";
  47. }
  48. join('',@m);
  49. }
  50. sub static_lib {
  51. my($self) = @_;
  52. my $old = $self->ExtUtils::MM_Unix::static_lib();
  53. return $old unless %{$self->{IMPORTS}};
  54. my @chunks = split /\n{2,}/, $old;
  55. shift @chunks unless length $chunks[0]; # Empty lines at the start
  56. $chunks[0] .= <<'EOC';
  57. $(AR) $(AR_STATIC_ARGS) $@ tmp_imp/* && $(RANLIB) $@
  58. EOC
  59. return join "\n\n". '', @chunks;
  60. }
  61. sub replace_manpage_separator {
  62. my($self,$man) = @_;
  63. $man =~ s,/+,.,g;
  64. $man;
  65. }
  66. sub maybe_command {
  67. my($self,$file) = @_;
  68. $file =~ s,[/\\]+,/,g;
  69. return $file if -x $file && ! -d _;
  70. return "$file.exe" if -x "$file.exe" && ! -d _;
  71. return "$file.cmd" if -x "$file.cmd" && ! -d _;
  72. return;
  73. }
  74. sub file_name_is_absolute {
  75. my($self,$file) = @_;
  76. $file =~ m{^([a-z]:)?[\\/]}i ;
  77. }
  78. sub perl_archive
  79. {
  80. return "\$(PERL_INC)/libperl\$(LIB_EXT)";
  81. }
  82. =item perl_archive_after
  83. This is an internal method that returns path to a library which
  84. should be put on the linker command line I<after> the external libraries
  85. to be linked to dynamic extensions. This may be needed if the linker
  86. is one-pass, and Perl includes some overrides for C RTL functions,
  87. such as malloc().
  88. =cut
  89. sub perl_archive_after
  90. {
  91. return "\$(PERL_INC)/libperl_override\$(LIB_EXT)" unless $OS2::is_aout;
  92. return "";
  93. }
  94. sub export_list
  95. {
  96. my ($self) = @_;
  97. return "$self->{BASEEXT}.def";
  98. }
  99. 1;
  100. __END__
  101. =head1 NAME
  102. ExtUtils::MM_OS2 - methods to override UN*X behaviour in ExtUtils::MakeMaker
  103. =head1 SYNOPSIS
  104. use ExtUtils::MM_OS2; # Done internally by ExtUtils::MakeMaker if needed
  105. =head1 DESCRIPTION
  106. See ExtUtils::MM_Unix for a documentation of the methods provided
  107. there. This package overrides the implementation of these methods, not
  108. the semantics.