2 eval 'exec perl -wS $0 ${1+"$@"}'
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: mapgen.pl,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
36 # mapgen - generate a map file for Unix libraries
44 ( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
46 $id_str = ' $Revision: 1.6 $ ';
47 $id_str =~ /Revision:\s+(\S+)\s+\$/
48 ?
($script_rev = $1) : ($script_rev = "-");
50 print "$script_name -- version: $script_rev\n";
51 print "Multi Platform Enabled Edition\n";
53 #########################
57 #########################
68 if (!(open (DUMP_FILE
, $dump_file))) {
69 &print_error
("Unable open $dump_file");
71 if (!(open (FLT_FILE
, $flt_file))) {
73 &print_error
("Unable open $flt_file");
76 if (!(open (MAP_FILE
, ">>$map_file"))) {
79 &print_error
("Unable open $map_file");
82 if ($ENV{OS
} eq 'SOLARIS') {
84 } elsif ($ENV{OS
} eq 'LINUX') {
87 &print_error
('Environment not set!!');
94 #### end of main procedure ####
96 #########################
100 #########################
103 # Generate a map file for solaris
107 foreach (<DUMP_FILE
>) {
108 next if (!(/\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*\|\s*(\S+)\s*/));
109 next if (($7 =~ /UNDEF/) || ($7 =~ /ABS/));
110 next if ($5 eq 'LOCL');
113 &filter_symbols
(\
%symbols);
117 # Generate a map file for linux
121 foreach (<DUMP_FILE
>) {
122 next if (!(/^\S+ [A|B|C|D|G|I|N|R|S|T|U|V|W|-|\?|-] (\S+)/));
125 &filter_symbols
(\
%symbols);
129 # Filter symbols with filters from $flt_file
133 my $env_section = '';
135 my @filtered_symbols = ();
139 $env_section = '1' and next if ((/^# SOLARIS #$/) && ($ENV{OS
} eq 'SOLARIS'));
140 $env_section = '1' and next if ((/^# LINUX #$/) && ($ENV{OS
} eq 'LINUX'));
141 $env_section = '1' and next if ((/^# FREEBSD #$/) && ($ENV{OS
} eq 'FREEBSD'));
142 last if ($env_section && ((/^# SOLARIS #$/) || (/^# FREEBSD #$/) || (/^# LINUX #$/)));
143 next if (!$_ || /^#/);
146 foreach my $symbol (keys %$symbols) {
148 foreach my $filter_str (@filters) {
149 my $add = substr ($filter_str, 0, 1);
150 my $filter = substr($filter_str, 1);
151 if ($symbol =~ /$filter/) {
155 if ($export eq '+') {
156 push(@filtered_symbols, $symbol);
159 &write_mapfile
(\
@filtered_symbols);
167 print MAP_FILE
$first_string . " {\n$tab" . "global:\n";
168 foreach (@
$symbols) {
169 print MAP_FILE
"$tab$tab$_\;\n";
171 print MAP_FILE
"$tab" . "local:\n$tab\*\;\n}\;";
175 # Get all options passed
183 &usage
() && exit(0) if ($#ARGV == -1);
184 while ($arg = shift @ARGV) {
185 $arg =~ /^-d$/ and $dump_file = shift @ARGV and next;
186 $arg =~ /^-f$/ and $flt_file = shift @ARGV and next;
187 $arg =~ /^-m$/ and $map_file = shift @ARGV and next;
188 $arg =~ /^-h$/ and &usage
and exit(0);
189 $arg =~ /^--help$/ and &usage
and exit(0);
190 $arg =~ /^-s$/ and $first_string = shift @ARGV and next;
203 print STDERR
"\nERROR: $message\n";
208 print STDERR
"\nmapgen:\n";
209 print STDERR
"Syntax: mapgen -d dump_file -s first_string -f filter_file -m map_file [-h|--help]\n";