[PATCH 2/3] fix out of tree build

Tomi Ollila tomi.ollila at iki.fi
Sat Dec 3 04:53:23 PST 2016


In addition to use ${srcdir} and deliver ${NOTMUCH_SRCDIR} where needed,
source from ruby bindings had to be copied to the out-of-tree target
directory -- if the source files in source directory were referenced
in build and there were also built object files there, those could have
been considered as target files (and then not found when attempting
to create bindings/ruby/notmuch.so).
---
 bindings/Makefile.local  |  1 +
 bindings/ruby/extconf.rb |  2 +-
 configure                | 12 +++++++++---
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/bindings/Makefile.local b/bindings/Makefile.local
index 11d11d4..17b561c 100644
--- a/bindings/Makefile.local
+++ b/bindings/Makefile.local
@@ -8,6 +8,7 @@ ifeq ($(HAVE_RUBY_DEV),1)
 	cd $(dir)/ruby && \
 		EXTRA_LDFLAGS="$(NO_UNDEFINED_LDFLAGS)" \
 		LIBNOTMUCH="../../lib/$(LINKER_NAME)" \
+		NOTMUCH_SRCDIR='$(NOTMUCH_SRCDIR)' \
 		ruby extconf.rb --vendor
 	$(MAKE) -C $(dir)/ruby
 endif
diff --git a/bindings/ruby/extconf.rb b/bindings/ruby/extconf.rb
index ddaa684..161de5a 100644
--- a/bindings/ruby/extconf.rb
+++ b/bindings/ruby/extconf.rb
@@ -5,7 +5,7 @@
 
 require 'mkmf'
 
-dir = File.join('..', '..', 'lib')
+dir = File.join(ENV['NOTMUCH_SRCDIR'], 'lib')
 
 # includes
 $INCFLAGS = "-I#{dir} #{$INCFLAGS}"
diff --git a/configure b/configure
index 174b24a..9ea6fee 100755
--- a/configure
+++ b/configure
@@ -32,7 +32,7 @@ subdirs="${subdirs} bindings"
 
 # For a non-srcdir configure invocation (such as ../configure), create
 # the directory structure and copy Makefiles.
-if [ "$srcdir" != "." ]; then
+if [ "$srcdir" != "." ] && [ "$srcdir" != "$NOTMUCH_SRCDIR" ]; then
 
     for dir in . ${subdirs}; do
 	mkdir -p "$dir"
@@ -47,6 +47,12 @@ if [ "$srcdir" != "." ]; then
     # Emacs only likes to generate compiled files next to the .el files
     # by default so copy these as well (which is not ideal).
     cp -a "$srcdir"/emacs/*.el emacs
+
+    # We were not able to create fully working Makefile using ruby mkmf.rb
+    # so ruby bindings source files are copied as well (ditto -- not ideal).
+    mkdir bindings/ruby
+    cp -a "$srcdir"/bindings/ruby/*.[ch] bindings/ruby
+    cp -a "$srcdir"/bindings/ruby/extconf.rb bindings/ruby
 fi
 
 # Set several defaults (optionally specified by the user in
@@ -357,8 +363,8 @@ int main(void) {
     return 0;
 }
 EOF
-if ${CC} ${CFLAGS} _libversion.c -o _libversion > /dev/null 2>&1 && \
-       ./_libversion > _libversion.sh && . ./_libversion.sh
+if ${CC} ${CFLAGS} -I"$srcdir" _libversion.c -o _libversion > /dev/null 2>&1 \
+       && ./_libversion > _libversion.sh && . ./_libversion.sh
 then
     printf "OK.\n"
 else
-- 
2.10.0



More information about the notmuch mailing list