+#!/bin/sh
+#
+# Copyright © 2012 Nick Bowler
+#
+# Verify that a static library does not export any unprefixed symbols.
+#
+# License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+# This is free software: you are free to do what the fuck you want to.
+# There is NO WARRANTY, to the extent permitted by law.
+
+ltlib=libcdecl.la
+sym_prefix=cdecl_
+
+eval `$LIBTOOL --config | sed -n \
+ -e '/^objdir=/p' \
+ -e '/^build_old_libs=/p'` || exit 1
+eval `< $ltlib sed -ne '/^old_library=/p'` || exit 1
+
+if test x"$build_old_libs" = x"no"; then
+ # Not building static libs.
+ exit 77
+fi
+
+lib=`expr "$ltlib" : '\(.*\)/'`
+lib="$lib${lib:+/}$objdir/$old_library"
+
+found_sym=no
+bad_sym=no
+
+for i in `$SHELL exported.sh "$lib"`
+do
+ if expr "$i" : "$sym_prefix" >/dev/null; then
+ # Record that we found at least one exported symbol.
+ found_sym=yes
+ else
+ printf 'unprefixed global symbol: %s\n' "$i" 1>&2
+ bad_sym=yes
+ fi
+done
+
+test x"$bad_sym" = x"yes" && exit 1
+
+if test x"$found_sym" = x"no"; then
+ printf 'no exported symbols found\n' 1>&2
+ exit 1
+fi
+
+exit 0