blob: d198c50c87f5475183b9978dfa7a2339214dfd08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
|