de5c18f403a035fe494287a87534f07dbb631ddd
[platform/upstream/libnice.git] / scripts / check-symbols.sh
1 #!/bin/sh
2
3 usage()
4 {
5         echo "usage: $0 library symbol-file"
6         exit 1
7 }
8
9 test -n "$1" || usage
10 lib="$1"
11 test -n "$2" || usage
12 symbol_file="$2"
13
14 make_symbol_list=`dirname $0`/make-symbol-list.sh
15 test -f "$make_symbol_list" || exit 1
16
17 if ! test -f "$symbol_file"; then
18         echo "$symbol_file doesn't exist"
19         exit 1
20 fi
21
22 diff=`sh $make_symbol_list "$lib" | \
23         diff -uB "$symbol_file" - | tail -n +3`
24
25 # stop if there are no differences
26 test -z "$diff" && exit 0
27
28 echo "symbols for $lib changed"
29
30 if echo "$diff" | grep -q '^-'; then
31         echo "  missing:"
32         echo "$diff" | grep '^-' | cut -b 2- | \
33                 xargs -i echo "   " "{}"
34 fi
35
36 if echo "$diff" | grep -q '^+'; then
37         echo "  extra:"
38         echo "$diff" | grep '^+' | cut -b 2- | \
39                 xargs -i echo "   " "{}"
40 fi
41
42 exit 1
43