1999-12-26 22:23:58 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
#
|
|
|
|
# fixpaths - substitute makefile variables into text files
|
|
|
|
|
|
|
|
|
2000-01-20 12:13:36 +00:00
|
|
|
$usage = "Usage: $0 [-x<file dot-suffix>] [-Dstring=replacement] [[infile] ...]\n";
|
|
|
|
|
|
|
|
$ext="out";
|
1999-12-26 22:23:58 +00:00
|
|
|
|
|
|
|
if (!defined(@ARGV)) { die ("$usage"); }
|
|
|
|
|
|
|
|
# read in the command line and get some definitions
|
|
|
|
while ($_=$ARGV[0], /^-/) {
|
2000-01-20 12:13:36 +00:00
|
|
|
if (/^-[Dx]/) {
|
1999-12-26 22:23:58 +00:00
|
|
|
# definition
|
|
|
|
shift(@ARGV);
|
|
|
|
if ( /-D(.*)=(.*)/ ) {
|
|
|
|
$def{"$1"}=$2;
|
2000-01-20 12:13:36 +00:00
|
|
|
} elsif ( /-x\s*(\w+)/ ) {
|
|
|
|
$ext=$1;
|
1999-12-26 22:23:58 +00:00
|
|
|
} else {
|
|
|
|
die ("$usage$0: error in command line arguments.\n");
|
|
|
|
}
|
|
|
|
} else {
|
2000-04-19 21:33:24 +00:00
|
|
|
@cmd = split(//, $ARGV[0]); $opt = $cmd[1];
|
|
|
|
die ("$usage$0: unknown option '-$opt'\n");
|
1999-12-26 22:23:58 +00:00
|
|
|
}
|
|
|
|
} # while parsing arguments
|
|
|
|
|
|
|
|
if (!defined(%def)) {
|
|
|
|
die ("$0: nothing to do - no substitutions listed!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for $f (@ARGV) {
|
|
|
|
|
|
|
|
$f =~ /(.*\/)*(.*)$/;
|
2000-01-20 12:13:36 +00:00
|
|
|
$of = $2.".$ext";
|
1999-12-26 22:23:58 +00:00
|
|
|
|
|
|
|
open(IN, "<$f") || die ("$0: input file $f missing!\n");
|
|
|
|
if (open(OUT, ">$of")) {
|
|
|
|
while (<IN>) {
|
|
|
|
for $s (keys(%def)) {
|
2000-01-20 12:13:36 +00:00
|
|
|
s#$s#$def{$s}#;
|
1999-12-26 22:23:58 +00:00
|
|
|
} # for $s
|
|
|
|
print OUT;
|
|
|
|
} # while <IN>
|
|
|
|
} # if (outfile open)
|
|
|
|
} # for $f
|
|
|
|
|
|
|
|
exit 0;
|