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