Skip to content

Commit dbbd3ac

Browse files
committed
[Configure] write single Makefile for multiple backends
does not work yet properly, because several targets are defined multiple times
1 parent ef0d520 commit dbbd3ac

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

Configure.pl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@
7979
$config{'cpsep'} = $^O eq 'MSWin32' ? ';' : ':';
8080
$config{'slash'} = $slash;
8181

82+
open my $MAKEFILE, '>', 'Makefile'
83+
or die "Cannot open 'Makefile' for writing: $!";
84+
85+
fill_template_file(
86+
'tools/build/Makefile-common.in',
87+
$MAKEFILE,
88+
%config,
89+
);
90+
8291
if ($backends{parrot}) {
8392
my $with_parrot = $options{'with-parrot'};
8493
my $gen_parrot = $options{'gen-parrot'};
@@ -169,7 +178,7 @@
169178
}
170179

171180
fill_template_file(
172-
['tools/build/Makefile-common.in', 'tools/build/Makefile-Parrot.in'], 'Makefile',
181+
'tools/build/Makefile-Parrot.in', $MAKEFILE,
173182
%config,
174183
);
175184
fill_template_file('src/vm/parrot/nqp.sh', 'gen/parrot/nqp_launcher', %config);
@@ -194,12 +203,12 @@
194203
$config{'make'} = $^O eq 'MSWin32' ? 'nmake' : 'make';
195204
$config{'runner'} = $^O eq 'MSWin32' ? 'nqp.bat' : 'nqp';
196205
fill_template_file(
197-
['tools/build/Makefile-common.in', 'tools/build/Makefile-Moar.in'],
198-
'Makefile',
206+
'tools/build/Makefile-common.in',
207+
$MAKEFILE,
199208
%config,
200209
);
201-
202210
}
211+
203212
if ($backends{jvm}) {
204213
my @errors;
205214

@@ -237,12 +246,15 @@
237246
$config{'runner'} = $^O eq 'MSWin32' ? 'nqp.bat' : 'nqp';
238247

239248
fill_template_file(
240-
['tools/build/Makefile-common.in', 'tools/build/Makefile-JVM.in'],
241-
'Makefile',
249+
'tools/build/Makefile-JVM.in',
250+
$MAKEFILE,
242251
%config,
243252
);
244253
}
245254

255+
close $MAKEFILE
256+
or die "Error while writing to 'Makefile': $!";
257+
246258
my $make = fill_template_text('@make@', %config);
247259
unless ($options{'no-clean'}) {
248260
no warnings;

tools/lib/NQP/Configure.pm

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,25 @@ sub fill_template_file {
151151
my $outfile = shift;
152152
my %config = @_;
153153

154-
open(my $OUT, '>', $outfile)
155-
or die "Unable to write $outfile\n";
156-
print "\nCreating $outfile ...\n";
154+
my $OUT;
155+
if (ref $outfile) {
156+
$OUT = $outfile;
157+
}
158+
else {
159+
print "\nCreating $outfile ...\n";
160+
open($OUT, '>', $outfile)
161+
or die "Unable to write $outfile\n";
162+
}
157163

158164
my @infiles = ref($infile) ? @$infile : $infile;
159165
for my $if (@infiles) {
160166
my $text = slurp( $if );
161167
$text = fill_template_text($text, %config);
162168
print $OUT $text;
163169
}
164-
close($OUT) or die $!;
170+
unless (ref $outfile) {
171+
close($OUT) or die "Error while writing '$outfile': $!";
172+
}
165173
}
166174

167175

0 commit comments

Comments
 (0)