unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* libtool-less shared library building
@ 2010-01-20 20:07 Ben Gamari
  2010-01-20 20:07 ` [PATCH] Build and link against notmuch shared library Ben Gamari
  2010-01-20 20:18 ` libtool-less shared library building David Bremner
  0 siblings, 2 replies; 18+ messages in thread
From: Ben Gamari @ 2010-01-20 20:07 UTC (permalink / raw)
  To: notmuch, cworth

Here is a short patch to build libnotmuch.so and link against the notmuch
binary against it. I think the notmuch rule in Makefile.local is probably
missing a dependency on lib/libnotmuch.so, but I wasn't sure how to specify it
without having it be added to the linker command line.

Let me know what you think. Thanks!

- Ben

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Build and link against notmuch shared library
  2010-01-20 20:07 libtool-less shared library building Ben Gamari
@ 2010-01-20 20:07 ` Ben Gamari
  2010-01-20 20:20   ` Mike Hommey
  2010-01-20 20:18 ` libtool-less shared library building David Bremner
  1 sibling, 1 reply; 18+ messages in thread
From: Ben Gamari @ 2010-01-20 20:07 UTC (permalink / raw)
  To: notmuch, cworth

---
 Makefile.local     |    5 +++--
 lib/Makefile.local |    8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 933ff4c..6e851e4 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -21,8 +21,8 @@ notmuch_client_srcs =		\
 	show-message.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)
+	$(call quiet,CXX,$(LDFLAGS)) -lnotmuch $^ $(FINAL_LDFLAGS) -o $@
 
 notmuch.1.gz: notmuch.1
 	$(call quiet,gzip) --stdout $^ > $@
@@ -33,6 +33,7 @@ install: all notmuch.1.gz
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
+	install lib/libnotmuch.so $(DESTDIR)$(prefix)/lib/
 	install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
 
 install-emacs: install emacs
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 70489e1..5e5a6e6 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,8 @@ 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 -o $@
 
 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
-CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a
+CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.so
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: libtool-less shared library building
  2010-01-20 20:07 libtool-less shared library building Ben Gamari
  2010-01-20 20:07 ` [PATCH] Build and link against notmuch shared library Ben Gamari
@ 2010-01-20 20:18 ` David Bremner
  2010-01-20 20:35   ` [PATCH] Build and link against notmuch shared library Ben Gamari
  1 sibling, 1 reply; 18+ messages in thread
From: David Bremner @ 2010-01-20 20:18 UTC (permalink / raw)
  To: Ben Gamari, notmuch, cworth

On Wed, 20 Jan 2010 15:07:26 -0500, Ben Gamari <bgamari.foss@gmail.com> wrote:
> Here is a short patch to build libnotmuch.so and link against the notmuch
> binary against it. I think the notmuch rule in Makefile.local is probably
> missing a dependency on lib/libnotmuch.so, but I wasn't sure how to specify it
> without having it be added to the linker command line.

It looks like that doesn't set an soname. Technically this isn't hard,
just add -Wl,-soname=$(SONAME) to the g++ command line. But keeping
track of when the soname should be bumped is a more challenging
enterprise.

d

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Build and link against notmuch shared library
  2010-01-20 20:07 ` [PATCH] Build and link against notmuch shared library Ben Gamari
@ 2010-01-20 20:20   ` Mike Hommey
  0 siblings, 0 replies; 18+ messages in thread
From: Mike Hommey @ 2010-01-20 20:20 UTC (permalink / raw)
  To: Ben Gamari; +Cc: notmuch

On Wed, Jan 20, 2010 at 03:07:27PM -0500, Ben Gamari wrote:
> +	install lib/libnotmuch.so $(DESTDIR)$(prefix)/lib/

> +$(dir)/libnotmuch.so: $(libnotmuch_modules)
> +	$(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -shared -o $@

If you're going to install that in $(prefix)/lib, you'd better make that
a library with a SONAME. -Wl,-soname,$(notdir $@) should do it, and
you'd obviously have to change the target name to add a SO version.

Mike

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Build and link against notmuch shared library
  2010-01-20 20:18 ` libtool-less shared library building David Bremner
@ 2010-01-20 20:35   ` Ben Gamari
  2010-01-23  0:58     ` Felipe Contreras
  0 siblings, 1 reply; 18+ messages in thread
From: Ben Gamari @ 2010-01-20 20:35 UTC (permalink / raw)
  To: notmuch, cworth

How's this look?


---
 Makefile           |    1 +
 Makefile.local     |    6 ++++--
 lib/Makefile.local |   10 ++++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 021fdb8..0f56bc6 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 933ff4c..71bd639 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -21,8 +21,8 @@ notmuch_client_srcs =		\
 	show-message.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,CXX,$(LDFLAGS)) -lnotmuch $(filter-out lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@
 
 notmuch.1.gz: notmuch.1
 	$(call quiet,gzip) --stdout $^ > $@
@@ -33,6 +33,8 @@ install: all notmuch.1.gz
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
+	install lib/$(SONAME) $(DESTDIR)$(prefix)/lib/
+	ln -sf $(DESTDIR)$(prefix)/lib/$(SONAME) $(DESTDIR)$(prefix)/lib/libnotmuch.so
 	install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
 
 install-emacs: install emacs
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 70489e1..cfefc9b 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,10 @@ 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)/$(SONAME): $(libnotmuch_modules)
+	$(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -Wl,-soname=$(SONAME) -shared -o $@
+$(dir)/libnotmuch.so: $(dir)/$(SONAME)
+	ln -sf $(dir)/$(SONAME) $(dir)/libnotmuch.so
 
 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
-CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a
+CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/libnotmuch.so $(dir)/$(SONAME)
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] Build and link against notmuch shared library
  2010-01-20 20:35   ` [PATCH] Build and link against notmuch shared library Ben Gamari
@ 2010-01-23  0:58     ` Felipe Contreras
  2010-01-23  2:06       ` Ingmar Vanhassel
  2010-01-23 18:35       ` Ben Gamari
  0 siblings, 2 replies; 18+ messages in thread
From: Felipe Contreras @ 2010-01-23  0:58 UTC (permalink / raw)
  To: Ben Gamari; +Cc: notmuch

On Wed, Jan 20, 2010 at 10:35 PM, Ben Gamari <bgamari.foss@gmail.com> wrote:
>  libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
> -$(dir)/notmuch.a: $(libnotmuch_modules)
> -       $(call quiet,AR) rcs $@ $^
> +$(dir)/$(SONAME): $(libnotmuch_modules)
> +       $(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -Wl,-soname=$(SONAME) -shared -o $@

Does it need to be CXX? Why not CC instead?

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Build and link against notmuch shared library
  2010-01-23  0:58     ` Felipe Contreras
@ 2010-01-23  2:06       ` Ingmar Vanhassel
  2010-01-23 18:58         ` bgamari.foss
  2010-01-23 18:35       ` Ben Gamari
  1 sibling, 1 reply; 18+ messages in thread
From: Ingmar Vanhassel @ 2010-01-23  2:06 UTC (permalink / raw)
  To: Felipe Contreras, Ben Gamari; +Cc: notmuch

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

On Sat, 23 Jan 2010 02:58:53 +0200, Felipe Contreras <felipe.contreras@gmail.com> wrote:
> On Wed, Jan 20, 2010 at 10:35 PM, Ben Gamari <bgamari.foss@gmail.com> wrote:
> >  libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
> > -$(dir)/notmuch.a: $(libnotmuch_modules)
> > -       $(call quiet,AR) rcs $@ $^
> > +$(dir)/$(SONAME): $(libnotmuch_modules)
> > +       $(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -Wl,-soname=$(SONAME) -shared -o $@
> 
> Does it need to be CXX? Why not CC instead?

Xapian and the notmuch wrapper 'parts' are written in C++.

-- 
Exherbo KDE, X.org maintainer

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Build and link against notmuch shared library
  2010-01-23  0:58     ` Felipe Contreras
  2010-01-23  2:06       ` Ingmar Vanhassel
@ 2010-01-23 18:35       ` Ben Gamari
  1 sibling, 0 replies; 18+ messages in thread
From: Ben Gamari @ 2010-01-23 18:35 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: notmuch

Excerpts from Felipe Contreras's message of Fri Jan 22 19:58:53 -0500 2010:
> Does it need to be CXX? Why not CC instead?
> 
Nope. It's been changed to CC. Thanks!

- Ben

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Build and link against notmuch shared library
  2010-01-23  2:06       ` Ingmar Vanhassel
@ 2010-01-23 18:58         ` bgamari.foss
  2010-01-24 21:23           ` [PATCH] Notmuch " Ben Gamari
  2010-01-25  1:00           ` [PATCH] " Scott Robinson
  0 siblings, 2 replies; 18+ messages in thread
From: bgamari.foss @ 2010-01-23 18:58 UTC (permalink / raw)
  To: Felipe Contreras, notmuch

Excerpts from Ingmar Vanhassel's message of Fri Jan 22 21:06:00 -0500 2010:
> On Sat, 23 Jan 2010 02:58:53 +0200, Felipe Contreras <felipe.contreras@gmail.com> wrote:
> > Does it need to be CXX? Why not CC instead?
> 
> Xapian and the notmuch wrapper 'parts' are written in C++.
> 
True, but I don't think that this means that we need to link the
executable with a C++ compiler. I've tried linking with CC and it seems
to succeed, so I don't think there should be a problem changing it.

- Ben

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Notmuch shared library
  2010-01-23 18:58         ` bgamari.foss
@ 2010-01-24 21:23           ` Ben Gamari
  2010-01-24 21:23             ` [PATCH 1/2] Fix typo in message Ben Gamari
  2010-01-25  1:00           ` [PATCH] " Scott Robinson
  1 sibling, 1 reply; 18+ messages in thread
From: Ben Gamari @ 2010-01-24 21:23 UTC (permalink / raw)
  To: notmuch, cworth

Here is what I believe should be the final set of patches building notmuch as a
shared library. Everything seems to work. Let me know if there are any
objections.

Thanks!
- Ben

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/2] Fix typo in message
  2010-01-24 21:23           ` [PATCH] Notmuch " Ben Gamari
@ 2010-01-24 21:23             ` Ben Gamari
  2010-01-24 21:23               ` [PATCH 2/2] Build and link against notmuch shared library Ben Gamari
  0 siblings, 1 reply; 18+ messages in thread
From: Ben Gamari @ 2010-01-24 21:23 UTC (permalink / raw)
  To: notmuch, cworth

---
 vim/plugin/notmuch.vim |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/vim/plugin/notmuch.vim b/vim/plugin/notmuch.vim
index a226f20..a9754f2 100644
--- a/vim/plugin/notmuch.vim
+++ b/vim/plugin/notmuch.vim
@@ -178,7 +178,7 @@ let g:notmuch_compose_imaps = {
 
 function! s:NM_cmd_folders(words)
         if len(a:words)
-                throw 'Not exapecting any arguments for folders command.'
+                throw 'Not expecting any arguments for folders command.'
         endif
         let cmd = ['count']
         let disp = []
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/2] Build and link against notmuch shared library
  2010-01-24 21:23             ` [PATCH 1/2] Fix typo in message Ben Gamari
@ 2010-01-24 21:23               ` Ben Gamari
  2010-03-04  8:25                 ` Sebastian Spaeth
  0 siblings, 1 reply; 18+ messages in thread
From: Ben Gamari @ 2010-01-24 21:23 UTC (permalink / raw)
  To: notmuch, cworth

---
 Makefile           |    1 +
 Makefile.local     |    6 ++++--
 lib/Makefile.local |   10 ++++++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 64b9d4a..6f296bb 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 d579242..a61eb67 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -21,8 +21,8 @@ notmuch_client_srcs =		\
 	show-message.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)) -lnotmuch $(filter-out lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@
 
 notmuch.1.gz: notmuch.1
 	$(call quiet,gzip) --stdout $^ > $@
@@ -33,6 +33,8 @@ install: all notmuch.1.gz
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
+	install lib/$(SONAME) $(DESTDIR)$(prefix)/lib/
+	ln -sf $(DESTDIR)$(prefix)/lib/$(SONAME) $(DESTDIR)$(prefix)/lib/libnotmuch.so
 	install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
 
 install-emacs: install emacs
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 70489e1..cfefc9b 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,10 @@ 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)/$(SONAME): $(libnotmuch_modules)
+	$(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -Wl,-soname=$(SONAME) -shared -o $@
+$(dir)/libnotmuch.so: $(dir)/$(SONAME)
+	ln -sf $(dir)/$(SONAME) $(dir)/libnotmuch.so
 
 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
-CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a
+CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/libnotmuch.so $(dir)/$(SONAME)
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] Build and link against notmuch shared library
  2010-01-23 18:58         ` bgamari.foss
  2010-01-24 21:23           ` [PATCH] Notmuch " Ben Gamari
@ 2010-01-25  1:00           ` Scott Robinson
  1 sibling, 0 replies; 18+ messages in thread
From: Scott Robinson @ 2010-01-25  1:00 UTC (permalink / raw)
  To: notmuch

Excerpts from bgamari.foss's message of Sat Jan 23 12:58:42 -0600 2010:
> True, but I don't think that this means that we need to link the
> executable with a C++ compiler. I've tried linking with CC and it seems
> to succeed, so I don't think there should be a problem changing it.
> 

Are you using "cc" or "gcc"?

Even when cc is an alias to gcc, there are different semantics. And "cc" vs.
"cpp" can be even more different on non-GCC compilers.

I wouldn't mess with it. :-)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Build and link against notmuch shared library
  2010-01-26  5:38 [PATCH] Add SWIG interface file Ben Gamari
@ 2010-01-26  6:15 ` Ben Gamari
  0 siblings, 0 replies; 18+ messages in thread
From: Ben Gamari @ 2010-01-26  6:15 UTC (permalink / raw)
  To: notmuch

Inger in #notmuch brought to light some build issues that will occur when the
notmuch binary is being built before libnotmuch is installed. Here is an
updated patch that resolves these issues.

---
 .gitignore         |    1 +
 Makefile           |    1 +
 Makefile.local     |    6 ++++--
 lib/Makefile.local |    9 +++++----
 4 files changed, 11 insertions(+), 6 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 64b9d4a..6f296bb 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 04bac83..5b6af0a 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -21,8 +21,8 @@ notmuch_client_srcs =		\
 	show-message.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 $^ > $@
@@ -33,6 +33,8 @@ install: all notmuch.1.gz
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
+	install lib/$(SONAME) $(DESTDIR)$(prefix)/lib/
+	ln -sf $(DESTDIR)$(prefix)/lib/$(SONAME) $(DESTDIR)$(prefix)/lib/libnotmuch.so
 	install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/
 
 install-emacs: install emacs
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 70489e1..a6462ae 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.6.3.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/2] Build and link against notmuch shared library
  2010-01-24 21:23               ` [PATCH 2/2] Build and link against notmuch shared library Ben Gamari
@ 2010-03-04  8:25                 ` Sebastian Spaeth
  2010-03-11 22:41                   ` Ben Gamari
  0 siblings, 1 reply; 18+ messages in thread
From: Sebastian Spaeth @ 2010-03-04  8:25 UTC (permalink / raw)
  To: Ben Gamari, notmuch, cworth

>  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)) -lnotmuch $(filter-out lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@

I just tried out this patch to compile notmuch as a shared library and
while producing lib/libnotmuch.so.1 it fails to find notmuch later:

CC 	notmuch
/usr/bin/ld: cannot find -lnotmuch

Aso it creates libnotmuch.so.1 in lib but seems to try symlinking it in
the "compat" dir which fails and produces a dead symlink.

CXX 	lib/libnotmuch.so.1
ln -sf compat/libnotmuch.so.1 compat/libnotmuch.so

Is more needed than this patch? Also, *I* think it would be nice to
support --static or --shared as options to --configure. But that is a
minor thing, probably.

Sebastian

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] Build and link against notmuch shared library
  2010-03-11 22:37 Notmuch " Ben Gamari
@ 2010-03-11 22:37 ` Ben Gamari
  0 siblings, 0 replies; 18+ messages in thread
From: Ben Gamari @ 2010-03-11 22:37 UTC (permalink / raw)
  To: notmuch

---
 .gitignore         |    1 +
 Makefile           |    1 +
 Makefile.local     |    9 ++++++---
 lib/Makefile.local |   11 ++++++-----
 4 files changed, 14 insertions(+), 8 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..38cecd1 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -20,18 +20,21 @@ 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)/share/man/man1 \
+		$(DESTDIR)$(prefix)/lib/ ; \
 	do \
 		install -d $$d ; \
 	done ;
 	install notmuch $(DESTDIR)$(prefix)/bin/
+	install lib/$(SONAME) $(DESTDIR)$(prefix)/lib/
+	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..a6462ae 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -1,5 +1,5 @@
-dir := lib
-extra_cflags += -I$(dir)
+dir=lib
+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

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/2] Build and link against notmuch shared library
  2010-03-04  8:25                 ` Sebastian Spaeth
@ 2010-03-11 22:41                   ` Ben Gamari
  2010-03-12 15:04                     ` Sebastian Spaeth
  0 siblings, 1 reply; 18+ messages in thread
From: Ben Gamari @ 2010-03-11 22:41 UTC (permalink / raw)
  To: Sebastian Spaeth, notmuch, cworth

On Thu, 04 Mar 2010 09:25:45 +0100, "Sebastian Spaeth" <Sebastian@SSpaeth.de> wrote:
> I just tried out this patch to compile notmuch as a shared library and
> while producing lib/libnotmuch.so.1 it fails to find notmuch later:

Try the version I just posted. It will apply against master and builds on my machine.

> Is more needed than this patch? Also, *I* think it would be nice to
> support --static or --shared as options to --configure. But that is a
> minor thing, probably.

What do others think about this? Would it be useful, counter-productive, or
none of the above to allow configuration of the library type?

Cheers,

- Ben

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/2] Build and link against notmuch shared library
  2010-03-11 22:41                   ` Ben Gamari
@ 2010-03-12 15:04                     ` Sebastian Spaeth
  0 siblings, 0 replies; 18+ messages in thread
From: Sebastian Spaeth @ 2010-03-12 15:04 UTC (permalink / raw)
  To: Ben Gamari, notmuch, cworth

On Thu, 11 Mar 2010 14:41:09 -0800 (PST), Ben Gamari <bgamari.foss@gmail.com> wrote:
> On Thu, 04 Mar 2010 09:25:45 +0100, "Sebastian Spaeth" <Sebastian@SSpaeth.de> wrote:
> > I just tried out this patch to compile notmuch as a shared library and
> > while producing lib/libnotmuch.so.1 it fails to find notmuch later:
> 
> Try the version I just posted. It will apply against master and builds on my machine.

Using the updated patch and a stock cworth/master I still got that
error. Using the updated patchset that was just posted and builds on
your work, it compiled and installed fine (but failed to find
libnotmuch.so.1 in /usr/local/lib)

I don't think I have a special setup on this box, so I wonder why it did
not work for me.

spaetz

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2010-03-12 15:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-20 20:07 libtool-less shared library building Ben Gamari
2010-01-20 20:07 ` [PATCH] Build and link against notmuch shared library Ben Gamari
2010-01-20 20:20   ` Mike Hommey
2010-01-20 20:18 ` libtool-less shared library building David Bremner
2010-01-20 20:35   ` [PATCH] Build and link against notmuch shared library Ben Gamari
2010-01-23  0:58     ` Felipe Contreras
2010-01-23  2:06       ` Ingmar Vanhassel
2010-01-23 18:58         ` bgamari.foss
2010-01-24 21:23           ` [PATCH] Notmuch " Ben Gamari
2010-01-24 21:23             ` [PATCH 1/2] Fix typo in message Ben Gamari
2010-01-24 21:23               ` [PATCH 2/2] Build and link against notmuch shared library Ben Gamari
2010-03-04  8:25                 ` Sebastian Spaeth
2010-03-11 22:41                   ` Ben Gamari
2010-03-12 15:04                     ` Sebastian Spaeth
2010-01-25  1:00           ` [PATCH] " Scott Robinson
2010-01-23 18:35       ` Ben Gamari
  -- strict thread matches above, loose matches on Subject: below --
2010-01-26  5:38 [PATCH] Add SWIG interface file Ben Gamari
2010-01-26  6:15 ` [PATCH] Build and link against notmuch shared library Ben Gamari
2010-03-11 22:37 Notmuch " Ben Gamari
2010-03-11 22:37 ` [PATCH] Build and link against notmuch " Ben Gamari

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).