Debian Codegraph @

mkExt

raw
1 #!/usr/local/bin/perl -w
2
3 sub translate
4 {
5 my ($src,$dst,$ext,$ref) = @_;
6 $ref = "\L$ref";
7 my $Ref = "\u$ref";
8 open(TEXT,"<$src") || die "Cannot open $src:$!";
9 open(MINE,">$dst") || die "Cannot open $dst:$!";
10 while (<TEXT>)
11 {
12 s/\b$Ref\b/$ext/g;
13 s/${Ref}Cmd/${ext}Cmd/g;
14 s/\b$ref\b/\L$ext/g;
15 print MINE $_;
16 }
17 close(TEXT);
18 close(MINE);
19 }
20
21 sub mkExt
22 {my ($ref,$ext) = @_;
23 mkdir($ext,0777) unless (-d $ext);
24 if (-f "Tk/$ext.pm")
25 {
26 rename("Tk/$ext.pm","$ext/$ext.pm");
27 }
28 translate("$ref/GNUmakefile","$ext/GNUmakefile",$ext,$ref);
29 translate("$ref/Makefile.PL","$ext/Makefile.PL",$ext,$ref);
30 translate("$ref/$ref.xs","$ext/$ext.xs",$ext,$ref);
31 }
32
33 my $ref = shift;
34
35 foreach $ext (@ARGV)
36 {
37 mkExt($ref,$ext);
38 }