Commit | Line | Data |
6b09c160 |
1 | package ExtUtils::CBuilder::Platform::os2; |
2 | |
3 | use strict; |
4 | use ExtUtils::CBuilder::Platform::Unix; |
5 | |
6 | use vars qw($VERSION @ISA); |
d1cf867f |
7 | $VERSION = '0.13'; |
6b09c160 |
8 | @ISA = qw(ExtUtils::CBuilder::Platform::Unix); |
9 | |
10 | sub need_prelink { 1 } |
11 | |
d1cf867f |
12 | sub prelink { |
13 | # Generate import libraries (XXXX currently near .DEF; should be near DLL!) |
14 | my $self = shift; |
15 | my @res = $self->SUPER::prelink(@_); |
16 | die "Unexpected number of DEF files" unless @res == 1; |
17 | die "Can't find DEF file in the output" |
18 | unless $res[0] =~ m,^(.*?)([^\\/]+)\.def$,si; |
19 | my $libname = "$2$self->{config}{lib_ext}"; |
20 | $self->do_system('emximp', '-o', $libname, $res[0]) or die "emxexp: res=$?"; |
21 | return (@res, $libname); |
22 | } |
23 | |
24 | sub _do_link { |
25 | # Some 'env' do exec(), thus return too early when run from ksh; |
26 | # To avoid 'env', remove (useless) shrpenv |
27 | my $self = shift; |
28 | local $self->{config}{shrpenv} = ''; |
29 | return $self->SUPER::_do_link(@_); |
30 | } |
31 | |
32 | sub extra_link_args_after_prelink { # Add .DEF file to the link line |
33 | my ($self, %args) = @_; |
34 | grep /\.def$/i, @{$args{prelink_res}}; |
35 | } |
36 | |
37 | sub link_executable { |
38 | # ldflags is not expecting .exe extension given on command line; remove -Zexe |
39 | my $self = shift; |
40 | local $self->{config}{ldflags} = $self->{config}{ldflags}; |
41 | $self->{config}{ldflags} =~ s/(?<!\S)-Zexe(?!\S)//; |
42 | return $self->SUPER::link_executable(@_); |
43 | } |
44 | |
45 | |
6b09c160 |
46 | 1; |