check.mak: Make number of torture iterations configurable
[platform/upstream/gst-common.git] / check-exports
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
8 if [ $# -ne 2 ]; then
9         echo "Usage: $0 library.def library.so"
10         exit 1
11 fi
12
13 def_path="$1"
14 def_name="$(basename $def_path)"
15 lib_path="$2"
16
17 lib_result="`mktemp /tmp/defname.XXXXXX`"
18
19 LC_ALL=C
20 export LC_ALL
21
22 # On Solaris, add -p to get the correct output format
23 NMARGS=
24 if nm -V 2>&1 |grep Solaris > /dev/null; then
25   NMARGS=-p
26 fi
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.
30 nm $NMARGS $lib_path | awk \
31         '{
32                 if ($3 ~ /^[_]?(gst_|Gst|GST_).*/)
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
42 diffoutput=`diff -u $def_path $lib_result`
43 diffresult=$?
44
45 rm $lib_result
46
47 if test "$diffresult" -eq 0; then
48   exit 0;
49 else
50   echo -n "$diffoutput" >&2
51   echo >&2
52   exit 1;
53 fi
54