--- a/src/configure.ac
+++ b/src/configure.ac
@@ -3,31 +3,20 @@
 AC_PREREQ(2.53)
 AC_CONFIG_SRCDIR(index/recollindex.cpp)
 
+AM_INIT_AUTOMAKE([1.10 no-define subdir-objects foreign])
+AC_DISABLE_STATIC
+LT_INIT
+AC_CONFIG_MACRO_DIR([m4])
+
 AC_PROG_CXX
 if test C$CXX = C ; then
    AC_MSG_ERROR([C++ compiler needed. Please install one (ie: gnu g++)])
 fi
 
+AC_PROG_YACC
+
+AC_PROG_LIBTOOL
 AC_C_BIGENDIAN
-
-sys=`uname | tr / _ | awk -F_ '{print $1}'`
-
-if test ! -f mk/$sys ; then
-   AC_MSG_NOTICE([
-    No system configuration file found in mk/ for uname = '$sys'. 
-    Trying with Default file. 
-    If the build fails, you'll need to write a configuration file, starting 
-    from one of the existing ones.])
-
-    sys=Default   
-fi
-(cd mk; rm -f sysconf; ln -s $sys sysconf)
-
-# There a few Recoll users on Mac OS X and a few things are just not worth
-# supporting
-if test X$sys = XDarwin ; then
-   NODYNLIB=#
-fi
 
 AC_SYS_LARGEFILE
 
@@ -199,12 +188,9 @@
     AC_HELP_STRING([--disable-idxthreads],
    [Disable multithread indexing.]),
         idxthreadsEnabled=$enableval, idxthreadsEnabled=yes)
-
+AM_CONDITIONAL(NOTHREADS, [test X$idxthreadsEnabled = Xno])
 if test X$idxthreadsEnabled = Xyes ; then
   AC_DEFINE(IDX_THREADS, 1, [Use multiple threads for indexing])
-  NOTHREADS=""
-else
-  NOTHREADS="#"
 fi
 
 # Enable CamelCase word splitting. This is optional because it causes 
@@ -221,54 +207,27 @@
    "mysql manual" (in phrases only and you could raise the phrase slack to
    get a match).]),
         camelcaseEnabled=$enableval, camelcaseEnabled=no)
-
 if test X$camelcaseEnabled = Xyes ; then
   AC_DEFINE(RCL_SPLIT_CAMELCASE, 1, [Split camelCase words])
 fi
 
-# Disable building the python module. This is built by default, because
-# it's really the easiest way to interface and extend recoll. It forces PIC
-# objects for everything (indexing performance impact: 1%), because it's
-# just not worth building the lib twice
-# You can still have a non-pic recoll with:
-#   configure --disable-python-module; make; make install;make clean
-#   configure; make; cd python/recoll; make install
-#
+# Disable building the python module.
 if test X$sys != XDarwin ; then
-AC_ARG_ENABLE(python-module,
+  AC_ARG_ENABLE(python-module,
     AC_HELP_STRING([--disable-python-module],
-   [Do not build the Python module.]),
+    [Do not build the Python module.]),
         pythonEnabled=$enableval, pythonEnabled=yes)
-if test X$pythonEnabled = Xyes ; then
-  NOPYTHON=""
 else
-  NOPYTHON="#"
-fi
-else
-  NOPYTHON="#"
-fi
-
-# Build PIC objects for the library ?
-AC_ARG_ENABLE(pic,
-    AC_HELP_STRING([--disable-pic],
-   [Do not compile library objects as position independant code. 
-    This is incompatible with the php or python extensions.]),
-        picEnabled=$enableval, picEnabled=forpython)
-case $picEnabled in
-forpython) picEnabled=$pythonEnabled; NOPIC=$NOPYTHON;;
-yes) NOPIC="";;
-*) NOPIC="#";;
-esac
-
-if test X$pythonEnabled = Xyes -a X$picEnabled != Xyes; then
-   AC_MSG_ERROR([Python build needs PIC library])
-fi
-
-if test X$NOPIC != X; then
-    NODYNLIB=#
-fi
+  pythonEnabled=no
+fi
+
+AM_CONDITIONAL(MAKEPYTHON, [test X$pythonEnabled = Xyes])
+
 
 AC_CHECK_FUNCS(mkdtemp)
+AC_CHECK_LIB([pthread], [pthread_create], [], [])
+AC_CHECK_LIB([dl], [dlopen], [], [])
+AC_CHECK_LIB([z], [zlibVersion], [], [])
 
 ##### Look for iconv. This can exist in either libc (ie: Linux, solaris) or
 ##### libiconv. We'd need a --with-libiconv= option
@@ -373,8 +332,6 @@
     esac
 done
 LIBXAPIAN=$tmpxaplib
-# Also recent xapian libs need lz even when they think they don't...
-LIBXAPIAN="$LIBXAPIAN -lz"
 LIBXAPIANDIR=`$XAPIAN_CONFIG --libs | awk '{print $1}'`
 case A"$LIBXAPIANDIR" in
   A-L*) LIBXAPIANDIR=`echo $LIBXAPIANDIR | sed -e 's/-L//'`;;
@@ -387,6 +344,12 @@
 #echo LIBXAPIANDIR: $LIBXAPIANDIR
 #echo LIBXAPIANSTATICEXTRA: $LIBXAPIANSTATICEXTRA
 #echo XAPIANCXXFLAGS: $XAPIANCXXFLAGS
+
+AC_ARG_ENABLE(xadump, 
+    AC_HELP_STRING([--enable-xadump],
+   [Enable building the xadump low level Xapian access program.]),
+        enableQT=$enableval, enableXADUMP="no")
+AM_CONDITIONAL(MAKEXADUMP, [test X$enableXADUMP = Xyes])
 
 #### QT
 # The way qt and its tools (qmake especially) are installed is very
@@ -414,12 +377,10 @@
    [Disable the QT-based graphical user interface.]),
         enableQT=$enableval, enableQT="yes")
 
-if test "$enableQT" != "yes" ; then
-   NOQTMAKE="#"
-   NOCMDLINE=""
-else
-  NOQTMAKE=""
-  NOCMDLINE="#"
+AM_CONDITIONAL(MAKEQT, [test X$enableQT = Xyes])
+AM_CONDITIONAL(MAKECMDLINE, [test X$enableQT = Xno])
+
+if test X$enableQT = Xyes ; then
 
   if test X$QTDIR != X ; then
      PATH=$PATH:$QTDIR/bin
@@ -449,15 +410,13 @@
      QMAKE="${QMAKE} -spec macx-g++"
   fi
   
-  # Discriminate qt3/4. Qt3 qmake prints its version on stderr but we don't
-  # depend on this. We try to detect the qt 4 version string instead.
+  # Check Qt version
   qmakevers="`${QMAKE} --version 2>&1`"
   #echo "qmake version: $qmakevers"
   v4=`expr "$qmakevers" : '.*Qt[ ][ ]*version[ ][ ]*4.*'`
   v5=`expr "$qmakevers" : '.*Qt[ ][ ]*version[ ][ ]*5.*'`
   if test X$v4 = X0 -a X$v5 = X0; then 
      AC_MSG_ERROR([qmake seems to be using Qt version 3 which is not supported any more])
-     QTGUI=qtgui
   else
     if test X$v4 != X0 ; then
        AC_MSG_NOTICE([using qt version 4 user interface])
@@ -473,7 +432,7 @@
   test -f recoll.pro && chmod +w recoll.pro
   cp recoll.pro.in recoll.pro
   #echo QMAKE ${QMAKE}
-  ${QMAKE} recoll.pro
+  ${QMAKE} PREFIX=${prefix} recoll.pro
   if test $? != 0 ; then
      AC_MSG_ERROR([Cannot use qmake to generate a Makefile. Maybe you need to
   check the QTDIR and QMAKESPEC environment variables?])
@@ -486,6 +445,7 @@
   installation. If there is no default mkspecs, you should also set QMAKESPEC])
      fi
   fi
+  rm -f Makefile recoll.pro
   cd ..
 
 
@@ -503,8 +463,6 @@
    QMAKE_DISABLE_WEBKIT=""
   fi
 
-
-
  ##### Using QZeitGeist lib ? Default no for now
   AC_ARG_WITH(qzeitgeist,
     AC_HELP_STRING([--with-qzeitgeist],
@@ -551,19 +509,21 @@
 #echo X_CFLAGS "'$X_CFLAGS'" X_PRE_LIBS "'$X_PRE_LIBS'" X_LIBS \
 #      "'$X_LIBS'" X_LIBX11 "'$X_LIBX11'" X_EXTRA_LIBS "'$X_EXTRA_LIBS'"
 
-
-# We have to expand prefix in here, couldn't find a way to do it inside 
-# the qt gui .pro file or Makefile. This just means that you can't change
-# prefix at build time. It works at install time because we dont' use the
-# qtgui Makefile
+# For communicating the value of RECOLL_DATADIR to non-make-based
+# subpackages like python-recoll, we have to expand prefix in here, because
+# things like "datadir = ${prefix}/share" (which is what we'd get by
+# expanding @datadir@) don't mean a thing in Python... I guess we could
+# have a piece of shell-script text to be substituted into and executed by
+# setup.py for getting the value of pkgdatadir, but really...
 m_prefix=$prefix
 test "X$m_prefix" = "XNONE" && m_prefix=/usr/local
 m_datadir=${m_prefix}/share
-QTRECOLL_DATADIR=${m_datadir}/recoll
-
-RCLVERSION=`cat VERSION`
+RECOLL_DATADIR=${m_datadir}/recoll
+
+RCLVERSION=$PACKAGE_VERSION
 RCLLIBVERSION=$RCLVERSION
 
+AC_SUBST(RECOLL_DATADIR)
 AC_SUBST(X_CFLAGS)
 AC_SUBST(X_PRE_LIBS)
 AC_SUBST(X_LIBS)
@@ -577,20 +537,12 @@
 AC_SUBST(LIBFAM)
 AC_SUBST(QMAKE)
 AC_SUBST(QTGUI)
-AC_SUBST(QTRECOLL_DATADIR)
 AC_SUBST(XAPIANCXXFLAGS)
-AC_SUBST(HAVE_MKDTEMP)
-AC_SUBST(NOQTMAKE)
-AC_SUBST(NOCMDLINE)
 AC_SUBST(QMAKE_ENABLE_WEBKIT)
 AC_SUBST(QMAKE_DISABLE_WEBKIT)
 AC_SUBST(QMAKE_ENABLE_ZEITGEIST)
 AC_SUBST(QMAKE_DISABLE_ZEITGEIST)
 AC_SUBST(LIBQZEITGEIST)
-AC_SUBST(NOPIC)
-AC_SUBST(NOTHREADS)
-AC_SUBST(NOPYTHON)
-AC_SUBST(NODYNLIB)
 AC_SUBST(RCLVERSION)
 AC_SUBST(RCLLIBVERSION)
 
@@ -598,23 +550,7 @@
 # changing it unless necessary
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES(common/rclversion.h)
-AC_CONFIG_FILES(lib/mkMake)
-AC_CONFIG_FILES(mk/localdefs.new:mk/localdefs.in)
 AC_CONFIG_FILES(python/recoll/setup.py)
-AC_CONFIG_FILES(recollinstall)
 AC_CONFIG_FILES(sampleconf/recoll.conf)
 
-for d in bincimapmime index lib query
-do 
-    rm -f $d/alldeps.stamp
-    cp -f /dev/null $d/alldeps
-done
-
 AC_OUTPUT
-
-if cmp -s mk/localdefs mk/localdefs.new ; then
-  rm -f mk/localdefs.new
-else
-  mv -f mk/localdefs.new mk/localdefs
-fi
-