touch $@
errcodes.h: $(top_srcdir)/src/backend/utils/errcodes.txt generate-errcodes.pl
- $(PERL) $(srcdir)/generate-errcodes.pl $< > $@
+ $(PERL) $(srcdir)/generate-errcodes.pl --outfile $@ $<
ifneq ($(enable_dtrace), yes)
probes.h: Gen_dummy_probes.sed
use strict;
use warnings;
+use Getopt::Long;
-print
+my $outfile = '';
+
+GetOptions(
+ 'outfile=s' => \$outfile) or die "$0: wrong arguments";
+
+open my $errcodes, '<', $ARGV[0]
+ or die "$0: could not open input file '$ARGV[0]': $!\n";
+
+my $outfh;
+if ($outfile)
+{
+ open $outfh, '>', $outfile
+ or die "$0: could not open output file '$outfile': $!\n";
+}
+else
+{
+ $outfh = *STDOUT;
+}
+
+print $outfh
"/* autogenerated from src/backend/utils/errcodes.txt, do not edit */\n";
-print "/* there is deliberately not an #ifndef ERRCODES_H here */\n";
+print $outfh "/* there is deliberately not an #ifndef ERRCODES_H here */\n";
-open my $errcodes, '<', $ARGV[0] or die;
while (<$errcodes>)
{
{
my $header = $1;
$header =~ s/^\s+//;
- print "\n/* $header */\n";
+ print $outfh "\n/* $header */\n";
next;
}
# And quote them
$sqlstate =~ s/([^,])/'$1'/g;
- print "#define $errcode_macro MAKE_SQLSTATE($sqlstate)\n";
+ print $outfh "#define $errcode_macro MAKE_SQLSTATE($sqlstate)\n";
}
close $errcodes;
+close $outfh if ($outfile);
{
print "Generating errcodes.h...\n";
system(
- 'perl src/backend/utils/generate-errcodes.pl src/backend/utils/errcodes.txt > src/backend/utils/errcodes.h'
+ 'perl src/backend/utils/generate-errcodes.pl --outfile src/backend/utils/errcodes.h src/backend/utils/errcodes.txt'
);
copyFile('src/backend/utils/errcodes.h',
'src/include/utils/errcodes.h');