2 eval 'exec perl -wS $0 ${1+"$@"}'
5 # This file is part of the LibreOffice project.
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distributed with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # This file incorporates work covered by the following license notice:
13 # Licensed to the Apache Software Foundation (ASF) under one or more
14 # contributor license agreements. See the NOTICE file distributed
15 # with this work for additional information regarding copyright
16 # ownership. The ASF licenses this file to you under the Apache
17 # License, Version 2.0 (the "License"); you may not use this file
18 # except in compliance with the License. You may obtain a copy of
19 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 # mapgen - generate a map file for Unix libraries
31 ( $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
32 print "$script_name -- version: 1.6\n";
33 print "Multi Platform Enabled Edition\n";
35 #########################
39 #########################
50 if (!(open (DUMP_FILE
, $dump_file))) {
51 &print_error
("Unable open $dump_file");
53 if (!(open (FLT_FILE
, $flt_file))) {
55 &print_error
("Unable open $flt_file");
58 if (!(open (MAP_FILE
, ">>$map_file"))) {
61 &print_error
("Unable open $map_file");
64 if ($ENV{OS
} eq 'SOLARIS') {
66 } elsif ($ENV{OS
} eq 'LINUX') {
69 &print_error
('Environment not set!!');
76 #### end of main procedure ####
78 #########################
82 #########################
85 # Generate a map file for solaris
89 foreach (<DUMP_FILE
>) {
90 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*/));
91 next if (($7 =~ /UNDEF/) || ($7 =~ /ABS/));
92 next if ($5 eq 'LOCL');
95 &filter_symbols
(\
%symbols);
99 # Generate a map file for linux
103 foreach (<DUMP_FILE
>) {
104 next if (!(/^\S+ [A|B|C|D|G|I|N|R|S|T|U|V|W|-|\?|-] (\S+)/));
107 &filter_symbols
(\
%symbols);
111 # Filter symbols with filters from $flt_file
115 my $env_section = '';
117 my @filtered_symbols = ();
121 $env_section = '1' and next if ((/^# SOLARIS #$/) && ($ENV{OS
} eq 'SOLARIS'));
122 $env_section = '1' and next if ((/^# LINUX #$/) && ($ENV{OS
} eq 'LINUX'));
123 $env_section = '1' and next if ((/^# FREEBSD #$/) && ($ENV{OS
} eq 'FREEBSD'));
124 $env_section = '1' and next if ((/^# NETBSD #$/) && ($ENV{OS
} eq 'NETBSD'));
125 $env_section = '1' and next if ((/^# OPENBSD #$/) && ($ENV{OS
} eq 'OPENBSD'));
126 $env_section = '1' and next if ((/^# DRAGONFLY #$/) && ($ENV{OS
} eq 'DRAGONFLY'));
127 last if ($env_section && ((/^# SOLARIS #$/) || (/^# FREEBSD #$/) || (/^# LINUX #$/) || (/^# NETBSD #$/) || (/^# OPENBSD #$/) (/^# DRAGONFLY #$/)));
128 next if (!$_ || /^#/);
131 foreach my $symbol (keys %$symbols) {
133 foreach my $filter_str (@filters) {
134 my $add = substr ($filter_str, 0, 1);
135 my $filter = substr($filter_str, 1);
136 if ($symbol =~ /$filter/) {
140 if ($export eq '+') {
141 push(@filtered_symbols, $symbol);
144 &write_mapfile
(\
@filtered_symbols);
152 print MAP_FILE
$first_string . " {\n$tab" . "global:\n";
153 foreach (@
$symbols) {
154 print MAP_FILE
"$tab$tab$_\;\n";
156 print MAP_FILE
"$tab" . "local:\n$tab\*\;\n}\;";
160 # Get all options passed
168 &usage
() && exit(0) if ($#ARGV == -1);
169 while ($arg = shift @ARGV) {
170 $arg =~ /^-d$/ and $dump_file = shift @ARGV and next;
171 $arg =~ /^-f$/ and $flt_file = shift @ARGV and next;
172 $arg =~ /^-m$/ and $map_file = shift @ARGV and next;
173 $arg =~ /^-h$/ and &usage
and exit(0);
174 $arg =~ /^--help$/ and &usage
and exit(0);
175 $arg =~ /^-s$/ and $first_string = shift @ARGV and next;
188 print STDERR
"\nERROR: $message\n";
193 print STDERR
"\nmapgen:\n";
194 print STDERR
"Syntax: mapgen -d dump_file -s first_string -f filter_file -m map_file [-h|--help]\n";