]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
configure: add test for default xapian backend
authorDavid Bremner <david@tethera.net>
Sat, 9 Apr 2016 01:49:49 +0000 (22:49 -0300)
committerDavid Bremner <david@tethera.net>
Tue, 12 Apr 2016 23:14:43 +0000 (20:14 -0300)
This is mainly for the test suite.  We already expect the tests to be
run in the same environment as configure was run, at least to get the
name of the python interpreter. So we are not really imposing a new
restriction.

configure
test/test-lib.sh

index eb6dbacec82a3b1096bb8137298e068235cf7f2e..4fc31ccf8e79264b96ecb96d92794f295eb0205d 100755 (executable)
--- a/configure
+++ b/configure
@@ -371,7 +371,25 @@ if [ ${have_xapian} = "1" ]; then
     esac
 fi
 
-
+default_xapian_backend=""
+if [ ${have_xapian} = "1" ]; then
+    printf "Testing default Xapian backend... "
+    cat >_default_backend.cc <<EOF
+#include <xapian.h>
+int main(int argc, char** argv) {
+   Xapian::WritableDatabase db("test.db",Xapian::DB_CREATE_OR_OPEN);
+}
+EOF
+    ${CXX} ${CXXLAGS} ${xapian_cxxflags} _default_backend.cc -o _default_backend ${xapian_ldflags}
+    ./_default_backend
+    if [ -f test.db/iamglass ]; then
+       default_xapian_backend=glass
+    else
+       default_xapian_backend=chert
+    fi
+    printf "${default_xapian_backend}\n";
+    rm -rf test.db _default_backend _default_backend.cc
+fi
 # we need to have a version >= 2.6.5 to avoid a crypto bug. We need
 # 2.6.7 for permissive "From " header handling.
 GMIME_MINVER=2.6.7
@@ -1001,6 +1019,9 @@ LINKER_RESOLVES_LIBRARY_DEPENDENCIES = ${linker_resolves_library_dependencies}
 XAPIAN_CXXFLAGS = ${xapian_cxxflags}
 XAPIAN_LDFLAGS = ${xapian_ldflags}
 
+# Which backend will Xapian use by default?
+DEFAULT_XAPIAN_BACKEND = ${default_xapian_backend}
+
 # Flags needed to compile and link against GMime
 GMIME_CFLAGS = ${gmime_cflags}
 GMIME_LDFLAGS = ${gmime_ldflags}
@@ -1077,6 +1098,9 @@ cat > sh.config <<EOF
 # Whether the Xapian version in use supports compaction
 NOTMUCH_HAVE_XAPIAN_COMPACT=${have_xapian_compact}
 
+# Which backend will Xapian use by default?
+NOTMUCH_DEFAULT_XAPIAN_BACKEND=${default_xapian_backend}
+
 # do we have man pages?
 NOTMUCH_HAVE_MAN=$((have_sphinx))
 
index cc08a98cb5f5fd45e2ea900006da51da0db332a5..ac04b15a96ba1da2c1c36759a5b78c030602cd0e 100644 (file)
@@ -1327,6 +1327,17 @@ test -z "$NO_PYTHON" && test_set_prereq PYTHON
 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
 rm -f y
 
+# convert variable from configure to more convenient form
+case "$NOTMUCH_DEFAULT_XAPIAN_BACKEND" in
+    glass)
+       db_ending=glass
+    ;;
+    chert)
+       db_ending=DB
+    ;;
+    *)
+       error "Unknown Xapian backend $NOTMUCH_DEFAULT_XAPIAN_BACKEND"
+esac
 # declare prerequisites for external binaries used in tests
 test_declare_external_prereq dtach
 test_declare_external_prereq emacs