forked from masak/html-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.PL
50 lines (41 loc) · 1.32 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
$|++;
use strict;
use warnings;
use File::Spec;
my $parrot_dir = $ENV{PARROT_DIR}
or die 'Please set $PARROT_DIR (see README).'."\n";
$ENV{PERL6LIB}
or die 'Please set $PERL6LIB (see README).'."\n";
if ( ! -d $parrot_dir ) {
print STDERR "Not a directory $parrot_dir, exiting...\n";
exit 1;
} elsif ( ! -x File::Spec->catfile( $parrot_dir, 'parrot' )) {
print STDERR "Couldn't find parrot executable in $parrot_dir, "
. "have you compiled?";
exit 1;
}
my @infiles = map { $_.'.in' } qw< Makefile >;
my %replacements = (
PARROT_DIR => $parrot_dir,
);
if ( !-e 'lib/Test.pm' ) {
!system("ln -s $parrot_dir/languages/rakudo/Test.pm lib/") or die @!;
print "Symlinked Test.pm from the Rakudo directory \n";
}
for my $infile (@infiles) {
if ((my $outfile = $infile) =~ s/\.in$//g) {
open my $IN, '<', $infile or die "Couldn't open $infile, $!, $?";
open my $OUT, '>', $outfile or die "Couldn't open $outfile, $!, $?";
while (my $line = <$IN>) {
while ( $line =~ /<(.*?)>/g ) {
my $repl = $1;
if (exists $replacements{$repl}) {
$line =~ s/<$repl>/$replacements{$repl}/g;
}
}
print $OUT $line;
}
print "Created $outfile \n";
}
}