From 875124adefb95a5ab11fdaaa6dedb1f5abd4bf4a Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 21 Sep 2011 20:58:27 -0400 Subject: [PATCH] Avoid gratuitous library dependencies linking gnulib. libcdecl doesn't use the readline module at all, but libtool happily pulls it in as a dependency. Handle library dependencies manually to avoid this problem. --- Makefile.am | 4 ++-- fix-gnulib.pl | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 16da7f1..580641d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,12 +37,12 @@ lib_LTLIBRARIES = libcdecl.la 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 diff --git a/fix-gnulib.pl b/fix-gnulib.pl index b8185fa..834fb7a 100755 --- a/fix-gnulib.pl +++ b/fix-gnulib.pl @@ -111,6 +111,14 @@ EOF # 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"; -- 2.43.2