#! /usr/local/bin/perl
die "No input !!\nUsage: $0 <input-file1> [<input-file2> ...]\n" if ($#ARGV<0);
while ($_ = <ARGV>) {
  if ($ARGV ne $outfile) {
    die "Cannot open $ARGV.\n" if (! (-T $ARGV));
    close (OUTF) && print STDERR ("done.\n") if (defined $outfile);
    $outfile = $ARGV;
    $infile = $ARGV;
    $infile .= ".org" if (!($infile =~ s/\..*$/\.org/));
    rename ($outfile, $infile);
    open (OUTF, ">$outfile");
    select(OUTF);
    print STDERR "$outfile ...";
  }
  print;
  print "#include \"gdevgppr.h\"\n" if (/^#\s*include\s+\"gdevprn\.h\"/);
}
print STDERR " done.\n";
