[notmuch] [PATCH 1/3] Build and link against notmuch shared library, install notmuch.h

Ingmar Vanhassel ingmar at exherbo.org
Fri Mar 12 05:47:34 PST 2010


From: Ben Gamari <bgamari.foss at gmail.com>

Signed-off-by: Ingmar Vanhassel <ingmar at exherbo.org>
---
 .gitignore         |    1 +
 Makefile           |    1 +
 Makefile.local     |   10 +++++++---
 lib/Makefile.local |    9 +++++----
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/.gitignore b/.gitignore
index efa98fb..daf8094 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ tags
 .deps
 notmuch
 notmuch.1.gz
+libnotmuch.so*
 *.[ao]
 *~
 .*.swp
diff --git a/Makefile b/Makefile
index 46f001c..80eedd0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+SONAME = libnotmuch.so.1
 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations
 
diff --git a/Makefile.local b/Makefile.local
index 3c2a629..31ab534 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -20,18 +20,22 @@ notmuch_client_srcs =		\
 	json.c
 
 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
-notmuch: $(notmuch_client_modules) lib/notmuch.a
-	$(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
+notmuch: $(notmuch_client_modules) lib/libnotmuch.so
+	$(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(filter-out lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@
 
 notmuch.1.gz: notmuch.1
 	$(call quiet,gzip) --stdout $^ > $@
 
 install: all notmuch.1.gz
-	for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/share/man/man1 ; \
+	for d in $(DESTDIR)$(prefix)/bin/ $(DESTDIR)$(prefix)/lib/ \
+		$(DESTDIR)$(prefix)/include/ $(DESTDIR)$(prefix)/share/man/man1 ; \
 	do \
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
+	install lib/$(SONAME) $(DESTDIR)$(prefix)/lib/
+	install lib/notmuch.h $(DESTDIR)$(prefix)/include/
+	ln -sf $(SONAME) $(DESTDIR)$(prefix)/lib/libnotmuch.so
 	install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
 ifeq ($(MAKECMDGOALS), install)
 	@echo ""
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 495b27e..f848946 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -1,5 +1,5 @@
 dir := lib
-extra_cflags += -I$(dir)
+extra_cflags += -I$(dir) -fPIC
 
 libnotmuch_c_srcs =		\
 	$(dir)/libsha1.c	\
@@ -18,8 +18,9 @@ libnotmuch_cxx_srcs =		\
 	$(dir)/thread.cc
 
 libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
-$(dir)/notmuch.a: $(libnotmuch_modules)
-	$(call quiet,AR) rcs $@ $^
+$(dir)/libnotmuch.so : $(libnotmuch_modules)
+	$(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -shared -Wl,-soname=$(SONAME) -o $@
+	ln -sf $(SONAME) $@
 
 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
-CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a
+CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/libnotmuch.so *.so
-- 
1.7.0.2



More information about the notmuch mailing list