This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make hv_notallowed a static as suggested by Nicholas Clark;
[perl5.git] / lib / ExtUtils / MM_OS2.pm
1 package ExtUtils::MM_OS2;
2
3 use strict;
4 use vars qw($VERSION @ISA);
5
6 use ExtUtils::MakeMaker qw(neatvalue);
7 use File::Spec;
8
9 $VERSION = '1.02_01';
10
11 require ExtUtils::MM_Any;
12 require ExtUtils::MM_Unix;
13 @ISA = qw(ExtUtils::MM_Any ExtUtils::MM_Unix);
14
15 =pod
16
17 =head1 NAME
18
19 ExtUtils::MM_OS2 - methods to override UN*X behaviour in ExtUtils::MakeMaker
20
21 =head1 SYNOPSIS
22
23  use ExtUtils::MM_OS2; # Done internally by ExtUtils::MakeMaker if needed
24
25 =head1 DESCRIPTION
26
27 See ExtUtils::MM_Unix for a documentation of the methods provided
28 there. This package overrides the implementation of these methods, not
29 the semantics.
30
31 =head1 METHODS
32
33 =over 4
34
35 =cut
36
37 sub dist {
38     my($self, %attribs) = @_;
39
40     $attribs{TO_UNIX} ||= sprintf <<'MAKE_TEXT', $self->{NOECHO};
41 %s$(TEST_F) tmp.zip && $(RM) tmp.zip; \\
42 $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM) tmp.zip
43 MAKE_TEXT
44
45     return $self->SUPER::dist(%attribs);
46 }
47
48 sub dlsyms {
49     my($self,%attribs) = @_;
50
51     my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
52     my($vars)  = $attribs{DL_VARS} || $self->{DL_VARS} || [];
53     my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
54     my($imports)  = $attribs{IMPORTS} || $self->{IMPORTS} || {};
55     my(@m);
56     (my $boot = $self->{NAME}) =~ s/:/_/g;
57
58     if (not $self->{SKIPHASH}{'dynamic'}) {
59         push(@m,"
60 $self->{BASEEXT}.def: Makefile.PL
61 ",
62      '  $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
63      Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ',
64      '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ',
65      '"INSTALLDIRS" => "$(INSTALLDIRS)", ',
66      '"DL_FUNCS" => ',neatvalue($funcs),
67      ', "FUNCLIST" => ',neatvalue($funclist),
68      ', "IMPORTS" => ',neatvalue($imports),
69      ', "DL_VARS" => ', neatvalue($vars), ');\'
70 ');
71     }
72     if ($self->{IMPORTS} && %{$self->{IMPORTS}}) {
73         # Make import files (needed for static build)
74         -d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp";
75         open IMP, '>tmpimp.imp' or die "Can't open tmpimp.imp";
76         my ($name, $exp);
77         while (($name, $exp)= each %{$self->{IMPORTS}}) {
78             my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'";
79             print IMP "$name $lib $id ?\n";
80         }
81         close IMP or die "Can't close tmpimp.imp";
82         # print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n";
83         system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp" 
84             and die "Cannot make import library: $!, \$?=$?";
85         unlink <tmp_imp/*>;
86         system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}" 
87             and die "Cannot extract import objects: $!, \$?=$?";      
88     }
89     join('',@m);
90 }
91
92 sub static_lib {
93     my($self) = @_;
94     my $old = $self->ExtUtils::MM_Unix::static_lib();
95     return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}};
96     
97     my @chunks = split /\n{2,}/, $old;
98     shift @chunks unless length $chunks[0]; # Empty lines at the start
99     $chunks[0] .= <<'EOC';
100
101         $(AR) $(AR_STATIC_ARGS) $@ tmp_imp/* && $(RANLIB) $@
102 EOC
103     return join "\n\n". '', @chunks;
104 }
105
106 sub replace_manpage_separator {
107     my($self,$man) = @_;
108     $man =~ s,/+,.,g;
109     $man;
110 }
111
112 sub maybe_command {
113     my($self,$file) = @_;
114     $file =~ s,[/\\]+,/,g;
115     return $file if -x $file && ! -d _;
116     return "$file.exe" if -x "$file.exe" && ! -d _;
117     return "$file.cmd" if -x "$file.cmd" && ! -d _;
118     return;
119 }
120
121 sub perl_archive {
122     return "\$(PERL_INC)/libperl\$(LIB_EXT)";
123 }
124
125 =item perl_archive_after
126
127 This is an internal method that returns path to a library which
128 should be put on the linker command line I<after> the external libraries
129 to be linked to dynamic extensions.  This may be needed if the linker
130 is one-pass, and Perl includes some overrides for C RTL functions,
131 such as malloc().
132
133 =cut 
134
135 sub perl_archive_after
136 {
137  return "\$(PERL_INC)/libperl_override\$(LIB_EXT)" unless $OS2::is_aout;
138  return "";
139 }
140
141 sub export_list
142 {
143  my ($self) = @_;
144  return "$self->{BASEEXT}.def";
145 }
146
147 1;
148
149 __END__
150
151 =pod
152
153 =back
154
155 =cut