return ('-o', $file);
}
+sub arg_defines {
+ my ($self, %args) = @_;
+ return map "-D$_=$args{$_}", keys %args;
+}
+
sub compile {
my ($self, %args) = @_;
die "Missing 'source' argument to compile()" unless defined $args{source};
(@{$args{include_dirs} || []},
$self->perl_inc());
+ my @defines = $self->arg_defines( %{$args{defines} || {}} );
+
my @extra_compiler_flags = $self->split_like_shell($args{extra_compiler_flags});
my @cccdlflags = $self->split_like_shell($cf->{cccdlflags});
my @ccflags = $self->split_like_shell($cf->{ccflags});
my @optimize = $self->split_like_shell($cf->{optimize});
- my @flags = (@include_dirs, @cccdlflags, @extra_compiler_flags,
+ my @flags = (@include_dirs, @defines, @cccdlflags, @extra_compiler_flags,
$self->arg_nolink,
@ccflags, @optimize,
$self->arg_object_file($args{object_file}),
sub need_prelink { 0 }
+sub extra_link_args_after_prelink { return }
+
sub prelink {
my ($self, %args) = @_;
NAME => $args{dl_name},
DLBASE => $args{dl_base},
FILE => $args{dl_file},
+ VERSION => (defined $args{dl_version} ? $args{dl_version} : '0.0'),
);
# Mksymlists will create one of these files
$self->prelink(%args,
dl_name => $args{module_name}) if $args{lddl} && $self->need_prelink;
- my @linker_flags = $self->split_like_shell($args{extra_linker_flags});
+ my @linker_flags = ($self->split_like_shell($args{extra_linker_flags}),
+ $self->extra_link_args_after_prelink(%args, dl_name => $args{module_name},
+ prelink_res => \@temp_files));
+
my @output = $args{lddl} ? $self->arg_share_object_file($out) : $self->arg_exec_file($out);
my @shrp = $self->split_like_shell($cf->{shrpenv});
my @ld = $self->split_like_shell($cf->{ld});
return @argv;
}
+sub arg_defines {
+ my ($self, %args) = @_;
+ s/"/\\"/g foreach values %args;
+ return map "-D$_=$args{$_}", keys %args;
+}
+
sub compile {
my ($self, %args) = @_;
my $cf = $self->{config};
$srcdir ||= File::Spec->curdir();
+ my @defines = $self->arg_defines( %{ $args{defines} || {} } );
+
my %spec = (
srcdir => $srcdir,
builddir => $srcdir,
cflags => [
$self->split_like_shell($cf->{ccflags}),
$self->split_like_shell($cf->{cccdlflags}),
+ $self->split_like_shell($cf->{extra_compiler_flags}),
],
optimize => [ $self->split_like_shell($cf->{optimize}) ],
- defines => [ '' ],
+ defines => \@defines,
includes => [ @{$args{include_dirs} || []} ],
perlinc => [
$self->perl_inc(),
$spec{basename} . '.ccs' );
$self->add_to_cleanup($script);
-
print "Generating script '$script'\n" if !$self->{quiet};
open( SCRIPT, ">$script" )
use ExtUtils::CBuilder::Platform::Unix;
use File::Spec;
-use vars qw(@ISA);
+use vars qw($VERSION @ISA);
@ISA = qw(ExtUtils::CBuilder::Platform::Unix);
+$VERSION = '0.01';
sub link_executable {
my $self = shift;
use ExtUtils::CBuilder::Platform::Unix;
use vars qw($VERSION @ISA);
-$VERSION = '0.12';
+$VERSION = '0.13';
@ISA = qw(ExtUtils::CBuilder::Platform::Unix);
sub need_prelink { 1 }
+sub prelink {
+ # Generate import libraries (XXXX currently near .DEF; should be near DLL!)
+ my $self = shift;
+ my @res = $self->SUPER::prelink(@_);
+ die "Unexpected number of DEF files" unless @res == 1;
+ die "Can't find DEF file in the output"
+ unless $res[0] =~ m,^(.*?)([^\\/]+)\.def$,si;
+ my $libname = "$2$self->{config}{lib_ext}";
+ $self->do_system('emximp', '-o', $libname, $res[0]) or die "emxexp: res=$?";
+ return (@res, $libname);
+}
+
+sub _do_link {
+ # Some 'env' do exec(), thus return too early when run from ksh;
+ # To avoid 'env', remove (useless) shrpenv
+ my $self = shift;
+ local $self->{config}{shrpenv} = '';
+ return $self->SUPER::_do_link(@_);
+}
+
+sub extra_link_args_after_prelink { # Add .DEF file to the link line
+ my ($self, %args) = @_;
+ grep /\.def$/i, @{$args{prelink_res}};
+}
+
+sub link_executable {
+ # ldflags is not expecting .exe extension given on command line; remove -Zexe
+ my $self = shift;
+ local $self->{config}{ldflags} = $self->{config}{ldflags};
+ $self->{config}{ldflags} =~ s/(?<!\S)-Zexe(?!\S)//;
+ return $self->SUPER::link_executable(@_);
+}
+
+
1;
($exe_file, @temps) = $b->link_executable(objects => $object_file);
ok $exe_file;
+if ($^O eq 'os2') { # Analogue of LDLOADPATH...
+ # Actually, not needed now, since we do not link with the generated DLL
+ my $old = OS2::extLibpath(); # [builtin function]
+ $old = ";$old" if defined $old and length $old;
+ # To pass the sanity check, components must have backslashes...
+ OS2::extLibpath_set(".\\$old");
+}
+
# Try the executable
ok my_system($exe_file), 11;