]> git.notmuchmail.org Git - notmuch/commitdiff
Add infrastructure for building shared library on OS X.
authorAaron Ecay <aaronecay@gmail.com>
Sun, 11 Apr 2010 23:44:53 +0000 (19:44 -0400)
committerCarl Worth <cworth@cworth.org>
Wed, 14 Apr 2010 23:10:27 +0000 (16:10 -0700)
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.local
configure
lib/Makefile.local

index 0f99e3f9d9d3c3253f6256ed3de1acf1d4b6a639..79ac50d4ff555b736a3d78fcfb89843839ed50e0 100644 (file)
@@ -199,7 +199,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
index 90a399cab63d736192e18840e58fd82890dcca3e..8af3dc9e24db5ec8c58758eea7ca83147a17bf5d 100755 (executable)
--- 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
 
@@ -399,6 +408,10 @@ HAVE_GETLINE = ${have_getline}
 # build its own version)
 HAVE_STRCASESTR = ${have_strcasestr}
 
+# 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}
index dc608ef0994c4b86b76ec3af16c23a5fb5fc7981..f001e75b9a01040490f3d464350f9cbc5c330195 100644 (file)
@@ -22,9 +22,20 @@ 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
@@ -52,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) $@