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