1#!/usr/bin/perl
2
3use strict;
4use File::Basename;
5
6my ($replace, $in, $outdir) = ($ARGV[0], $ARGV[1], $ARGV[2]);
7
8my $f = $outdir . "/" . basename($in);
9
10my ($IN, $OUT);
11
12open IN, "$in" or die "failed to open $in";
13open OUT, ">$f" or die "failed to open $f";
14
15while(<IN>) {
16    if ($replace eq "GSS" and m/krb5-types.h/) {
17	s/<krb5-types.h>/<inttypes.h>/;
18	print OUT;
19	print OUT "#include <unistd.h>\n";
20    } elsif (m/_err.h/ or m/_asn1.h/ or m/krb5.*\.h/ or m/com_.*\.h/ or m/gssapi.*\.h/ or m/.*-protos\.h/ or /heimbase.h/) {
21	s/#include +\<(.*).h>/#include <${replace}\/$1.h>/;
22	print OUT;
23    } else {
24	print OUT;
25    }
26}
27
28close IN;
29close OUT;
30
31exit 0;
32