unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] configure: add ${NOTMUCH_SRCDIR} -- absolute path to notmuch source
@ 2016-12-03 12:53 Tomi Ollila
  2016-12-03 12:53 ` [PATCH 2/3] fix out of tree build Tomi Ollila
  2016-12-03 12:53 ` [PATCH 3/3] fix out of tree tests Tomi Ollila
  0 siblings, 2 replies; 6+ messages in thread
From: Tomi Ollila @ 2016-12-03 12:53 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

The ${srcdir} -- usually relative path to notmuch source -- works fine
in current ./configure and all makefiles. To have simple access to
notmuch source in tests and out of tree builds holding absolute path to
the source directory is useful.
---
 configure | 8 ++++++++
 1 file changed, 8 insertions(+)

Version 3 of id:1480099848-17636-1-git-send-email-too@guru.guru-group.fi
now adding variable holding absolute path to notmuch source to *.config
files in ./configure

diff --git a/configure b/configure
index 72db26d..174b24a 100755
--- a/configure
+++ b/configure
@@ -19,7 +19,12 @@ To work around this problem you may try to execute:
 # Store original IFS value so it can be changed (and restored) in many places.
 readonly DEFAULT_IFS="$IFS"
 
+# The top-level directory for the source. This ./configure and all Makefiles
+# are good with ${srcdir} usually being relative. Some components (e.g. tests)
+# are executed in subdirectories and for those it is simpler to use
+# ${NOTMUCH_SRCDIR} which holds absolute path to the source.
 srcdir=$(dirname "$0")
+NOTMUCH_SRCDIR=$(cd "$srcdir" && pwd)
 
 subdirs="util compat lib parse-time-string completion doc emacs"
 subdirs="${subdirs} performance-test test test/test-databases"
@@ -927,6 +932,7 @@ cat > Makefile.config <<EOF
 # the configure script). This may be different than the build
 # directory (the current directory at the time configure was run).
 srcdir = ${srcdir}
+NOTMUCH_SRCDIR = ${NOTMUCH_SRCDIR}
 
 # subdirectories to build
 subdirs = ${subdirs}
@@ -1182,6 +1188,8 @@ cat > sh.config <<EOF
 # This sh.config was automatically generated by the ./configure
 # script of notmuch.
 
+NOTMUCH_SRCDIR='${NOTMUCH_SRCDIR}'
+
 # Whether the Xapian version in use supports compaction
 NOTMUCH_HAVE_XAPIAN_COMPACT=${have_xapian_compact}
 
-- 
2.10.0

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

* [PATCH 2/3] fix out of tree build
  2016-12-03 12:53 [PATCH 1/3] configure: add ${NOTMUCH_SRCDIR} -- absolute path to notmuch source Tomi Ollila
@ 2016-12-03 12:53 ` Tomi Ollila
  2017-03-10 17:24   ` David Bremner
  2016-12-03 12:53 ` [PATCH 3/3] fix out of tree tests Tomi Ollila
  1 sibling, 1 reply; 6+ messages in thread
From: Tomi Ollila @ 2016-12-03 12:53 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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

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

* [PATCH 3/3] fix out of tree tests
  2016-12-03 12:53 [PATCH 1/3] configure: add ${NOTMUCH_SRCDIR} -- absolute path to notmuch source Tomi Ollila
  2016-12-03 12:53 ` [PATCH 2/3] fix out of tree build Tomi Ollila
@ 2016-12-03 12:53 ` Tomi Ollila
  2017-03-10 17:25   ` David Bremner
  1 sibling, 1 reply; 6+ messages in thread
From: Tomi Ollila @ 2016-12-03 12:53 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

Use $NOTMUCH_SRCDIR/ instead of $TEST_DIRECTORY/../ (in those 2 places)
where refecence to source directory instead of build directory is
required.
---
 test/test-lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index f55d2c6..b08c425 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -1206,7 +1206,7 @@ test_emacs () {
 test_python() {
     # Note: if there is need to print debug information from python program,
     # use stdout = os.fdopen(6, 'w') or stderr = os.fdopen(7, 'w')
-    PYTHONPATH="$TEST_DIRECTORY/../bindings/python${PYTHONPATH:+:$PYTHONPATH}" \
+    PYTHONPATH="$NOTMUCH_SRCDIR/bindings/python${PYTHONPATH:+:$PYTHONPATH}" \
 	$NOTMUCH_PYTHON -B - > OUTPUT
 }
 
@@ -1218,7 +1218,7 @@ test_C () {
     exec_file="test${test_count}"
     test_file="${exec_file}.c"
     cat > ${test_file}
-    ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY} -I${TEST_DIRECTORY}/../lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc
+    ${TEST_CC} ${TEST_CFLAGS} -I${TEST_DIRECTORY} -I${NOTMUCH_SRCDIR}/lib -o ${exec_file} ${test_file} -L${TEST_DIRECTORY}/../lib/ -lnotmuch -ltalloc
     echo "== stdout ==" > OUTPUT.stdout
     echo "== stderr ==" > OUTPUT.stderr
     ./${exec_file} "$@" 1>>OUTPUT.stdout 2>>OUTPUT.stderr
-- 
2.10.0

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

* Re: [PATCH 2/3] fix out of tree build
  2016-12-03 12:53 ` [PATCH 2/3] fix out of tree build Tomi Ollila
@ 2017-03-10 17:24   ` David Bremner
  0 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2017-03-10 17:24 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

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

After apply the first two patches in this series,

% mkdir build && cd build && ../configure && make

works, but

% mkdir /tmp/foo && cd /tmp/foo && ~/software/upstream/notmuch/configure && make

does not.

Am I missing something?

d

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

* Re: [PATCH 3/3] fix out of tree tests
  2016-12-03 12:53 ` [PATCH 3/3] fix out of tree tests Tomi Ollila
@ 2017-03-10 17:25   ` David Bremner
  0 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2017-03-10 17:25 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> Use $NOTMUCH_SRCDIR/ instead of $TEST_DIRECTORY/../ (in those 2 places)
> where refecence to source directory instead of build directory is
> required.
> ---

If you're regenerating this anyway, theres a spelling mistake in the
commit message (refecence)

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

* [PATCH 2/3] fix out of tree build
  2017-03-12 11:59 [PATCH 1/3] configure: add ${NOTMUCH_SRCDIR} -- absolute path to notmuch source Tomi Ollila
@ 2017-03-12 11:59 ` Tomi Ollila
  0 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2017-03-12 11:59 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

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                | 10 ++++++++--
 3 files changed, 10 insertions(+), 3 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 bcfa416..6c782e1 100755
--- a/configure
+++ b/configure
@@ -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.9.3

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

end of thread, other threads:[~2017-03-12 11:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-03 12:53 [PATCH 1/3] configure: add ${NOTMUCH_SRCDIR} -- absolute path to notmuch source Tomi Ollila
2016-12-03 12:53 ` [PATCH 2/3] fix out of tree build Tomi Ollila
2017-03-10 17:24   ` David Bremner
2016-12-03 12:53 ` [PATCH 3/3] fix out of tree tests Tomi Ollila
2017-03-10 17:25   ` David Bremner
  -- strict thread matches above, loose matches on Subject: below --
2017-03-12 11:59 [PATCH 1/3] configure: add ${NOTMUCH_SRCDIR} -- absolute path to notmuch source Tomi Ollila
2017-03-12 11:59 ` [PATCH 2/3] fix out of tree build Tomi Ollila

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