1*e76eebc6SAndrew Rist#************************************************************** 2*e76eebc6SAndrew Rist# 3*e76eebc6SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*e76eebc6SAndrew Rist# or more contributor license agreements. See the NOTICE file 5*e76eebc6SAndrew Rist# distributed with this work for additional information 6*e76eebc6SAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*e76eebc6SAndrew Rist# to you under the Apache License, Version 2.0 (the 8*e76eebc6SAndrew Rist# "License"); you may not use this file except in compliance 9*e76eebc6SAndrew Rist# with the License. You may obtain a copy of the License at 10*e76eebc6SAndrew Rist# 11*e76eebc6SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*e76eebc6SAndrew Rist# 13*e76eebc6SAndrew Rist# Unless required by applicable law or agreed to in writing, 14*e76eebc6SAndrew Rist# software distributed under the License is distributed on an 15*e76eebc6SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*e76eebc6SAndrew Rist# KIND, either express or implied. See the License for the 17*e76eebc6SAndrew Rist# specific language governing permissions and limitations 18*e76eebc6SAndrew Rist# under the License. 19*e76eebc6SAndrew Rist# 20*e76eebc6SAndrew Rist#************************************************************** 21cdf0e10cSrcweir 22cdf0e10cSrcweir# Generate an exported symbols list out of a map file (as use on Linux/Solaris) in order to 23cdf0e10cSrcweir# build shared libraries on Mac OS X 24cdf0e10cSrcweir# 25cdf0e10cSrcweir# The below code fails may fail with 'perverted' mapfiles (using a strange line layout etc.) 26cdf0e10cSrcweir 27cdf0e10cSrcweir# Skip 'SECTION_NAME {' lines 28cdf0e10cSrcweir/^[\t ]*.*[\t ]*\{/ { next } 29cdf0e10cSrcweir 30cdf0e10cSrcweir# Skip 'global:' or 'local:' lines 31cdf0e10cSrcweir/global:/ || /local:/ { next } 32cdf0e10cSrcweir 33cdf0e10cSrcweir# Skip '*;' lines 34cdf0e10cSrcweir/^[\t ]*\*;[\t ]*/ { next } 35cdf0e10cSrcweir 36cdf0e10cSrcweir# Skip section end '}?;' lines 37cdf0e10cSrcweir/^[\t ]*\}[\t ]*.*[;]*/ { next } 38cdf0e10cSrcweir 39cdf0e10cSrcweir# Skip comment or empty lines 40cdf0e10cSrcweir/^[\t ]*#.*/ || /^[\t ]*$/ || /^$/ { next } 41cdf0e10cSrcweir 42cdf0e10cSrcweir# Echo all lines containing symbol names and prefix them with '_' 43cdf0e10cSrcweir# because symbols on Mac OS X start always with '__' 44cdf0e10cSrcweir{ 45cdf0e10cSrcweir # There may appear multiple symbols in one line 46cdf0e10cSrcweir # e.g. "sym1; sym2; # and finally a comment" 47cdf0e10cSrcweir # take this into account 48cdf0e10cSrcweir for (i = 1; i <= NF ; i++) { 49cdf0e10cSrcweir if ($i !~ /^[\t ]*#.*/) { # as long as the current field doesn't start with '#' 50cdf0e10cSrcweir gsub(/[\t ;]/, "", $i) # Remove leading spaces and trailing ';' 51cdf0e10cSrcweir printf("_%s\n",$i) 52cdf0e10cSrcweir } 53cdf0e10cSrcweir else { # ignore everything after a '#' (comment) sign 54cdf0e10cSrcweir break 55cdf0e10cSrcweir } 56cdf0e10cSrcweir } 57cdf0e10cSrcweir} 58