2 # $Id: listused.sh,v 1.5 2003/07/05 19:02:41 tom Exp $
3 # A very simple script to list entrypoints that are used by either a test
4 # program, or within the libraries. This relies on the output format of 'nm',
5 # and assumes that the libraries are configured with TRACE defined, and using
9 # Static libraries are used, to provide some filtering based on internal usage
10 # of the different symbols.
12 # keep the sorting independent of locale:
13 if test "${LANGUAGE+set}" = set; then LANGUAGE
=C
; export LANGUAGE
; fi
14 if test "${LANG+set}" = set; then LANG
=C
; export LANG
; fi
15 if test "${LC_ALL+set}" = set; then LC_ALL
=C
; export LC_ALL
; fi
16 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES
=C
; export LC_MESSAGES
; fi
17 if test "${LC_CTYPE+set}" = set; then LC_CTYPE
=C
; export LC_CTYPE
; fi
18 if test "${LC_COLLATE+set}" = set; then LC_COLLATE
=C
; export LC_COLLATE
; fi
22 if test ! -d ..
/objects
; then
23 echo "? need objects to run this script"
25 elif test ! -d ..
/lib
; then
26 echo "? need libraries to run this script"
31 for name
in `(echo "test:";sort modules; echo "progs:";sort ../progs/modules) |sed -e 's/[ ].*//' -e '/^[#@]/d'`
38 NAME
=..
/objects
/${name}.o
50 LIB
=`basename $lib .a`
57 tmp
=`echo $LIB|sed -e 's/w$//'`
60 echo $tmp |
sed -e 's/./-/g'
61 # Construct a list of public externals provided by the library.
62 WANT
=`nm $NM_OPTS $lib |\
72 # List programs which use that external.
85 TEST
=`nm $NM_OPTS $prog |\
93 -e 's/^'${name}'$/_/' \
97 have
=`basename $prog .o`
100 if test "$last" = "$tags"
104 HAVE
="$HAVE $tags $have"
114 # if we did not find a program using it directly, see if it
115 # is used within a library.
118 for tmp
in ..
/lib
/*.a
125 TEST
=`nm $NM_OPTS $tmp |\
126 sed -e 's/^[^ ]*//' \
134 -e 's/^'${name}'$/_/' \
138 tmp
=`basename $tmp .a |sed -e 's/w$//'`
139 HAVE
=`echo $tmp | sed -e 's/lib/lib: /'`
144 test -z "$HAVE" && HAVE
="-"
145 lenn
=`expr 39 - length $name`
146 lenn
=`expr $lenn / 8`
148 while test $lenn != 0
151 lenn
=`expr $lenn - 1`
153 echo "${name}${tabs}${HAVE}"