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