# 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.
+AUTOMAKE_OPTIONS = parallel-tests color-tests
ACLOCAL_AMFLAGS = -I m4
# For Gnulib
$(libcdecl_la_OBJECTS): $(gnulib_headers)
bin_PROGRAMS = cdecl99
+cdecl99_SOURCES = src/cdecl99.c
+cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
+$(cdecl99_OBJECTS): $(gnulib_headers)
check_PROGRAMS =
check_LTLIBRARIES = libtest.la
check_PROGRAMS += test/randomdecl
endif
-cdecl99_SOURCES = src/cdecl99.c
-cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
-$(cdecl99_OBJECTS): $(gnulib_headers)
-
test_randomdecl_LDADD = libcdecl.la libtest.la libgnu.la
$(test_randomdecl_OBJECTS): $(gnulib_headers)
+TESTS_ENVIRONMENT = SHELL='$(SHELL)' LIBTOOL='$(LIBTOOL)'
+TEST_EXTENSIONS = .sh
+SH_LOG_COMPILER = $(SHELL)
+
+TESTS = tests/libcdecl-static-symbols.sh
+EXTRA_DIST += $(TESTS)
+
src/parse.lo: src/scan.h
src/scan.lo: src/parse.h
src/parse-decl.lo: src/scan.h src/parse.h
--- /dev/null
+#!/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