libcdecl_la_LDFLAGS = -export-symbols-regex '^cdecl_[[:lower:]]'
libcdecl_la_SOURCES = src/scan.c src/parse.c src/parse-decl.c src/typemap.c \
src/output.c src/explain.c src/declare.c src/i18n.c
-libcdecl_la_LIBADD = $(LTLIBINTL) $(LTLIBTHREAD) libgnu.la
+libcdecl_la_LIBADD = libgnu.la $(LTLIBINTL) $(LTLIBTHREAD)
$(libcdecl_la_OBJECTS): $(gnulib_headers)
bin_PROGRAMS = cdecl99
cdecl99_SOURCES = src/cdecl99.c
-cdecl99_LDADD = libcdecl.la libgnu.la
+cdecl99_LDADD = libcdecl.la libgnu.la $(LTLIBINTL) $(LTLIBREADLINE)
$(cdecl99_OBJECTS): $(gnulib_headers)
src/parse.lo: src/scan.h
# useful for non-recursive builds. Strip them out.
drop if (/^(AM_CPPFLAGS|AM_CFLAGS)/);
+ # Library dependencies are added automatically to libgnu.la by
+ # gnulib-tool. Unfortunately, this means that everything linking
+ # against libgnu.la is forced to pull in the same deps, even if they're
+ # unneeded. Furthermore, a libtool linker flag reordering bug prevents
+ # --as-needed from stripping out the useless deps, so it's better to
+ # handle them all manually.
+ drop if (/LDFLAGS/);
+
# Rewrite automake hook targets to be more generic.
if (s/^(.*)-local:/\1-gnulib:/) {
print ".PHONY: $1-gnulib\n";