6 test -z "$srcdir" && srcdir=.
7 test -z "$libs" && libs=.libs
10 IGNORED_SYMBOLS='_fini\|_init\|_fdata\|_ftext\|_fbss\|__bss_start\|__bss_start__\|__bss_end__\|_edata\|_end\|_bss_end__\|__end__\|__gcov_flush\|llvm_.*'
12 if which nm 2>/dev/null >/dev/null; then
15 echo "check-symbols.sh: 'nm' not found; skipping test"
20 for soname in harfbuzz harfbuzz-subset harfbuzz-icu harfbuzz-gobject; do
21 for suffix in so dylib; do
22 so=$libs/lib$soname.$suffix
23 if ! test -f "$so"; then continue; fi
25 # On macOS, C symbols are prefixed with _
27 if test $suffix = dylib; then symprefix=_; fi
29 EXPORTED_SYMBOLS="`nm "$so" | grep ' [BCDGINRST] .' | grep -v " $symprefix\\($IGNORED_SYMBOLS\\>\\)" | cut -d' ' -f3 | c++filt`"
31 prefix=$symprefix`basename "$so" | sed 's/libharfbuzz/hb/; s/-/_/g; s/[.].*//'`
33 echo "Checking that $so does not expose internal symbols"
34 if echo "$EXPORTED_SYMBOLS" | grep -v "^${prefix}\(_\|$\)"; then
35 echo "Ouch, internal symbols exposed"
40 if ! test -f "$def"; then
41 echo "'$def' not found; skipping"
43 echo "Checking that $so has the same symbol list as $def"
46 echo "$EXPORTED_SYMBOLS" | sed -e "s/^${symprefix}hb/hb/g"
47 # cheat: copy the last line from the def file!
49 } | c++filt | diff "$def" - >&2 || stat=1
56 echo "check-symbols.sh: no shared libraries found; skipping test"