From: Aaron Ecay <aaronecay@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH 3/4] Add infrastructure for building shared library on OS X.
Date: Sun, 11 Apr 2010 19:44:53 -0400 [thread overview]
Message-ID: <1271029494-89014-3-git-send-email-aaronecay@gmail.com> (raw)
In-Reply-To: <4bc25ea0.86c3f10a.45a3.ffff80d3@mx.google.com>
This patch adds a configure check for OS X (actually Darwin),
and sets up the Makefiles to build a proper shared library on
that platform.
Signed-off-by: Aaron Ecay <aaronecay@gmail.com>
---
Makefile | 2 +-
Makefile.local | 2 +-
configure | 13 +++++++++++++
lib/Makefile.local | 16 ++++++++++++++--
4 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index faaaec6..86e08fa 100644
--- a/Makefile
+++ b/Makefile
@@ -18,4 +18,4 @@ extra_cxxflags :=
# Finally, include all of the Makefile.local fragments where all the
# real work is done.
-include $(subdirs:%=%/Makefile.local) Makefile.local
+include Makefile.config $(subdirs:%=%/Makefile.local) Makefile.local
diff --git a/Makefile.local b/Makefile.local
index c04044c..99d5b64 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -213,7 +213,7 @@ notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
notmuch: $(notmuch_client_modules) lib/libnotmuch.a
$(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
-notmuch-shared: $(notmuch_client_modules) lib/libnotmuch.so
+notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
$(call quiet,CXX $(CFLAGS)) $(notmuch_client_modules) $(FINAL_NOTMUCH_LDFLAGS) -o $@
notmuch.1.gz: notmuch.1
diff --git a/configure b/configure
index 5af7852..da45572 100755
--- a/configure
+++ b/configure
@@ -234,6 +234,15 @@ else
have_emacs=0
fi
+printf "Checking for Mac OS X (for shared library)... "
+if [ `uname` = "Darwin" ] ; then
+ printf "Yes.\n"
+ mac_os_x=1
+else
+ printf "No.\n"
+ mac_os_x=0
+fi
+
if [ $errors -gt 0 ]; then
cat <<EOF
@@ -384,6 +393,10 @@ zsh_completion_dir = \$(prefix)/share/zsh/functions/Completion/Unix
# build its own version)
HAVE_GETLINE = ${have_getline}
+# Whether we are building on OS X. This will affect how we build the
+# shared library.
+MAC_OS_X = ${mac_os_x}
+
# Flags needed to compile and link against Xapian
XAPIAN_CXXFLAGS = ${xapian_cxxflags}
XAPIAN_LDFLAGS = ${xapian_ldflags}
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 0e3a4d1..7e73810 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -22,14 +22,26 @@ LIBNOTMUCH_VERSION_MINOR = 0
# simply compatible changes to the implementation).
LIBNOTMUCH_VERSION_RELEASE = 0
-LINKER_NAME = libnotmuch.so
+ifeq ($(MAC_OS_X),1)
+LIBRARY_SUFFIX = dylib
+# On OS X, library version numbers go before suffix.
+LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
+SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)
+LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)
+LIBRARY_LINK_FLAG = -Wl,-dylib_install_name -Wl,$(SONAME)
+else
+LIBRARY_SUFFIX = so
+LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
+LIBRARY_LINK_FLAG = -Wl,-soname=$(SONAME)
+endif
dir := lib
extra_cflags += -I$(dir) -fPIC
libnotmuch_c_srcs = \
+ $(notmuch_compat_srcs) \
$(dir)/libsha1.c \
$(dir)/message-file.c \
$(dir)/messages.c \
@@ -51,7 +63,7 @@ $(dir)/libnotmuch.a: $(libnotmuch_modules)
$(call quiet,AR) rcs $@ $^
$(dir)/$(LIBNAME): $(libnotmuch_modules)
- $(call quiet,CXX $(CXXFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -shared -Wl,-soname=$(SONAME) -o $@
+ $(call quiet,CXX $(CXXFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -shared $(LIBRARY_LINK_FLAG) -o $@
$(dir)/$(SONAME): $(dir)/$(LIBNAME)
ln -sf $(LIBNAME) $@
--
1.7.0.4
next prev parent reply other threads:[~2010-04-11 23:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-11 23:43 Build problems on OS X Aaron Ecay
2010-04-11 23:44 ` [PATCH 1/4] Use C++ compiler to link notmuch binaries Aaron Ecay
2010-04-14 17:39 ` Carl Worth
2010-04-11 23:44 ` [PATCH 2/4] Fix up Makefile for build Aaron Ecay
2010-04-14 17:47 ` Carl Worth
2010-04-11 23:44 ` Aaron Ecay [this message]
2010-04-14 18:01 ` [PATCH 3/4] Add infrastructure for building shared library on OS X Carl Worth
2010-04-14 18:47 ` Carl Worth
2010-04-14 23:39 ` Carl Worth
2010-04-11 23:44 ` [PATCH 4/4] Add CONFIGURE_LDFLAGS to the notmuch-shared buld command line Aaron Ecay
2010-04-14 18:04 ` Carl Worth
2010-04-14 17:37 ` Build problems on OS X Carl Worth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1271029494-89014-3-git-send-email-aaronecay@gmail.com \
--to=aaronecay@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).