blob: ed60abe9562838f801c1cd0f087de30655c16c14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
use strict;
use warnings;
use Getopt::Long;
my $format;
my $libname;
my $input;
my $output;
GetOptions(
'format:s' => \$format,
'libname:s' => \$libname,
'input:s' => \$input,
'output:s' => \$output) or die "wrong arguments";
if (not( $format eq 'aix'
or $format eq 'darwin'
or $format eq 'gnu'
or $format eq 'win'))
{
die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n";
}
open(my $input_handle, '<', $input)
or die "$0: could not open input file '$input': $!\n";
open(my $output_handle, '>', $output)
or die "$0: could not open output file '$output': $!\n";
if ($format eq 'gnu')
{
print $output_handle "{
global:
";
}
elsif ($format eq 'win')
{
# XXX: Looks like specifying LIBRARY $libname is optional, which makes it
# easier to build a generic command for generating export files...
if ($libname)
{
print $output_handle "LIBRARY $libname\n";
}
print $output_handle "EXPORTS\n";
}
while (<$input_handle>)
{
if (/^#/)
{
# don't do anything with a comment
}
elsif (/^(\S+)\s+(\S+)/)
{
if ($format eq 'aix')
{
print $output_handle "$1\n";
}
elsif ($format eq 'darwin')
{
print $output_handle "_$1\n";
}
elsif ($format eq 'gnu')
{
print $output_handle " $1;\n";
}
elsif ($format eq 'win')
{
print $output_handle "$1 @ $2\n";
}
}
else
{
die "$0: unexpected line $_\n";
}
}
if ($format eq 'gnu')
{
print $output_handle " local: *;
};
";
}
|