diff options
Diffstat (limited to 'scripts/check-globals.sh')
-rwxr-xr-x | scripts/check-globals.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/check-globals.sh b/scripts/check-globals.sh new file mode 100755 index 000000000..d198c50c8 --- /dev/null +++ b/scripts/check-globals.sh @@ -0,0 +1,37 @@ +#!/bin/bash -e +# +# Check that global symbols in a static library conform to a given regex. +# Only static library is checked, since libtool -export-symbols-regex +# takes care of dynamic libraries. +# +# Required variables: +# LIBTOOL Path to libtool. +# NM Path to nm. +# LIB Library directory. +# lib_LTLIBRARIES Library .la file. +# CHECK_GLOBALS_REGEX Global symbols matching this regex are accepted. +# + +tmpfile=$(mktemp) + +# get $objdir +$LIBTOOL --config > $tmpfile +. $tmpfile + +# get $old_library (static library name) +. $lib_LTLIBRARIES + +echo "$old_library: Checking global symbols, regex: $CHECK_GLOBALS_REGEX" + +# get a list of symbols that are global, are not undefined or weak, and +# do not match the regex +$NM -g --defined-only $LIB/$objdir/$old_library | \ + egrep " [uA-T] " | egrep -v "$CHECK_GLOBALS_REGEX" | tee $tmpfile + +num=$(cat $tmpfile | wc -l) +rm -f $tmpfile + +if [ "$num" != "0" ]; then + echo "$old_library: ($num non-matching symbols)" + false +fi |