Portions of gnulib depend on -lintl, and cygwin does not allow
lazy linking.

* src/Makefile.am (LDADD): Include libraries in correct order.

Signed-off-by: Eric Blake <[email protected]>
---

> Can you confirm that the equivalent also solves the Cygwin
> build problem?

Yes, the build still succeeds.  Okay to push?

 src/Makefile.am |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 5376b97..08f7aac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,7 +28,13 @@ noinst_LIBRARIES = libgrep.a
 libgrep_a_SOURCES = kwset.c dfa.c searchutils.c dfasearch.c kwsearch.c \
        pcresearch.c main.c

-LDADD = $(LIBINTL) libgrep.a ../lib/libgreputils.a
+# Sometimes, the expansion of $(LIBINTL) includes -lc which may
+# include modules defining variables like `optind', so libgreputils.a
+# must precede $(LIBINTL) in order to ensure we use GNU getopt.
+# But libgreputils.a must also follow $(LIBINTL), since libintl uses
+# replacement functions defined in libgreputils.a.
+LDADD = libgrep.a ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a
+
 grep_LDADD = $(LDADD) $(PCRE_LIBS)
 localedir = $(datadir)/locale
 INCLUDES = -I$(top_srcdir)/lib -DLOCALEDIR=\"$(localedir)\"
-- 
1.6.6.1



Reply via email to