This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate change #9028 from maintperl into mainline.
[perl5.git] / lib / ExtUtils / MM_OS2.pm
CommitLineData
1e44e2bf
PP
1package ExtUtils::MM_OS2;
2
b75c8c73
MS
3use strict;
4
5our $VERSION = '1.00';
6
1e44e2bf
PP
7#use Config;
8#use Cwd;
9#use File::Basename;
10require Exporter;
11
b75c8c73
MS
12require ExtUtils::MakeMaker;
13ExtUtils::MakeMaker->import(qw( $Verbose &neatvalue));
1e44e2bf 14
1e44e2bf
PP
15unshift @MM::ISA, 'ExtUtils::MM_OS2';
16
17sub dlsyms {
18 my($self,%attribs) = @_;
19
20 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
21 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
762efda7 22 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
1e44e2bf
PP
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; \\
3cfae81b
IZ
32 Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ',
33 '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ',
34 '"INSTALLDIRS" => "$(INSTALLDIRS)", ',
35 '"DL_FUNCS" => ',neatvalue($funcs),
017f25f1 36 ', "FUNCLIST" => ',neatvalue($funclist),
1e44e2bf 37 ', "IMPORTS" => ',neatvalue($imports),
3cfae81b 38 ', "DL_VARS" => ', neatvalue($vars), ');\'
1e44e2bf
PP
39');
40 }
659f4fc5 41 if ($self->{IMPORTS} && %{$self->{IMPORTS}}) {
017f25f1
IZ
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 }
1e44e2bf
PP
58 join('',@m);
59}
60
017f25f1
IZ
61sub static_lib {
62 my($self) = @_;
63 my $old = $self->ExtUtils::MM_Unix::static_lib();
659f4fc5 64 return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}};
017f25f1
IZ
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) $@
71EOC
72 return join "\n\n". '', @chunks;
73}
74
1e44e2bf
PP
75sub replace_manpage_separator {
76 my($self,$man) = @_;
77 $man =~ s,/+,.,g;
78 $man;
79}
80
81sub maybe_command {
82 my($self,$file) = @_;
13bc20ff 83 $file =~ s,[/\\]+,/,g;
1e44e2bf
PP
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
90sub file_name_is_absolute {
91 my($self,$file) = @_;
92 $file =~ m{^([a-z]:)?[\\/]}i ;
93}
94
68dc0745
PP
95sub perl_archive
96{
97 return "\$(PERL_INC)/libperl\$(LIB_EXT)";
98}
99
100sub export_list
101{
102 my ($self) = @_;
103 return "$self->{BASEEXT}.def";
104}
105
1e44e2bf
PP
1061;
107__END__
108
109=head1 NAME
110
111ExtUtils::MM_OS2 - methods to override UN*X behaviour in ExtUtils::MakeMaker
112
a5f75d66
AD
113=head1 SYNOPSIS
114
115 use ExtUtils::MM_OS2; # Done internally by ExtUtils::MakeMaker if needed
116
1e44e2bf
PP
117=head1 DESCRIPTION
118
119See ExtUtils::MM_Unix for a documentation of the methods provided
120there. This package overrides the implementation of these methods, not
121the semantics.
122