1 package ExtUtils::CBuilder::Platform::Windows::BCC;
6 sub format_compiler_cmd {
7 my ($self, %spec) = @_;
9 foreach my $path ( @{ $spec{includes} || [] },
10 @{ $spec{perlinc} || [] } ) {
14 %spec = $self->write_compiler_script(%spec)
15 if $spec{use_scripts};
17 return [ grep {defined && length} (
29 sub write_compiler_script {
30 my ($self, %spec) = @_;
32 my $script = File::Spec->catfile( $spec{srcdir},
33 $spec{basename} . '.ccs' );
35 $self->add_to_cleanup($script);
37 print "Generating script '$script'\n" if !$self->{quiet};
39 my $SCRIPT = IO::File->new( ">$script" )
40 or die( "Could not create script '$script': $!" );
42 # XXX Borland "response files" seem to be unable to accept macro
43 # definitions containing quoted strings. Escaping strings with
44 # backslash doesn't work, and any level of quotes are stripped. The
45 # result is is a floating point number in the source file where a
46 # string is expected. So we leave the macros on the command line.
47 print $SCRIPT join( "\n",
48 map { ref $_ ? @{$_} : $_ }
51 @spec{ qw(includes cflags optimize perlinc) } )
54 push @{$spec{includes}}, '@"' . $script . '"';
59 sub format_linker_cmd {
60 my ($self, %spec) = @_;
62 foreach my $path ( @{$spec{libpath}} ) {
66 push( @{$spec{startup}}, 'c0d32.obj' )
67 unless ( $spec{starup} && @{$spec{startup}} );
69 %spec = $self->write_linker_script(%spec)
70 if $spec{use_scripts};
72 return [ grep {defined && length} (
76 @{$spec{other_ldflags}} ,
78 @{$spec{objects}} , ',',
80 $spec{map_file} , ',',
82 @{$spec{perllibs}} , ',',
87 sub write_linker_script {
88 my ($self, %spec) = @_;
90 # To work around Borlands "unique" commandline syntax,
91 # two scripts are used:
93 my $ld_script = File::Spec->catfile( $spec{srcdir},
94 $spec{basename} . '.lds' );
95 my $ld_libs = File::Spec->catfile( $spec{srcdir},
96 $spec{basename} . '.lbs' );
98 $self->add_to_cleanup($ld_script, $ld_libs);
100 print "Generating scripts '$ld_script' and '$ld_libs'.\n" if !$self->{quiet};
102 # Script 1: contains options & names of object files.
103 my $LD_SCRIPT = IO::File->new( ">$ld_script" )
104 or die( "Could not create linker script '$ld_script': $!" );
106 print $LD_SCRIPT join( " +\n",
110 @spec{ qw(lddlflags libpath other_ldflags startup objects) } )
113 # Script 2: contains name of libs to link against.
114 my $LD_LIBS = IO::File->new( ">$ld_libs" )
115 or die( "Could not create linker script '$ld_libs': $!" );
117 print $LD_LIBS join( " +\n",
118 (delete $spec{libperl} || ''),
119 @{delete $spec{perllibs} || []},
122 push @{$spec{lddlflags}}, '@"' . $ld_script . '"';
123 push @{$spec{perllibs}}, '@"' . $ld_libs . '"';