1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#*************************************************************************
27
28# Generate an exported symbols list out of a map file (as use on Linux/Solaris) in order to
29# build shared libraries on Mac OS X
30#
31# The below code fails may fail with 'perverted' mapfiles (using a strange line layout etc.)
32
33# Skip 'SECTION_NAME {' lines
34/^[\t ]*.*[\t ]*\{/ { next }
35
36# Skip 'global:' or 'local:' lines
37/global:/ || /local:/ { next }
38
39# Skip '*;' lines
40/^[\t ]*\*;[\t ]*/ { next }
41
42# Skip section end '}?;' lines
43/^[\t ]*\}[\t ]*.*[;]*/ { next }
44
45# Skip comment or empty lines
46/^[\t ]*#.*/ || /^[\t ]*$/ || /^$/ { next }
47
48# Echo all lines containing symbol names and prefix them with '_'
49# because symbols on Mac OS X start always with '__'
50{
51    # There may appear multiple symbols in one line
52    # e.g. "sym1; sym2; # and finally a comment"
53    # take this into account
54    for (i = 1; i <= NF ; i++) {
55	if ($i !~ /^[\t ]*#.*/) { # as long as the current field doesn't start with '#'
56	    gsub(/[\t ;]/, "", $i) # Remove leading spaces and trailing ';'
57	    printf("_%s\n",$i)
58	}
59	else { # ignore everything after a '#' (comment) sign
60	    break
61	}
62    }
63}
64