This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
SIGRTMAX, SIGRTMIN, LDBL_MAX, LDBL_MIN, LDBL_EPSILON and HUGE_VAL
[perl5.git] / lib / ExtUtils / MM_OS2.pm
CommitLineData
1e44e2bf 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
7292dc67 9$VERSION = '1.05';
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
7292dc67 35=item init_dist
479d2113
MS
36
37Define TO_UNIX to convert OS2 linefeeds to Unix style.
38
bbc7dcd2
MS
39=cut
40
479d2113
MS
41sub init_dist {
42 my($self) = @_;
f6d6199c 43
479d2113 44 $self->{TO_UNIX} ||= <<'MAKE_TEXT';
dedf98bc 45$(NOECHO) $(TEST_F) tmp.zip && $(RM_F) tmp.zip; $(ZIP) -ll -mr tmp.zip $(DISTVNAME) && unzip -o tmp.zip && $(RM_F) tmp.zip
f6d6199c
MS
46MAKE_TEXT
47
479d2113 48 $self->SUPER::init_dist;
f6d6199c
MS
49}
50
1e44e2bf 51sub dlsyms {
52 my($self,%attribs) = @_;
53
54 my($funcs) = $attribs{DL_FUNCS} || $self->{DL_FUNCS} || {};
55 my($vars) = $attribs{DL_VARS} || $self->{DL_VARS} || [];
762efda7 56 my($funclist) = $attribs{FUNCLIST} || $self->{FUNCLIST} || [];
1e44e2bf 57 my($imports) = $attribs{IMPORTS} || $self->{IMPORTS} || {};
58 my(@m);
59 (my $boot = $self->{NAME}) =~ s/:/_/g;
60
61 if (not $self->{SKIPHASH}{'dynamic'}) {
62 push(@m,"
63$self->{BASEEXT}.def: Makefile.PL
64",
65 ' $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -e \'use ExtUtils::Mksymlists; \\
3cfae81b
IZ
66 Mksymlists("NAME" => "$(NAME)", "DLBASE" => "$(DLBASE)", ',
67 '"VERSION" => "$(VERSION)", "DISTNAME" => "$(DISTNAME)", ',
68 '"INSTALLDIRS" => "$(INSTALLDIRS)", ',
69 '"DL_FUNCS" => ',neatvalue($funcs),
017f25f1 70 ', "FUNCLIST" => ',neatvalue($funclist),
1e44e2bf 71 ', "IMPORTS" => ',neatvalue($imports),
3cfae81b 72 ', "DL_VARS" => ', neatvalue($vars), ');\'
1e44e2bf 73');
74 }
659f4fc5 75 if ($self->{IMPORTS} && %{$self->{IMPORTS}}) {
017f25f1
IZ
76 # Make import files (needed for static build)
77 -d 'tmp_imp' or mkdir 'tmp_imp', 0777 or die "Can't mkdir tmp_imp";
78 open IMP, '>tmpimp.imp' or die "Can't open tmpimp.imp";
79 my ($name, $exp);
80 while (($name, $exp)= each %{$self->{IMPORTS}}) {
81 my ($lib, $id) = ($exp =~ /(.*)\.(.*)/) or die "Malformed IMPORT `$exp'";
82 print IMP "$name $lib $id ?\n";
83 }
84 close IMP or die "Can't close tmpimp.imp";
85 # print "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp\n";
86 system "emximp -o tmpimp$Config::Config{lib_ext} tmpimp.imp"
87 and die "Cannot make import library: $!, \$?=$?";
88 unlink <tmp_imp/*>;
89 system "cd tmp_imp; $Config::Config{ar} x ../tmpimp$Config::Config{lib_ext}"
90 and die "Cannot extract import objects: $!, \$?=$?";
91 }
1e44e2bf 92 join('',@m);
93}
94
017f25f1
IZ
95sub static_lib {
96 my($self) = @_;
97 my $old = $self->ExtUtils::MM_Unix::static_lib();
659f4fc5 98 return $old unless $self->{IMPORTS} && %{$self->{IMPORTS}};
017f25f1
IZ
99
100 my @chunks = split /\n{2,}/, $old;
101 shift @chunks unless length $chunks[0]; # Empty lines at the start
102 $chunks[0] .= <<'EOC';
103
104 $(AR) $(AR_STATIC_ARGS) $@ tmp_imp/* && $(RANLIB) $@
105EOC
106 return join "\n\n". '', @chunks;
107}
108
1e44e2bf 109sub replace_manpage_separator {
110 my($self,$man) = @_;
111 $man =~ s,/+,.,g;
112 $man;
113}
114
115sub maybe_command {
116 my($self,$file) = @_;
13bc20ff 117 $file =~ s,[/\\]+,/,g;
1e44e2bf 118 return $file if -x $file && ! -d _;
119 return "$file.exe" if -x "$file.exe" && ! -d _;
120 return "$file.cmd" if -x "$file.cmd" && ! -d _;
121 return;
122}
123
479d2113 124=item init_linker
68dc0745 125
479d2113 126=cut
5ba48348 127
479d2113
MS
128sub init_linker {
129 my $self = shift;
5ba48348 130
479d2113 131 $self->{PERL_ARCHIVE} = "\$(PERL_INC)/libperl\$(LIB_EXT)";
5ba48348 132
ad2f23df
JH
133 $self->{PERL_ARCHIVE_AFTER} = $OS2::is_aout
134 ? ''
135 : '$(PERL_INC)/libperl_override$(LIB_EXT)';
479d2113 136 $self->{EXPORT_LIST} = '$(BASEEXT).def';
68dc0745 137}
138
dedf98bc
MS
139=item os_flavor
140
141OS/2 is OS/2
142
143=cut
144
145sub os_flavor {
146 return('OS/2');
147}
148
bbc7dcd2 149=back
1e44e2bf 150
bbc7dcd2 151=cut
479d2113
MS
152
1531;