use ExtUtils::CBuilder::Base;
use vars qw($VERSION @ISA);
-$VERSION = '0.01';
+$VERSION = '0.12';
@ISA = qw(ExtUtils::CBuilder::Base);
sub new {
return @argv;
}
+sub arg_defines {
+ my ($self, %args) = @_;
+ s/"/\\"/g foreach values %args;
+ return map qq{"-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(),
use_scripts => 1, # XXX provide user option to change this???
);
- $self->add_to_cleanup($spec{output});
-
$self->normalize_filespecs(
\$spec{source},
\$spec{output},
# if running in perl source tree, look for libs there, not installed
my $lddlflags = $cf->{lddlflags};
my $perl_src = $self->perl_src();
- $lddlflags =~ s/\Q$cf->{archlibexp}\E\\CORE/$perl_src/ if $perl_src;
+ $lddlflags =~ s/\Q$cf->{archlibexp}\E[\\\/]CORE/$perl_src/ if $perl_src;
my %spec = (
srcdir => $to,
$self->add_to_cleanup(
grep defined,
- @{[ @spec{qw(output implib explib def_file base_file map_file)} ]}
+ @{[ @spec{qw(implib explib def_file base_file map_file)} ]}
);
foreach my $opt ( qw(output implib explib def_file map_file base_file) ) {
=begin comment
The packages below implement functions for generating properly
-formated commandlines for the compiler being used. Each package
+formatted commandlines for the compiler being used. Each package
defines two primary functions 'format_linker_cmd()' &
'format_compiler_cmd()' that accepts a list of named arguments (a
-hash) and returns a list of formated options suitable for invoking the
+hash) and returns a list of formatted options suitable for invoking the
compiler. By default, if the compiler supports scripting of its
operation then a script file is built containing the options while
those options are removed from the commandline, and a reference to the
$spec{basename} . '.ccs' );
$self->add_to_cleanup($script);
-
print "Generating script '$script'\n" if !$self->{quiet};
open( SCRIPT, ">$script" )