Index: configure.ac
===================================================================
--- configure.ac	(revision c129d211546e1a55db91dc032790767374adf257)
+++ configure.ac	(revision de061d9d851257a04e924d4472df4523d33bb08b)
@@ -1,164 +1,192 @@
+
 #                                               -*- Autoconf -*-
 # Process this file with autoconf to produce a configure script.
 
-AC_PREREQ(2.59)
-AC_INIT(MoleCuilder, 1.5.4, [foo@molecuilder.de], [molecuilder], [http://www.molecuilder.de/])
+AC_PREREQ([2.60])
+AC_INIT([VMG], [0.1], [tremolo-devel@ins.uni-bonn.de])
+
+AC_MSG_NOTICE([****************************************************************])
+AC_MSG_NOTICE([*      Configuring solver VMG                                  *])
+AC_MSG_NOTICE([****************************************************************])
+
+AC_CONFIG_SRCDIR([src/mg.cpp])
 AC_CONFIG_AUX_DIR([build-aux])
-AC_CONFIG_SRCDIR([src/builder.cpp])
-AC_CONFIG_HEADER([config.h libmolecuilder_config.h])
 AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_SUBDIRS([ThirdParty/LinearAlgebra])
-AC_CONFIG_SUBDIRS([ThirdParty/mpqc_open])
-
-# parallel-tests: use parallel test druver
-# color-tests: us coloring to indicate success/failure when available
-# tar-pax: use newer tar implementation with longer filename (>99 chars)
-AM_INIT_AUTOMAKE([dist-bzip2 1.5 parallel-tests color-tests tar-pax subdir-objects])
+AC_CONFIG_HEADERS([libvmg_config.h])
+AM_INIT_AUTOMAKE([1.7 dist-bzip2 1.5 parallel-tests color-tests tar-pax subdir-objects])
+
+# We use mostly C++, but may need Fortran compiler infos for Lapack.
+AC_LANG([C++])
+
+# Release version switch
+AC_MSG_CHECKING(whether to enable debug version)
+AC_ARG_ENABLE([debug], 
+	AS_HELP_STRING([--enable-debug], [Compile with debug settings]),
+	enable_debug=$enableval,
+	enable_debug="no")
+AC_MSG_RESULT($enable_debug)
+AS_IF([test "$enable_debug" = "no"], [
+	    AC_DEFINE([RELEASE], [1], [Release])
+	    AC_DEFINE([NDEBUG], [1], [Skip asserts])
+])
+
+# One-sided communications
+AC_MSG_CHECKING(whether to enable one-sided MPI2 communications)
+AC_ARG_ENABLE([one_sided], 
+	AS_HELP_STRING([--enable-one-sided], [Enable use of one-sided communications as according to MPI2 standard]),
+	enable_one_sided=$enableval,
+        enable_one_sided="no")
+AC_MSG_RESULT($enable_one_sided)
+AS_IF([test "$enable_one_sided" = "yes"], [
+	    AC_DEFINE([VMG_ONE_SIDED], [1], [Enable use of one-sided MPI2 communications])
+])
+
+# Interpolating B-Spline degree
+AC_ARG_VAR(BSPLINE_DEG, [Degree of interpolating B-Splines. Must be in [3-6].])
+if test -z "$BSPLINE_DEG"
+then
+	BSPLINE_DEG=3
+fi
+AC_MSG_CHECKING(interpolation b-spline degree)
+AC_DEFINE_UNQUOTED([BSPLINE_DEGREE], ${BSPLINE_DEG}, [Interpolating B-Spline degree])
+AC_MSG_RESULT(${BSPLINE_DEG})
+
+# Debugging switches
+AC_MSG_CHECKING(whether to enable debugging)
+AC_ARG_ENABLE([debug], 
+	AS_HELP_STRING([--enable-debug], [Enable debugging]),
+	enable_debug=$enableval,
+	enable_debug="no")
+AS_IF([test "x$enable_fcs_debug" != "x"],[enable_debug="yes"])
+AC_MSG_RESULT($enable_debug)
+AS_IF([test "$enable_debug" = "yes"], [
+	    CXXFLAGS=${CXXFLAGS-"-g -O0 -Wall"}
+	    AC_DEFINE([DEBUG], [1], [Debugging])
+])
+
+AC_MSG_CHECKING(whether to enable debug checking of matrices)
+AC_ARG_ENABLE([debug-check-matrices], 
+	AS_HELP_STRING([--enable-debug-check-matrices], [Enable matrix validity checks]),
+	enable_debug_check_matrices=$enableval,
+	enable_debug_check_matrices="no")
+AC_MSG_RESULT($enable_debug_check_matrices)
+AS_IF([test "$enable_debug_check_matrices" = "yes"], [
+	    AC_DEFINE([DEBUG_MATRIX_CHECKS], [1], [Matrix validity checks])
+])
+
+AC_MSG_CHECKING(whether to enable MPE profiling)
+AC_ARG_ENABLE([mpe], 
+	AS_HELP_STRING([--enable-mpe], [Enable MPE parallel profiling]),
+	enable_mpe=$enableval,
+	enable_mpe="no")
+AC_MSG_RESULT($enable_mpe)
+
+AC_MSG_CHECKING(whether to enable MPI_Barrier debugging)
+AC_ARG_ENABLE([debug-barrier], 
+	AS_HELP_STRING([--enable-debug-barrier], [Enable MPI_Barrier debugging]),
+	enable_debug_barrier=$enableval,
+	enable_debug_barrier="no")
+AC_MSG_RESULT($enable_debug_barrier)
+AS_IF([test "$enable_debug_barrier" = "yes"], [
+	    AC_DEFINE([DEBUG_BARRIER], [1], [MPI_Barrier debugging])
+])
+
+# Several output switches
+AC_MSG_CHECKING(whether to enable info output)
+AC_ARG_ENABLE([output-info], 
+	AS_HELP_STRING([--enable-output-info], [Enable info output]),
+	enable_output_info=$enableval,
+	enable_output_info="no")
+AS_IF([test "x$enable_fcs_info" != "x"],[enable_output_info="yes"])
+AC_MSG_RESULT($enable_output_info)
+AS_IF([test "$enable_output_info" = "yes"], [
+	    AC_DEFINE([OUTPUT_INFO], [1], [Output level info])
+])
+
+AC_MSG_CHECKING(whether to enable debug output)
+AC_ARG_ENABLE([output-debug], 
+	AS_HELP_STRING([--enable-output-debug], [Enable debug output]),
+	enable_output_debug=$enableval,
+	enable_output_debug="no")
+AS_IF([test "x$enable_fcs_debug" != "x"],[enable_output_debug="yes"])
+AC_MSG_RESULT($enable_output_debug)
+AS_IF([test "$enable_output_debug" = "yes"], [
+	    AC_DEFINE([OUTPUT_DEBUG], [1], [Output level debug])
+])
+
+AC_MSG_CHECKING(whether to enable timing output)
+AC_ARG_ENABLE([output-timing], 
+	AS_HELP_STRING([--enable-output-timing], [Enable timing output]),
+	enable_output_timing=$enableval,
+	enable_output_timing="no")
+AS_IF([test "x$enable_fcs_timing" != "x"],[enable_output_timing="yes"])
+AC_MSG_RESULT($enable_output_timing)
+AS_IF([test "$enable_output_timing" = "yes"], [
+	    AC_DEFINE([OUTPUT_TIMING], [1], [Output level timing])
+])
+
 
 # Checks for programs.
-AC_PROG_CXX
-AC_PROG_INSTALL
-
-# check for cppunit (taken from svn.apache.org/../xmlbeanscxx)
-AM_PATH_CPPUNIT(1.9.6)
-AM_CONDITIONAL(CONDCPPUNIT, test "$CPPUNIT_LIBS")
-
-dnl Check if we have enable python
-# python module
-AC_MSG_CHECKING(whether to enable python module)
-AC_ARG_ENABLE(
-	[python],
-	AS_HELP_STRING([--enable-python],[turn on python module [default=yes]]),
-	enable_python=$enableval,
-	enable_python="yes")
-AC_MSG_RESULT($enable_python)
-AS_IF([test x"$enable_python" != x"no"],[
-  # Python (for boost::python)
-  AM_PATH_PYTHON([2.2])
-  AX_PYTHON
-  AC_DEFINE(HAVE_PYTHON,1, ["Build python module and scripts."])
-])
-AM_CONDITIONAL([CONDPYTHON], [test x"$enable_python" != x"no"])
-AC_SUBST(HAVE_PYTHON)
-
-dnl Check whether no extra thread for ActionQueue shall be used
-AC_MSG_CHECKING(whether to enable ActionQueue's run thread)
-AC_ARG_ENABLE(
-	[action_thread],
-	AS_HELP_STRING([--enable-action-thread],[turn on extra run thread for ActionQueue [default=yes]]),
-	enable_action_thread=$enableval,
-	enable_action_thread="no"
-)
-AC_MSG_RESULT($enable_action_thread)
-AS_IF([test x"$enable_action_thread" != x"no"],[
-  AC_DEFINE(HAVE_ACTION_THREAD,1, ["Have extra run thread for ActionQueue."])
-])
-AM_CONDITIONAL([CONDACTIONTHREAD], [test x"$enable_action_thread" != x"no"])
-AC_SUBST(HAVE_ACTION_THREAD)
-
-dnl Check if we have enable qtgui
-# Qt programs
-AC_MSG_CHECKING(whether to enable Qt-based GUI)
-AC_ARG_ENABLE(
-	[qtgui], 
-	AS_HELP_STRING([--enable-qtgui],[turn on Qt GUI compilation [default=yes]]),
-	enable_qtgui=$enableval,
-	enable_qtgui="yes")
-AC_MSG_RESULT($enable_qtgui)
-AS_IF([test x"$enable_qtgui" != x"no"],[
-	AC_ARG_WITH(
-		[Qt-bin],
-		[AS_HELP_STRING([--with-Qt-bin], [give path to Qt binaries])],
-		[have_qtgui_path=$withval],
-		have_qtgui_path="")
-	AS_IF([test x"$have_qtgui_path" != x""],[
-		AC_PATH_PROGS([QT_MOC],
-			[moc-qt4 moc], 
-			[AC_MSG_ERROR(["Qts moc not found, please use --with-Qt-bin."])],
-			[$have_qtgui_path]
-		)
-		AC_PATH_PROGS([QT_RCC],
-			[rcc-qt4 rcc], 
-			[AC_MSG_ERROR(["Qts rcc not found, please use --with-Qt-bin."])],
-			[$have_qtgui_path]
-		)
-		AC_PATH_PROGS([QT_UIC], 
-			[uic-qt4 uic], 
-			[AC_MSG_ERROR(["Qts uic not found, please use --with-Qt-bin."])],
-			[$have_qtgui_path]
-		)
-	],[
-		AC_PATH_PROGS([QT_MOC],
-			[moc-qt4 moc], 
-			[AC_MSG_ERROR(["Qts moc not found, please use --with-Qt-bin."])]
-		)
-		AC_PATH_PROGS([QT_RCC],
-			[rcc-qt4 rcc], 
-			[AC_MSG_ERROR(["Qts rcc not found, please use --with-Qt-bin."])]
-		)
-		AC_PATH_PROGS([QT_UIC], 
-			[uic-qt4 uic], 
-			[AC_MSG_ERROR(["Qts uic not found, please use --with-Qt-bin."])]
-		)
-	])
-	PKG_CHECK_MODULES([QT], [QtCore QtGui Qt3D], [
-	])
-	AC_SUBST([QT_CFLAGS])
-	AC_SUBST([QT_LIBS])
-	AC_DEFINE(HAVE_QTGUI,1, ["Build Qt-based GUI"])
-])
-AM_CONDITIONAL([CONDQTGUI], [test x"$enable_qtgui" != x"no"])
-AC_SUBST(HAVE_QTGUI)
-
-dnl Check whether qtgui captures log or not
-AC_MSG_CHECKING(whether to capture stdout in qtgui)
-AC_ARG_ENABLE(
-	[qtgui_capture_log],
-	AS_HELP_STRING([--enable-qtgui-capture-log],[turn on capturing of log inside qtgui [default=yes]]),
-	enable_qtgui_capture_log=$enableval,
-	enable_qtgui_capture_log="yes"
-)
-AC_MSG_RESULT($enable_qtgui_capture_log)
-AS_IF([test x"$enable_qtgui_capture_log" != x"no"],[
-  AC_DEFINE(QT_CAPTURES_LOG,1, ["Have QtGui capture the stdout."])
-])
-AC_SUBST(QT_CAPTURES_LOG)
-
-
-# check additionally for QWT to enable plotting of potentials
-AC_MSG_CHECKING(whether to enable Qwt-based plotting)
-#enable_qwt=yes
-AC_ARG_ENABLE(
-	[qwt], 
-	AS_HELP_STRING([--enable-qwt],[turn on Qwt compilation [default=yes]]),
-	enable_qwt=$enableval,
-	enable_qwt="yes")
-AC_MSG_RESULT($enable_qwt)
-AS_IF([test x"$enable_qwt" != x"no"],[
-	MOL_AC_HAVE_QWT_IFELSE(
-		[
-			enable_qwt=yes
-			AC_DEFINE(HAVE_QWT,1, ["Build Qwt-based plotting"])
-		],
-		[
-			enable_qwt=no
-			AC_MSG_WARN([Qwt not found, disabling plotting in QtUI.])
-		]
-	)
-])
-AM_CONDITIONAL([CONDQWT], [test x"$enable_qwt" != x"no"])
-AC_SUBST(HAVE_QWT)
-
-# use doxygen
-DX_HTML_FEATURE(ON)
-DX_PS_FEATURE(OFF)
-DX_PDF_FEATURE(OFF)
-DX_INIT_DOXYGEN(MoleCuilder, Doxyfile, ${docdir})
-
-# use docbook
-AX_CHECK_DOCBOOK
+AM_MISSING_PROG([DOXYGEN], [doxygen])
+
+# Get the C MPI compiler, because the following AC_FC_WRAPPERS macro works better if CC is from the same "family" as FC (which is MPI).
+AX_PROG_CC_MPI(,,AC_MSG_FAILURE([The VMG solver requires an MPI C compiler.]))
+
+# Do not even look for a non-MPI C++ compiler if MPICXX is set.
+if test -n "$MPICXX" && test -z "$CXX"; then
+  CXX=$MPICXX
+fi
+ACX_MPI([AC_DEFINE([HAVE_MPI], [1],
+		   [Define if building the MPI parallel version])
+	 CXX=$MPICXX
+	 LIBS="$MPILIBS $LIBS"
+	 AC_DEFINE([MPICH_SKIP_MPICXX], [1], [Skip C++ bindings])
+	 AC_DEFINE([OMPI_SKIP_MPICXX], [1], [Skip C++ bindings])
+	 AC_DEFINE([MPI_NO_CPPBIND], [1], [Skip C++ bindings])
+	 AC_DEFINE([_MPICC_H], [1], [Skip C++ bindings])
+	 AC_DEFINE([MPIBULL_SKIP_MPICXX], [1], [Skip C++ bindings])]
+	 if test "$enable_mpe" = "yes"; then
+	    AC_DEFINE([HAVE_MPE], [1], [Use MPE parallel profiler])
+	 fi,
+	[AC_DEFINE([sequent], [1],
+		   [Define if building the serial version])])
+
+# Get the Fortran MPI compiler, for Lapack.
+AC_LANG_PUSH([Fortran])
+# Do not even look for a non-MPI Fortran compiler if MPIFC is set.
+AX_PROG_FC_MPI(,,AC_MSG_FAILURE([The VMG solver requires an MPI Fortran compiler.]))
+
+# Find out how to call Fortran functions from C.
+AC_FC_WRAPPERS
+AC_LANG_POP([Fortran])
+
+# Check for the restrict keyword.
+AC_C_RESTRICT
+
+AM_OPTIONS_VTK
+AM_PATH_VTK([5.8.0],
+	[AC_DEFINE([HAVE_VTK], [1], [VTK present on system])])
+
+AC_SUBST([VTK_CXXFLAGS])
+AC_SUBST([VTK_LDFLAGS])
+AC_SUBST([VTK_LIBS])
+
+# Boost
+BOOST_REQUIRE([1.34])
+
+# Boost headers with libraries
+BOOST_SYSTEM
+BOOST_FILESYSTEM
+BOOST_TEST
+
+AM_CONDITIONAL([COND_HAVE_BOOST_UNIT_TEST], [test x"$boost_cv_lib_unit_test_framework" = xyes])
+AM_CONDITIONAL([COND_HAVE_BOOST_UNIT_TEST_LIB], [test x"$boost_cv_lib_unit_test_framework" = xyes])
 
 # use libtool
 LT_INIT([static])
+
+# superceded by libtool
+#AC_PROG_RANLIB
+#4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 
 # Define these substitions here to keep all version information in one place.
@@ -166,432 +194,64 @@
 # refer to the libtool manual, section "Updating library version information":
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
-AC_SUBST([MOLECUILDER_SO_VERSION], [17:0:0])
-AC_SUBST([MOLECUILDER_API_VERSION], [1.5.4])
-
-dnl this macro is used to get the arguments supplied
-dnl to the configure script (./configure --enable-debug)
-dnl Check if we have enable debug support.
-AC_MSG_CHECKING(whether to enable debugging)
-have_debug="no"
-AC_ARG_ENABLE(
-	[debug],
-	AS_HELP_STRING([--enable-debug],[turn on debugging [default=no]]),
-	enable_debug=$enableval,
-	enable_debug="no")
-AC_MSG_RESULT($enable_debug)
-AS_IF([test x"$enable_debug" = x"yes"],[
-  AC_DEFINE(MEMDEBUG,1, ["Use memory debugger."])
-  AC_DEFINE(HAVE_DEBUG,1, ["Use debug setting to compile code."])
-  have_debug="yes"
-],[
-	AS_IF([test x"$enable_debug" = x"full"],[
-	  AC_DEFINE(MEMDEBUG,1, ["Use memory debugger."])
-	  AC_DEFINE(LOG_OBSERVER,1, ["Use observer log."])
-	  AC_DEFINE(HAVE_DEBUG,2, ["Use debug setting to compile code."])
-	  dnl AC_DEFINE(QT_DEBUG,, ["Enable Qt debug messages."])
-	  have_debug="full"
-	],[
-	  AC_DEFINE(NDEBUG,1, ["Don't compile in debugging code."])
-	  AC_DEFINE(HAVE_DEBUG,0, ["Use debug setting to compile code."])
-	  AC_DEFINE(QT_NO_DEBUG_OUTPUT,, ["Disable Qt debug messages."])
-	  have_debug="no"
-	])
-])
-AC_SUBST(HAVE_DEBUG)
-
-dnl this macro is used to get the arguments supplied
-dnl to the configure script (./configure --enable-debug)
-dnl Check if we have enable debug support.
-AC_MSG_CHECKING(whether to enable internal caching/lazy evaluation)
-AC_ARG_ENABLE(
-	[cache],
-	AS_HELP_STRING([--enable-cache],[turn on internal lazy evaluation [default=yes]]),
-	enable_cache=$enableval,
-	enable_cache="yes")
-AC_MSG_RESULT($enable_cache)
-AS_IF([test x"$enable_cache" != x"no"],[
-  AC_DEFINE(HAVE_CACHE,1, ["cache variables to speed up the code."])
-],[
-  AC_DEFINE(NO_CACHING,1, ["Don't use caching code."])
-  AC_DEFINE(HAVE_CACHE,0, ["cache variables to speed up the code."])
-])
-AC_SUBST(HAVE_CACHE)
+AC_SUBST([VMG_SO_VERSION], [1:0:0])
+AC_SUBST([VMG_API_VERSION], [1.0.0])
 
 # Checks for libraries.
-AC_CHECK_LIB(m, sqrt, , AC_MSG_ERROR([compatible libc math library not found]))
-
-# Pthreads
-ACX_PTHREAD()
-
-# Boost
-BOOST_REQUIRE([1.40])
-
-# Boost headers only
-BOOST_ANY
-BOOST_ARRAY
-BOOST_BIMAP
-BOOST_BIND
-BOOST_CAST
-BOOST_CONVERSION
-BOOST_EXCEPTION
-BOOST_FOREACH
-BOOST_FUNCTION
-BOOST_FUSION
-BOOST_GRAPH
-BOOST_ITERATOR
-BOOST_MULTIARRAY
-BOOST_MULTIINDEXCONTAINER
-BOOST_MPL
-BOOST_PREPROCESSOR
-BOOST_RANDOM
-BOOST_SMART_PTR
-BOOST_STRING_ALGO
-BOOST_TOKENIZER
-
-# Boost headers with libraries
-BOOST_FILESYSTEM
-BOOST_IOSTREAMS
-BOOST_PROGRAM_OPTIONS
-AS_IF([test x"$enable_python" != x"no"], [BOOST_PYTHON])
-BOOST_SERIALIZATION
-BOOST_THREADS
-
-
-# CodePatterns library (requiring UnobservedIterator)
-compile_codepatterns="no"
-AM_PATH_CODEPATTERNS([1.3.2], $have_debug,,[
-	# compile from ThirdParty
-	AC_CONFIG_SUBDIRS([ThirdParty/CodePatterns])
-	compile_codepatterns="yes"
-	[CodePatterns_LDFLAGS='-L$(top_builddir)/ThirdParty/CodePatterns/src']
-	[CodePatterns_CFLAGS='-I$(top_srcdir)/ThirdParty/CodePatterns/src']
-	AS_IF([test x"$enable_debug" != x"no"], [
-		[CodePatterns_LIBS='-lcodepatterns-debug']
-	],[
-		[CodePatterns_LIBS='-lcodepatterns']
-	])
-	AC_SUBST(CodePatterns_LDFLAGS)
-	AC_SUBST(CodePatterns_CFLAGS)
-	AC_SUBST(CodePatterns_LIBS)
-	#AC_MSG_ERROR([Missing CodePatterns library, please specify PKG_CONFIG_PATH or use --with-codepatterns...])
-])
-AM_CONDITIONAL([COND_COMPILE_CODEPATTERNS], [test x"$compile_codepatterns" = x"yes"])
-
-# JobMarket library (needs boost/archive/iserializer.hpp before MemDebug.hpp)
-AC_MSG_CHECKING(whether to enable jobmarket)
-AC_ARG_ENABLE(
-  [jobmarket],
-  AS_HELP_STRING([--enable-jobmarket],[turn on JobMarket feature [default=yes]]),
-  enable_jobmarket=$enableval,
-  enable_jobmarket="yes")
-AC_MSG_RESULT($enable_jobmarket)
-compile_jobmarket="no"
-AS_IF([test x"$enable_jobmarket" != x"no"],[
-  # the following is only required if we use JobMarket
-  BOOST_ASIO
-  AC_DEFINE(HAVE_JOBMARKET,1, ["use JobMarket to calculate fragment jobs."])
-  # JobMarket library (needs SystemCommandJob with suffix)
-  AM_PATH_JOBMARKET([1.1.6], $have_debug,
-    ,[
-	AC_CONFIG_SUBDIRS([ThirdParty/JobMarket])
-	compile_jobmarket="yes"
-	[JobMarket_CFLAGS='-I$(top_srcdir)/ThirdParty/JobMarket/src']
-	[JobMarket_LDFLAGS='-L$(top_builddir)/ThirdParty/JobMarket/src/JobMarket']
-	[JobMarket_LIBS='-lJobMarket']
-	[JobMarket_Controller_LIBS='-lJobMarketController']
-	[JobMarket_Server_LIBS='-lJobMarketServer']
-	[JobMarket_PoolWorker_LIBS='-lJobMarketPoolWorker']
-	AC_SUBST(JobMarket_CFLAGS)
-	AC_SUBST(JobMarket_LDFLAGS)
-	AC_SUBST(JobMarket_LIBS)
-	AC_SUBST(JobMarket_Controller_LIBS)
-	AC_SUBST(JobMarket_Server_LIBS)
-	AC_SUBST(JobMarket_PoolWorker_LIBS)
-    ])
-]
-AM_CONDITIONAL([COND_COMPILE_JOBMARKET], [test x"$compile_jobmarket" = x"yes"])
-#[
-#  AC_DEFINE(HAVE_JOBMARKET,0, ["use JobMarket to calculate fragment jobs."])
-#]
-)
-AC_SUBST(HAVE_JOBMARKET)
-AM_CONDITIONAL([CONDJOBMARKET], [test x"$enable_jobmarket" = x"yes"])
-
-# VMG library
-AC_MSG_CHECKING(whether to compile in long-range support via VMG)
-AC_ARG_ENABLE(
-  [vmg],
-  [AS_HELP_STRING([--enable-vmg], [turn on long-range potential calculation via VMG [default=no]])],
-  [enable_vmg=$enableval],
-  enable_vmg="no")
-AC_MSG_RESULT($enable_vmg)
-AS_IF([test x"$enable_vmg" != x"no"],[
-  PKG_CHECK_MODULES(VMG, VMG >= 0.1)
-  AC_SUBST(VMG_CFLAGS)
-  AC_SUBST(VMG_LIBS)
-  AC_DEFINE(HAVE_VMG,1, ["use VMG to calculate long-range contributions."])
-
-  # check whether to use mpi
-  AC_ARG_WITH(
-      [vmg-mpi], 
-      [AS_HELP_STRING([--with-vmg-mpi], [whether to use MPI for communication in VMGJobs])],
-      [with_vmg_mpi=yes],
-      [with_vmg_mpi=no])
-  AS_IF(
-    [test "x$with_vmg_mpi" != xno],
-    [
-      AC_LANG_SAVE
-      AC_LANG_CPLUSPLUS
-      LX_FIND_MPI
-      AC_LANG_RESTORE
-      AS_IF([test "x$have_CXX_mpi" = xyes],[
-            AC_DEFINE([MPICH_SKIP_MPICXX], [1], [Skip C++ bindings])
-            AC_DEFINE([OMPI_SKIP_MPICXX], [1], [Skip C++ bindings])
-            AC_DEFINE([MPI_NO_CPPBIND], [1], [Skip C++ bindings])
-            AC_DEFINE([_MPICC_H], [1], [Skip C++ bindings])
-            AC_DEFINE([MPIBULL_SKIP_MPICXX], [1], [Skip C++ bindings])
-	    #ac_configure_args="$ac_configure_args --with-mpi-thread=single --with-default-parallel=mpi --with-include=\"$MPI_CXXFLAGS\" --with-libs=\"$MPI_CXXLDFLAGS\""
-	    ac_configure_args="$ac_configure_args --with-default-parallel=none"
-           ])
-    ],
-    [])
-])
-AM_CONDITIONAL([CONDVMG], [test x"$enable_vmg" = x"yes"])
-AM_CONDITIONAL([CONDVMGMPI], [test x"$have_CXX_mpi" = x"yes"])
-
-
-# Check for Levenberg-Marquardt implementation
-AC_MSG_CHECKING(whether to enable function fitting via levmar)
-AC_ARG_ENABLE(
-  [levmar],
-  AS_HELP_STRING([--enable-levmar],[turn on LevMar feature [default=no]]),
-  enable_levmar=$enableval,
-  enable_levmar="no")
-AC_MSG_RESULT($enable_levmar)
-# don't use AS_IF here as it expands (and tests) AC_F77_FUN even if levmar
-# is disabled.
-compile_levmar="no"
-AS_IF([test x"$enable_levmar" = xyes],[
-	AC_MSG_CHECKING(for levmar presence via given path )
-	AC_ARG_WITH(
-		[levmar],
-		[AS_HELP_STRING([--with-levmar], [give path to LevMar package])],
-		[have_levmar_path=$withval
-		enable_levmar=yes],
-	[
-		enable_levmar=no
-	])
-	AC_MSG_RESULT($enable_levmar)
-	AS_IF([test -n "$have_levmar_path"],[
-		LEVMAR_CPPFLAGS="-I${have_levmar_path}/include"
-		LEVMAR_LDFLAGS="-L${have_levmar_path}/lib"
-		LEVMAR_LIBS="-llevmar"],
-		[PKG_CHECK_MODULES([LEVMAR],[levmar],[enable_levmar=yes],[enable_levmar=no])
-	])
-	],[enable_levmar=no]
-)
-if test x"$enable_levmar" = xyes; then
-	AX_LAPACK([enable_levmar=yes],
-		[enable_levmar=no
-		AC_MSG_WARN(["Missing LAPACK, disabling off levmar"])
-		]
-	)
-else
-			AC_CONFIG_SUBDIRS([ThirdParty/levmar])
-			compile_levmar="yes"
-			enable_levmar="yes"
-			LEVMAR_CPPFLAGS='-I$(top_srcdir)/ThirdParty/levmar/src'
-			LEVMAR_LDFLAGS='-L$(top_builddir)/ThirdParty/levmar/src'
-			LEVMAR_LIBS='-llevmar'
-fi
-AC_MSG_CHECKING(for levmar usability)
-AS_IF([test x"$enable_levmar" = xyes],[
-	AC_SUBST(LEVMAR_CPPFLAGS)
-	AC_SUBST(LEVMAR_LDFLAGS)
-	AC_SUBST(LEVMAR_LIBS)
-        AC_DEFINE(HAVE_LEVMAR,1, ["use levmar for non-linear minimisation/potential fitting."])])
-AC_MSG_RESULT($enable_levmar)
-AM_CONDITIONAL([CONDLEVMAR], [test x"$enable_levmar" = x"yes"])
-AM_CONDITIONAL([COND_COMPILE_LEVMAR], [test x"$compile_levmar" = x"yes"])
+AC_CHECK_LIB([m], [sqrt])
+AX_LAPACK
+AM_CONDITIONAL([HAVE_LAPACK], [test "x$ax_lapack_ok" = xyes])
 
 # Checks for header files.
-AC_HEADER_STDC
-AC_CHECK_HEADERS([sys/time.h])
-AC_HEADER_STDBOOL
-
-AC_FUNC_MALLOC
-AC_FUNC_REALLOC
-AC_CHECK_FUNCS([floor pow sqrt strchr])
-
-# Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_C_INLINE
-AC_C_RESTRICT
-AC_TYPE_SIZE_T
+
+# Checks for types.
+
+# Set up FCS library arguments.
+m4_ifdef([AX_FCS_CONFIG_SOLVER_ARGS],[AX_FCS_CONFIG_SOLVER_ARGS])
+
+# Set up FCS library.
+m4_ifdef([AX_FCS_CONFIG_SOLVER],[AX_FCS_CONFIG_SOLVER])
+
+# Set up FCS types 
+m4_ifdef([AX_FCS_TYPES],
+  [AC_DEFINE([vmg_float], [fcs_float],
+     [Define to the primary interface and computation floating type.])
+   AC_DEFINE([vmg_int], [fcs_int],
+     [Define to the primary integer type for particle indices.])],
+  [AC_DEFINE([vmg_float], [double],
+     [Define to the primary interface and computation floating type.])
+   AC_DEFINE([vmg_int], [int],
+     [Define to the primary integer type for particle indices.])])
+
+# Set up information for FCS package if inside the FCS tree.
+have_fcs="no"
+m4_ifdef([AX_FCS_PACKAGE_RESET],[
+AX_FCS_PACKAGE_RESET
+AX_FCS_PACKAGE_ADD([vmg_LIBS],[-lfcs_vmg])
+AX_FCS_PACKAGE_ADD([vmg_LIBS_A],[src/libfcs_vmg.a])
+AX_FCS_PACKAGE_ADD([vmg_LDADD],[$VTK_LDFLAGS $VTK_LIBS $BOOST_SYSTEM_LDFLAGS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LDFLAGS $BOOST_FILESYSTEM_LIBS $LAPACK_LIBS $BLAS_LIBS])
+AX_FCS_PACKAGE_ADD([CXXLIBS_USE],[yes])
+have_fsc="yes"
+])
+AM_CONDITIONAL(COND_HAVE_FCS, [test x"have_fcs" = xyes])
+
+# Checks for structures.
+
+# Checks for compiler characteristics.
 
 # Checks for library functions.
-# check for GNU Scientific Library
-AC_CHECK_HEADERS([gsl/gsl_blas.h])
-AC_SEARCH_LIBS(dnrm2, gslblas gslcblas goto blas cblas)
-AC_SEARCH_LIBS(cblas_dnrm2, gslblas gslcblas blas cblas)
-AC_SEARCH_LIBS(gsl_blas_dnrm2,, gsl)
-#AC_CHECK_LIB(gsl, gsl_blas_dnrm2, , [AC_MSG_ERROR(["No working BLAS found for GSL, stopping."])])
-AC_CHECK_LIB(gsl, main)
-
-# use CppUnit TestRunner or not
-AC_MSG_CHECKING(whether to enable ECut TestRunnerClient)
-AC_ARG_ENABLE(
-	[ecut],
-	AS_HELP_STRING([--enable-ecut],[Use ECut TestRunnerClient [default=no]]),
-	enable_ecut=$disableval,
-	enable_ecut="no")
-AC_MSG_RESULT($enable_ecut)
-AS_IF([test x"$enable_ecut" = x"yes"],[
-  AC_DEFINE(HAVE_ECUT,1, ["Use ECut TestRunnerClient instead of our own."])
-  AC_SUBST(HAVE_ECUT)
-])
-AM_CONDITIONAL([CONDECUT], [test x"$enable_ecut" = x"yes"])
-
-# with valgrinding testsuite or not
-AC_MSG_CHECKING(whether to enable valgrind memory checking in testsuite)
-AC_ARG_ENABLE(
-	[valgrind],
-	AS_HELP_STRING([--enable-valgrind],[Use Valgrind on the testsuite [default=no]]),
-        enable_valgrind=$enableval,
-	enable_valgrind="no")
-AC_MSG_RESULT($enable_valgrind)
-AS_IF([test x"$enable_valgrind" = x"yes"], [
-  AC_CHECK_HEADER([valgrind/valgrind.h],
-    [
-      # check header
-      AC_DEFINE(HAVE_VALGRIND_TESTSUITE,1, ["Use Valgrind to check the testsuite."])
-      # check path
-      AC_PATH_PROG(VALGRIND, [valgrind], [/bin/false])
-      # set variables 
-      AC_SUBST(HAVE_VALGRIND_TESTSUITE)
-      AC_SUBST(VALGRIND)
-    ],
-    [
-      AC_MSG_ERROR(["Valgrind support requested but headers not available."])
-    ]
-  )
-])
-
-# Check for "extern inline", using a modified version
-# of the test for AC_C_INLINE from acspecific.mt
-AC_CACHE_CHECK([for extern inline], ac_cv_c_extern_inline,
-[ac_cv_c_extern_inline=no
-AC_TRY_COMPILE([extern $ac_cv_c_inline double foo(double x);
-extern $ac_cv_c_inline double foo(double x) { return x+1.0; };
-double foo (double x) { return x + 1.0; };], 
-[  foo(1.0)  ],
-[ac_cv_c_extern_inline="yes"])
-])
-
-if test "$ac_cv_c_inline" != no ; then
-  AC_DEFINE(HAVE_INLINE,1, ["May use inline routines"])
-  AC_SUBST(HAVE_INLINE)
-fi
-
-#AC_MSG_NOTICE(["CFLAGS: $CFLAGS, CXXFLAGS: $CXXFLAGS, LDFLAGS: $LDFLAGS, CC: $CC, CXX:, $CXX, MPICC: $MPICC, MPILIBS: $MPILIBS, LIBS: $LIBS"])
-
-# test suite
-
+
+# Checks for system services
+
+# we save the cache here because the tests below fail more commonly
+
+# package information
 AC_CONFIG_FILES([
-	tests/Makefile])
-
-AC_CONFIG_TESTDIR(tests/Calculations)
-AC_CONFIG_FILES([
-	tests/Calculations/atlocal 
-	tests/Calculations/Makefile])
-AC_CONFIG_FILES([tests/Calculations/molecuilder], [chmod +x tests/Calculations/molecuilder])
-
-AC_CONFIG_TESTDIR(tests/CodeChecks)
-AC_CONFIG_FILES([
-	tests/CodeChecks/atlocal 
-	tests/CodeChecks/Makefile])
-
-AC_CONFIG_TESTDIR(tests/Fragmentations)
-AC_CONFIG_FILES([
-	tests/Fragmentations/atlocal 
-	tests/Fragmentations/Makefile])
-AC_CONFIG_FILES([tests/Fragmentations/molecuilder], [chmod +x tests/Fragmentations/molecuilder])
-
-AC_CONFIG_TESTDIR(tests/GuiChecks)
-AC_CONFIG_FILES([
-	tests/GuiChecks/atlocal 
-	tests/GuiChecks/Makefile])
-AC_CONFIG_FILES([tests/GuiChecks/molecuilder], [chmod +x tests/GuiChecks/molecuilder])
-AC_CONFIG_FILES([tests/GuiChecks/molecuilderguitest], [chmod +x tests/GuiChecks/molecuilderguitest])
-AC_CONFIG_FILES([tests/GuiChecks/adjacencymatcher], [chmod +x tests/GuiChecks/adjacencymatcher])
-AC_CONFIG_FILES([tests/GuiChecks/trianglematcher], [chmod +x tests/GuiChecks/trianglematcher])
-
-AC_CONFIG_TESTDIR(tests/JobMarket)
-AC_CONFIG_FILES([
-  tests/JobMarket/atlocal 
-  tests/JobMarket/Makefile])
-AC_CONFIG_FILES([tests/JobMarket/molecuilder], [chmod +x tests/JobMarket/molecuilder])
-
-AC_CONFIG_TESTDIR(tests/integration)
-AC_CONFIG_FILES([
-  tests/integration/atlocal 
-  tests/integration/Makefile])
-AC_CONFIG_FILES([tests/integration/molecuilder], [chmod +x tests/integration/molecuilder])
-AC_CONFIG_FILES([tests/integration/molecuilder_mpqc], [chmod +x tests/integration/molecuilder_mpqc])
-
-AC_CONFIG_TESTDIR(tests/regression)
-AC_CONFIG_FILES([
-	tests/regression/atlocal 
-	tests/regression/Makefile])
-AC_CONFIG_FILES([tests/regression/molecuilder], [chmod +x tests/regression/molecuilder])
-AC_CONFIG_FILES([tests/regression/adjacencymatcher], [chmod +x tests/regression/adjacencymatcher])
-AC_CONFIG_FILES([tests/regression/trianglematcher], [chmod +x tests/regression/trianglematcher])
-AC_CONFIG_FILES([tests/regression/runpython], [chmod +x tests/regression/runpython])
-
-AC_CONFIG_TESTDIR(tests/Tesselations)
-AC_CONFIG_FILES([
-	tests/Tesselations/atlocal 
-	tests/Tesselations/Makefile])
-AC_CONFIG_FILES([tests/Tesselations/molecuilder], [chmod +x tests/Tesselations/molecuilder])
-AC_CONFIG_FILES([tests/Tesselations/trianglematcher], [chmod +x tests/Tesselations/trianglematcher])
-
-AC_CONFIG_TESTDIR(tests/Examples)
-AC_CONFIG_FILES([
-	tests/Examples/atlocal 
-	tests/Examples/Makefile])
-AC_CONFIG_FILES([tests/Examples/molecuilder], [chmod +x tests/Examples/molecuilder])
-
-AC_CONFIG_FILES([
-	doc/molecuilder.xml])
-AC_CONFIG_FILES([
-	doc/userguide/catalog.xml:doc/userguide/catalog.xml.in])
-AC_CONFIG_FILES([
-	MoleCuilder.pc:MoleCuilder.pc.in])
-AC_CONFIG_FILES([
+	VMG.pc:VMG.pc.in])
+
+AC_CONFIG_FILES([Makefile
+	src/Makefile
 	doc/Makefile
-	doc/userguide/Makefile
-])
-AC_CONFIG_FILES([
-	Makefile 
-	src/Makefile
-	src/Bond/AdjacencyMatcher/Makefile
-	src/Tesselation/TriangleMatcher/Makefile
-	ThirdParty/Makefile
-	data/icons/Makefile
-	utils/Makefile
-])
-AC_CONFIG_FILES([
-	src/unittests/Makefile
-])
-
-# produce python scripts and tests only when python's present
-AC_CONFIG_TESTDIR([tests/Python])
-AC_CONFIG_FILES([tests/Python/atlocal])
-AM_COND_IF([CONDPYTHON],[
-	AC_CONFIG_FILES([utils/Python/boxmaker.py:utils/Python/boxmaker.py.in], [chmod +x utils/Python/boxmaker.py])
-	AC_CONFIG_FILES([utils/Python/python_wrapper:utils/Python/python_wrapper.in], [chmod +x utils/Python/python_wrapper])
-	AC_CONFIG_FILES([tests/Python/run], [chmod +x tests/Python/run])
-])
-AC_CONFIG_FILES([tests/Python/Makefile])
+	test/Makefile])
+AC_CONFIG_FILES([vmg.pc:vmg.pc.in])
 
 AC_OUTPUT
