Make some error strings more generic
[pgsql.git] / src / tools / gen_export.pl
blobed60abe9562838f801c1cd0f087de30655c16c14
1 use strict;
2 use warnings;
3 use Getopt::Long;
5 my $format;
6 my $libname;
7 my $input;
8 my $output;
10 GetOptions(
11 'format:s' => \$format,
12 'libname:s' => \$libname,
13 'input:s' => \$input,
14 'output:s' => \$output) or die "wrong arguments";
16 if (not( $format eq 'aix'
17 or $format eq 'darwin'
18 or $format eq 'gnu'
19 or $format eq 'win'))
21 die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n";
24 open(my $input_handle, '<', $input)
25 or die "$0: could not open input file '$input': $!\n";
27 open(my $output_handle, '>', $output)
28 or die "$0: could not open output file '$output': $!\n";
31 if ($format eq 'gnu')
33 print $output_handle "{
34 global:
37 elsif ($format eq 'win')
39 # XXX: Looks like specifying LIBRARY $libname is optional, which makes it
40 # easier to build a generic command for generating export files...
41 if ($libname)
43 print $output_handle "LIBRARY $libname\n";
45 print $output_handle "EXPORTS\n";
48 while (<$input_handle>)
50 if (/^#/)
52 # don't do anything with a comment
54 elsif (/^(\S+)\s+(\S+)/)
56 if ($format eq 'aix')
58 print $output_handle "$1\n";
60 elsif ($format eq 'darwin')
62 print $output_handle "_$1\n";
64 elsif ($format eq 'gnu')
66 print $output_handle " $1;\n";
68 elsif ($format eq 'win')
70 print $output_handle "$1 @ $2\n";
73 else
75 die "$0: unexpected line $_\n";
79 if ($format eq 'gnu')
81 print $output_handle " local: *;