This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade experimental from version 0.015 to 0.016
[perl5.git] / dist / ExtUtils-CBuilder / lib / ExtUtils / CBuilder / Platform / Windows / BCC.pm
CommitLineData
506098d4 1package ExtUtils::CBuilder::Platform::Windows::BCC;
65b2b0d2 2$ExtUtils::CBuilder::Platform::Windows::BCC::VERSION = '0.280223';
506098d4
DG
3sub format_compiler_cmd {
4 my ($self, %spec) = @_;
5
6 foreach my $path ( @{ $spec{includes} || [] },
7 @{ $spec{perlinc} || [] } ) {
8 $path = '-I' . $path;
9 }
10
11 %spec = $self->write_compiler_script(%spec)
12 if $spec{use_scripts};
13
14 return [ grep {defined && length} (
15 $spec{cc}, '-c' ,
16 @{$spec{includes}} ,
17 @{$spec{cflags}} ,
18 @{$spec{optimize}} ,
19 @{$spec{defines}} ,
20 @{$spec{perlinc}} ,
21 "-o$spec{output}" ,
22 $spec{source} ,
23 ) ];
24}
25
26sub write_compiler_script {
27 my ($self, %spec) = @_;
28
29 my $script = File::Spec->catfile( $spec{srcdir},
30 $spec{basename} . '.ccs' );
31
32 $self->add_to_cleanup($script);
33
34 print "Generating script '$script'\n" if !$self->{quiet};
35
36 my $SCRIPT = IO::File->new( ">$script" )
37 or die( "Could not create script '$script': $!" );
38
39 # XXX Borland "response files" seem to be unable to accept macro
40 # definitions containing quoted strings. Escaping strings with
41 # backslash doesn't work, and any level of quotes are stripped. The
a9b2c8ff 42 # result is a floating point number in the source file where a
506098d4
DG
43 # string is expected. So we leave the macros on the command line.
44 print $SCRIPT join( "\n",
45 map { ref $_ ? @{$_} : $_ }
46 grep defined,
47 delete(
48 @spec{ qw(includes cflags optimize perlinc) } )
49 );
50
51 push @{$spec{includes}}, '@"' . $script . '"';
52
53 return %spec;
54}
55
56sub format_linker_cmd {
57 my ($self, %spec) = @_;
58
59 foreach my $path ( @{$spec{libpath}} ) {
60 $path = "-L$path";
61 }
62
63 push( @{$spec{startup}}, 'c0d32.obj' )
74d5bfab 64 unless ( $spec{startup} && @{$spec{startup}} );
506098d4
DG
65
66 %spec = $self->write_linker_script(%spec)
67 if $spec{use_scripts};
68
69 return [ grep {defined && length} (
70 $spec{ld} ,
71 @{$spec{lddlflags}} ,
72 @{$spec{libpath}} ,
73 @{$spec{other_ldflags}} ,
74 @{$spec{startup}} ,
75 @{$spec{objects}} , ',',
76 $spec{output} , ',',
77 $spec{map_file} , ',',
78 $spec{libperl} ,
79 @{$spec{perllibs}} , ',',
80 $spec{def_file}
81 ) ];
82}
83
84sub write_linker_script {
85 my ($self, %spec) = @_;
86
87 # To work around Borlands "unique" commandline syntax,
88 # two scripts are used:
89
90 my $ld_script = File::Spec->catfile( $spec{srcdir},
91 $spec{basename} . '.lds' );
92 my $ld_libs = File::Spec->catfile( $spec{srcdir},
93 $spec{basename} . '.lbs' );
94
95 $self->add_to_cleanup($ld_script, $ld_libs);
96
97 print "Generating scripts '$ld_script' and '$ld_libs'.\n" if !$self->{quiet};
98
99 # Script 1: contains options & names of object files.
100 my $LD_SCRIPT = IO::File->new( ">$ld_script" )
101 or die( "Could not create linker script '$ld_script': $!" );
102
103 print $LD_SCRIPT join( " +\n",
104 map { @{$_} }
105 grep defined,
106 delete(
107 @spec{ qw(lddlflags libpath other_ldflags startup objects) } )
108 );
109
110 # Script 2: contains name of libs to link against.
111 my $LD_LIBS = IO::File->new( ">$ld_libs" )
112 or die( "Could not create linker script '$ld_libs': $!" );
113
114 print $LD_LIBS join( " +\n",
115 (delete $spec{libperl} || ''),
116 @{delete $spec{perllibs} || []},
117 );
118
119 push @{$spec{lddlflags}}, '@"' . $ld_script . '"';
120 push @{$spec{perllibs}}, '@"' . $ld_libs . '"';
121
122 return %spec;
123}
124
1251;
126
127