1#!/bin/sh
2# check-exports
3#
4# quick'n'dirty script that retrieves the list of exported symbols of a given
5# library using 'nm', and compares that against the list of symbols-to-export
6# of our win32/common/libfoo.def files.
7
8if [ $# -ne 2 ]; then
9	echo "Usage: $0 library.def library.so"
10	exit 1
11fi
12
13def_path="$1"
14def_name="$(basename $def_path)"
15lib_path="$2"
16
17lib_result="`mktemp /tmp/defname.XXXXXX`"
18
19LC_ALL=C
20export LC_ALL
21
22# On Solaris, add -p to get the correct output format
23NMARGS=
24if nm -V 2>&1 |grep Solaris > /dev/null; then
25  NMARGS=-p
26fi
27
28# _end is special cased because for some reason it is reported as an exported
29# BSS symbol, unlike on linux where it's a local absolute symbol.
30nm $NMARGS $lib_path | awk \
31	'{
32		if ($3 ~ /^[_]?(gst_|Gst|GST_|ges_|Ges|GES_).*/)
33		{
34			if ($2 ~ /^[BSDG]$/)
35				print "\t" $3 " DATA"
36			else if ($2 == "T")
37				print "\t" $3
38		}
39	 }' | sort | awk '{ if (NR == 1) print "EXPORTS"; print $0; }' \
40	> $lib_result
41
42diffoutput=`diff -u $def_path $lib_result`
43diffresult=$?
44
45rm $lib_result
46
47if test "$diffresult" -eq 0; then
48  exit 0;
49else
50  echo -n "$diffoutput" >&2
51  echo >&2
52  exit 1;
53fi
54
55