This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Import Encode-2.92 from CPAN
[perl5.git] / dist / ExtUtils-CBuilder / lib / ExtUtils / CBuilder / Platform / os2.pm
CommitLineData
6b09c160 1package ExtUtils::CBuilder::Platform::os2;
a83beb43 2$ExtUtils::CBuilder::Platform::os2::VERSION = '0.280226';
83dcc064 3use warnings;
6b09c160
YST
4use strict;
5use ExtUtils::CBuilder::Platform::Unix;
6
74d5bfab 7use vars qw(@ISA);
6b09c160
YST
8@ISA = qw(ExtUtils::CBuilder::Platform::Unix);
9
10sub need_prelink { 1 }
11
d1cf867f
SP
12sub prelink {
13 # Generate import libraries (XXXX currently near .DEF; should be near DLL!)
14 my $self = shift;
3fa7b0d2
RGS
15 my %args = @_;
16
17 my @res = $self->SUPER::prelink(%args);
d1cf867f
SP
18 die "Unexpected number of DEF files" unless @res == 1;
19 die "Can't find DEF file in the output"
3fa7b0d2
RGS
20 unless $res[0] =~ m,^(.*)\.def$,si;
21 my $libname = "$1$self->{config}{lib_ext}"; # Put .LIB file near .DEF file
d1cf867f
SP
22 $self->do_system('emximp', '-o', $libname, $res[0]) or die "emxexp: res=$?";
23 return (@res, $libname);
24}
25
26sub _do_link {
3fa7b0d2
RGS
27 my $self = shift;
28 my ($how, %args) = @_;
29 if ($how eq 'lib_file'
30 and (defined $args{module_name} and length $args{module_name})) {
31
3fa7b0d2
RGS
32 # Now know the basename, find directory parts via lib_file, or objects
33 my $objs = ( (ref $args{objects}) ? $args{objects} : [$args{objects}] );
34 my $near_obj = $self->lib_file(@$objs);
3fa7b0d2
RGS
35 my $exp_dir = ($near_obj =~ m,(.*)[/\\],s ? "$1/" : '' );
36
37 $args{dl_file} = $1 if $near_obj =~ m,(.*)\.,s; # put ExportList near OBJ
3fa7b0d2
RGS
38
39 # XXX _do_link does not have place to put libraries?
40 push @$objs, $self->perl_inc() . "/libperl$self->{config}{lib_ext}";
41 $args{objects} = $objs;
42 }
d1cf867f
SP
43 # Some 'env' do exec(), thus return too early when run from ksh;
44 # To avoid 'env', remove (useless) shrpenv
d1cf867f 45 local $self->{config}{shrpenv} = '';
3fa7b0d2 46 return $self->SUPER::_do_link($how, %args);
d1cf867f
SP
47}
48
3fa7b0d2
RGS
49sub extra_link_args_after_prelink {
50 # Add .DEF file to the link line
d1cf867f 51 my ($self, %args) = @_;
3fa7b0d2
RGS
52
53 my @DEF = grep /\.def$/i, @{$args{prelink_res}};
6dfee1ec 54 die "More than one .def files created by 'prelink' stage" if @DEF > 1;
3fa7b0d2 55 # XXXX No "$how" argument here, so how to test for dynamic link?
6dfee1ec 56 die "No .def file created by 'prelink' stage"
3fa7b0d2
RGS
57 unless @DEF or not @{$args{prelink_res}};
58
59 my @after_libs = ($OS2::is_aout ? ()
60 : $self->perl_inc() . "/libperl_override$self->{config}{lib_ext}");
61 # , "-L", "-lperl"
62 (@after_libs, @DEF);
d1cf867f
SP
63}
64
65sub link_executable {
66 # ldflags is not expecting .exe extension given on command line; remove -Zexe
67 my $self = shift;
68 local $self->{config}{ldflags} = $self->{config}{ldflags};
69 $self->{config}{ldflags} =~ s/(?<!\S)-Zexe(?!\S)//;
70 return $self->SUPER::link_executable(@_);
71}
72
73
6b09c160 741;