[PATCH 6/8] Fix linking shared library on Cygwin

Subject:[PATCH 6/8] Fix linking shared library on Cygwin

Date:Tue, 22 Aug 2017 22:43:37 +0000

To:notmuch@notmuchmail.org

Cc:Vladimir Panteleev

From:Vladimir Panteleev


From: Vladimir Panteleev <vladimir@thecybershadow.net>

Apparently due to historical reasons, when given -lfoo, Cygwin's ld
will prefer to link against libfoo.a over libfoo.so (or even
libfoo.dll). As such, we need to explicitly specify the library file
name when on Cygwin to avoid creating a broken notmuch-shared binary.

* Makefile.global: Use -l:libnotmuch.so instead of -lnotmuch on
  Cygwin.
---
 Makefile.global | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Makefile.global b/Makefile.global
index 5d10bff7..0b536302 100644
--- a/Makefile.global
+++ b/Makefile.global
@@ -48,11 +48,19 @@ GPG_FILE=$(SHA256_FILE).asc
 
 PV_FILE=bindings/python/notmuch/version.py
 
+# Cygwin's linker prefers .a files over shared objects, so indicate
+# that we want to link against the shared library explicitly.
+ifeq ($(PLATFORM),CYGWIN)
+NOTMUCH_LIBRARY_FLAG=-l:libnotmuch.so
+else
+NOTMUCH_LIBRARY_FLAG=-lnotmuch
+endif
+
 # Smash together user's values with our extra values
 STD_CFLAGS := -std=gnu99
 FINAL_CFLAGS = -DNOTMUCH_VERSION=$(VERSION) $(CPPFLAGS) $(STD_CFLAGS) $(CFLAGS) $(WARN_CFLAGS) $(extra_cflags) $(CONFIGURE_CFLAGS)
 FINAL_CXXFLAGS = $(CPPFLAGS) $(CXXFLAGS) $(WARN_CXXFLAGS) $(extra_cflags) $(extra_cxxflags) $(CONFIGURE_CXXFLAGS)
-FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Lutil -lnotmuch_util -Llib -lnotmuch
+FINAL_NOTMUCH_LDFLAGS = $(LDFLAGS) -Lutil -lnotmuch_util -Llib $(NOTMUCH_LIBRARY_FLAG)
 ifeq ($(LIBDIR_IN_LDCONFIG),0)
 FINAL_NOTMUCH_LDFLAGS += $(RPATH_LDFLAGS)
 endif
-- 
2.13.3

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: