[PATCH 6/8] Fix linking shared library on Cygwin
Vladimir Panteleev
notmuch at thecybershadow.net
Tue Aug 22 15:43:37 PDT 2017
From: Vladimir Panteleev <vladimir at 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
More information about the notmuch
mailing list