xref: /aoo41x/main/solenv/bin/addsym-macosx.sh (revision e4af8f11)
1*e4af8f11SPedro Giffuni#!/bin/sh
2cdf0e10cSrcweir
3cdf0e10cSrcweir# This script is needed in the process of generating exported
4cdf0e10cSrcweir# symbols list out of map files on Mac OS X (see also #i69351#)
5cdf0e10cSrcweir# The magic generating the regular expression from the temporary
6cdf0e10cSrcweir# mapfile containing only star and question mark symbols
7cdf0e10cSrcweir#
8cdf0e10cSrcweir# The script has to be called as follows:
9cdf0e10cSrcweir# nm -gx <file>.o | addsym-macosx.sh <file-with-wildcard-symbols> <temporary-file-where-to-write-the-search-expression-to>
10cdf0e10cSrcweir# See tg_shl.mk for an example of how to use the script
11cdf0e10cSrcweir#
12cdf0e10cSrcweir# Replace every * with .* and every ? with . to get awk expression
13cdf0e10cSrcweir# Put ^ at the beginning of every expression
14cdf0e10cSrcweir# Put $ at the beginning of every expression
15cdf0e10cSrcweir# Connect them all on one line, separated by |
16cdf0e10cSrcweir# Remove | at the end of this regular expression because the last end
17cdf0e10cSrcweir# of line was also replaced by |
18cdf0e10cSrcweir
19cdf0e10cSrcweircat $1 | sed 's#*#.*#g
20cdf0e10cSrcweirs#?#.#g
21cdf0e10cSrcweirs#^#^#
22cdf0e10cSrcweirs#$#$#' | tr '\n' '|' | sed "s#|\$##" >$2
23cdf0e10cSrcweir
24cdf0e10cSrcweir# Please note that the awk expression expects to get the output of 'nm -gx'!
25cdf0e10cSrcweir# On Panther we have to filter out symbols with a value "1f" otherwise external
26cdf0e10cSrcweir# symbols will erroneously be added to the generated export symbols list file.
27cdf0e10cSrcweirawk -v SYMBOLSREGEXP="`cat $2`" '
28cdf0e10cSrcweirmatch ($6,SYMBOLSREGEXP) > 0 &&  $6 !~ /_GLOBAL_/ { if (($2 != 1) && ( $2 != "1f" ) ) print $6 }'
29cdf0e10cSrcweir
30