]> git.draconx.ca Git - cdecl99.git/blob - tests/libcdecl-static-symbols.sh
Output copyright symbol directly, rather than via translations.
[cdecl99.git] / tests / libcdecl-static-symbols.sh
1 #!/bin/sh
2 #
3 # Copyright © 2012 Nick Bowler
4 #
5 # Verify that a static library does not export any unprefixed symbols.
6 #
7 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
8 # This is free software: you are free to do what the fuck you want to.
9 # There is NO WARRANTY, to the extent permitted by law.
10
11 ltlib=libcdecl.la
12 sym_prefix=cdecl_
13
14 eval `$LIBTOOL --config | sed -n \
15         -e '/^objdir=/p' \
16         -e '/^build_old_libs=/p'` || exit 1
17 eval `< $ltlib sed -ne '/^old_library=/p'` || exit 1
18
19 if test x"$build_old_libs" = x"no"; then
20         # Not building static libs.
21         exit 77
22 fi
23
24 lib=`expr "$ltlib" : '\(.*\)/'`
25 lib="$lib${lib:+/}$objdir/$old_library"
26
27 found_sym=no
28 bad_sym=no
29
30 for i in `$SHELL exported.sh "$lib"`
31 do
32         if expr "$i" : "$sym_prefix" >/dev/null; then
33                 # Record that we found at least one exported symbol.
34                 found_sym=yes
35         else
36                 printf 'unprefixed global symbol: %s\n' "$i" 1>&2
37                 bad_sym=yes
38         fi
39 done
40
41 test x"$bad_sym" = x"yes" && exit 1
42
43 if test x"$found_sym" = x"no"; then
44         printf 'no exported symbols found\n' 1>&2
45         exit 1
46 fi
47
48 exit 0