Index: Makefile.am
===================================================================
--- Makefile.am	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -36,6 +36,6 @@
 debug=yes
 check:
-	$(MAKE) -C tests all-tests install=no debug=${debug}
+	$(MAKE) -C tests all-tests installed=no debug=${debug}
 
 installcheck:
-	$(MAKE) -C tests all-tests install=yes debug=${debug}
+	$(MAKE) -C tests all-tests installed=yes debug=${debug}
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -900,8 +900,8 @@
 	@cd $(dir $@) && $(abs_top_srcdir)/libcfa/configure $(config_data)
 check:
-	$(MAKE) -C tests all-tests install=no debug=${debug}
+	$(MAKE) -C tests all-tests installed=no debug=${debug}
 
 installcheck:
-	$(MAKE) -C tests all-tests install=yes debug=${debug}
+	$(MAKE) -C tests all-tests installed=yes debug=${debug}
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
Index: automake/cfa.m4
===================================================================
--- automake/cfa.m4	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ automake/cfa.m4	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -26,5 +26,9 @@
 
 	if test "$libdir" = '${exec_prefix}/lib'; then
-		cfa_libdir="${cfa_prefix}/lib/${cfa_name}/${ARCHITECTURE}${CONFIGURATION}"
+		if test "${ARCHITECTURE}" != ""; then
+			cfa_libdir="${cfa_prefix}/lib/${cfa_name}/${ARCHITECTURE}-${CONFIGURATION}/"
+		else
+			cfa_libdir="${cfa_prefix}/lib/${cfa_name}/"
+		fi
 	else
 		cfa_libdir="${libdir}/${ARCHITECTURE}${CONFIGURATION}"
Index: configure
===================================================================
--- configure	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ configure	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -3266,5 +3266,9 @@
 
 	if test "$libdir" = '${exec_prefix}/lib'; then
-		cfa_libdir="${cfa_prefix}/lib/${cfa_name}/${ARCHITECTURE}${CONFIGURATION}"
+		if test "${ARCHITECTURE}" != ""; then
+			cfa_libdir="${cfa_prefix}/lib/${cfa_name}/${ARCHITECTURE}-${CONFIGURATION}/"
+		else
+			cfa_libdir="${cfa_prefix}/lib/${cfa_name}/"
+		fi
 	else
 		cfa_libdir="${libdir}/${ARCHITECTURE}${CONFIGURATION}"
@@ -3450,14 +3454,14 @@
 
 	lib_arch=${cannon_arch_name}
-	lib_dir="libcfa-${lib_arch}-${lib_config}"
+	lib_dir="libcfa/${lib_arch}-${lib_config}"
 
 	LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}"
 	LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile"
 
-	mkdir -p libcfa-${lib_arch}-${lib_config}
-	echo -n "${LIBCFA_GENERAL_ARGS} " > libcfa-${lib_arch}-${lib_config}/config.data
-	echo -n "${LIBCFA_PATHS} " >> libcfa-${lib_arch}-${lib_config}/config.data
-	echo -n "ARCHITECTURE=${lib_arch} " >> libcfa-${lib_arch}-${lib_config}/config.data
-	echo -n "CONFIGURATION=${lib_config}" >> libcfa-${lib_arch}-${lib_config}/config.data
+	mkdir -p ${lib_dir}
+	echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data
+	echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data
+	echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data
+	echo -n "CONFIGURATION=${lib_config}" >> ${lib_dir}/config.data
 done
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ configure.ac	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -145,14 +145,14 @@
 	M4CFA_CANNON_CPU([${arch_name}])
 	lib_arch=${cannon_arch_name}
-	lib_dir="libcfa-${lib_arch}-${lib_config}"
+	lib_dir="libcfa/${lib_arch}-${lib_config}"
 
 	LIBCFA_TARGET_DIRS="${LIBCFA_TARGET_DIRS} ${lib_dir}"
 	LIBCFA_TARGET_MAKEFILES="${LIBCFA_TARGET_MAKEFILES} ${lib_dir}/Makefile"
 
-	mkdir -p libcfa-${lib_arch}-${lib_config}
-	echo -n "${LIBCFA_GENERAL_ARGS} " > libcfa-${lib_arch}-${lib_config}/config.data
-	echo -n "${LIBCFA_PATHS} " >> libcfa-${lib_arch}-${lib_config}/config.data
-	echo -n "ARCHITECTURE=${lib_arch} " >> libcfa-${lib_arch}-${lib_config}/config.data
-	echo -n "CONFIGURATION=${lib_config}" >> libcfa-${lib_arch}-${lib_config}/config.data
+	mkdir -p ${lib_dir}
+	echo -n "${LIBCFA_GENERAL_ARGS} " > ${lib_dir}/config.data
+	echo -n "${LIBCFA_PATHS} " >> ${lib_dir}/config.data
+	echo -n "ARCHITECTURE=${lib_arch} " >> ${lib_dir}/config.data
+	echo -n "CONFIGURATION=${lib_config}" >> ${lib_dir}/config.data
 done
 
Index: driver/cfa.cc
===================================================================
--- driver/cfa.cc	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ driver/cfa.cc	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -86,6 +86,7 @@
 	string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
 
-	string installincdir( CFA_INCDIR );					// fixed location of include files
-	string installlibdir( CFA_LIBDIR );					// fixed location of cc1 and cfa-cpp commands
+	string installincdir( CFA_INCDIR );                         // fixed location of include files
+	string installlibdir( CFA_LIBDIR );                         // fixed location of cc1 and cfa-cpp commands when installed
+	string srcdriverdir ( TOP_BUILDDIR "driver");                // fixed location of cc1 and cfa-cpp commands when in tree
 
 	string heading;										// banner printed at start of cfa compilation
@@ -171,5 +172,4 @@
 				noincstd_flag = true;					// strip the no-include-stdhdr flag
 			} else if ( arg == "-in-tree" ) {
-				noincstd_flag = true;
 				intree = true;
 			} else if ( arg == "-compiler" ) {
@@ -338,37 +338,54 @@
 
 	// add the CFA include-library paths, which allow direct access to header files without directory qualification
-	args[nargs] = "-I" CFA_INCDIR;
-	nargs += 1;
-	if ( ! noincstd_flag ) {							// do not use during build
-		args[nargs] = "-I" CFA_INCDIR "/stdhdr";
-		nargs += 1;
-	} // if
-	args[nargs] = "-I" CFA_INCDIR "/concurrency";
-	nargs += 1;
-	args[nargs] = "-I" CFA_INCDIR "/containers";
-	nargs += 1;
-
-	string libdir;
 	if( !intree ) {
-		const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
-		const char * config = debug ? "debug": "nodebug";
-		libdir = string(CFA_LIBDIR) + arch + config;
-		if( !dirExists(libdir) ) {
-			cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
-			libdir = string(CFA_LIBDIR) + arch + "nolib";
-		}
-
-		if( !dirExists(libdir) ) {
-			cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
-			cerr << "Was looking for " << libdir << endl;
-			exit( EXIT_FAILURE );
-		}
-
-		args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir) ).c_str();
+		args[nargs] = "-I" CFA_INCDIR;
+		nargs += 1;
+		if ( ! noincstd_flag ) {							// do not use during build
+			args[nargs] = "-I" CFA_INCDIR "/stdhdr";
+			nargs += 1;
+		} // if
+		args[nargs] = "-I" CFA_INCDIR "/concurrency";
+		nargs += 1;
+		args[nargs] = "-I" CFA_INCDIR "/containers";
 		nargs += 1;
 	} else {
+		args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
+		nargs += 1;
+		if ( ! noincstd_flag ) {							// do not use during build
+			args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
+			nargs += 1;
+		} // if
+		args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/concurrency";
+		nargs += 1;
+		args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/containers";
+		nargs += 1;
+	}
+
+	string libbase;
+	if( !intree ) {
+		libbase = CFA_LIBDIR;
+	} else {
+		libbase = TOP_BUILDDIR "libcfa/";
 		args[nargs] = "-D__CFA_FLAG__=-t";
 		nargs += 1;
 	}
+
+	const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
+	const char * config = debug ? "debug": "nodebug";
+	string libdir = libbase + arch + "-" + config;
+	if( !dirExists(libdir) ) {
+		cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
+		cerr << "Was looking for " << libdir << endl;
+		libdir = libbase + arch + "-" + "nolib";
+	}
+
+	if( !dirExists(libdir) ) {
+		cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
+		cerr << "Was looking for " << libdir << endl;
+		exit( EXIT_FAILURE );
+	}
+
+	args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
+	nargs += 1;
 
 	if ( link ) {
@@ -387,8 +404,6 @@
 
 		// include the cfa library in case it's needed
-		if( !intree ) {
-			args[nargs] = ( *new string( string("-L" ) + libdir) ).c_str();
-			nargs += 1;
-		}
+		args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src" : "")) ).c_str();
+		nargs += 1;
 		args[nargs] = "-lcfa";
 		nargs += 1;
@@ -445,5 +460,5 @@
 
 	if ( Bprefix.length() == 0 ) {
-		Bprefix = installlibdir;
+		Bprefix = !intree ? installlibdir : srcdriverdir;
 		args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
 		nargs += 1;
Index: libcfa/configure
===================================================================
--- libcfa/configure	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ libcfa/configure	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -2584,5 +2584,9 @@
 
 	if test "$libdir" = '${exec_prefix}/lib'; then
-		cfa_libdir="${cfa_prefix}/lib/${cfa_name}/${ARCHITECTURE}${CONFIGURATION}"
+		if test "${ARCHITECTURE}" != ""; then
+			cfa_libdir="${cfa_prefix}/lib/${cfa_name}/${ARCHITECTURE}-${CONFIGURATION}/"
+		else
+			cfa_libdir="${cfa_prefix}/lib/${cfa_name}/"
+		fi
 	else
 		cfa_libdir="${libdir}/${ARCHITECTURE}${CONFIGURATION}"
Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ libcfa/src/Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -28,5 +28,5 @@
 # use -no-include-stdhdr to prevent rebuild cycles
 # The built sources must not depend on the installed headers
-AM_CFAFLAGS = -quiet -in-tree -B@DRIVER_DIR@ -XCFA --prelude-dir=$(top_builddir)/prelude -imacros prelude.c -I$(srcdir)/stdhdr
+AM_CFAFLAGS = -quiet -in-tree -imacros prelude.c -I$(srcdir)/stdhdr
 AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@
 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ libcfa/src/Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -339,5 +339,5 @@
 # use -no-include-stdhdr to prevent rebuild cycles
 # The built sources must not depend on the installed headers
-AM_CFAFLAGS = -quiet -in-tree -B@DRIVER_DIR@ -XCFA --prelude-dir=$(top_builddir)/prelude -imacros prelude.c -I$(srcdir)/stdhdr
+AM_CFAFLAGS = -quiet -in-tree -imacros prelude.c -I$(srcdir)/stdhdr
 AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@
 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ tests/Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -31,8 +31,7 @@
 	-Wno-unused-function \
 	-quiet @CFA_FLAGS@ \
-	-DIN_DIR="${srcdir}/.in/" \
-	@BUILD_IN_TREE_FLAGS@
+	-DIN_DIR="${srcdir}/.in/"
 
-AM_CFLAGS += ${DEBUG_FLAGS}
+AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS}
 
 CC = @CFACC@
@@ -48,8 +47,8 @@
 #----------------------------------------------------------------------------------------------------------------
 all-local :
-	@+${TEST_PY} --debug=${debug} ${concurrent} ${quick_test}
+	@+${TEST_PY} --debug=${debug}  --install=${installed} ${concurrent} ${quick_test}
 
 all-tests :
-	@+${TEST_PY} --all --debug=${debug} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
+	@+${TEST_PY} --all --debug=${debug}  --install=${installed} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
 
 clean-local :
@@ -66,5 +65,5 @@
 
 concurrency :
-	@+${TEST_PY} --debug=${debug} -Iconcurrent
+	@+${TEST_PY} --debug=${debug}  --install=${installed} -Iconcurrent
 
 #----------------------------------------------------------------------------------------------------------------
Index: tests/Makefile.in
===================================================================
--- tests/Makefile.in	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ tests/Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -303,6 +303,6 @@
 # applies to both programs
 AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \
-	-quiet @CFA_FLAGS@ -DIN_DIR="${srcdir}/.in/" \
-	@BUILD_IN_TREE_FLAGS@ ${DEBUG_FLAGS}
+	-quiet @CFA_FLAGS@ -DIN_DIR="${srcdir}/.in/" ${DEBUG_FLAGS} \
+	${INSTALL_FLAGS}
 fstream_test_SOURCES = fstream_test.c
 avl_test_SOURCES = avltree/avl_test.c avltree/avl0.c avltree/avl1.c avltree/avl2.c avltree/avl3.c avltree/avl4.c avltree/avl-private.c
@@ -613,8 +613,8 @@
 #----------------------------------------------------------------------------------------------------------------
 all-local :
-	@+${TEST_PY} --debug=${debug} ${concurrent} ${quick_test}
+	@+${TEST_PY} --debug=${debug}  --install=${installed} ${concurrent} ${quick_test}
 
 all-tests :
-	@+${TEST_PY} --all --debug=${debug} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
+	@+${TEST_PY} --all --debug=${debug}  --install=${installed} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
 
 clean-local :
@@ -631,5 +631,5 @@
 
 concurrency :
-	@+${TEST_PY} --debug=${debug} -Iconcurrent
+	@+${TEST_PY} --debug=${debug}  --install=${installed} -Iconcurrent
 
 #----------------------------------------------------------------------------------------------------------------
Index: tests/pybin/settings.py
===================================================================
--- tests/pybin/settings.py	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ tests/pybin/settings.py	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -67,4 +67,9 @@
 		self.flags  = """DEBUG_FLAGS="%s" """ % ("-debug" if value else "-nodebug")
 
+class Install:
+	def __init__(self, value):
+		self.string = "installed" if value else "in-tree"
+		self.flags  = """INSTALL_FLAGS="%s" """ % ("" if value else "-in-tree")
+
 def init( options ):
 	global arch
@@ -73,5 +78,5 @@
 	global make
 	global debug
-	global debugFlag
+	global install
 
 	dry_run    = options.dry_run
@@ -79,4 +84,5 @@
 	make       = 'make'
 	debug	     = Debug(options.debug)
+	install    = Install(options.install)
 	arch       = Architecture(options.arch)
 
Index: tests/pybin/tools.py
===================================================================
--- tests/pybin/tools.py	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ tests/pybin/tools.py	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -102,4 +102,5 @@
 		test_param,
 		settings.debug.flags,
+		settings.install.flags,
 		flags,
 		target,
Index: tests/test.py
===================================================================
--- tests/test.py	(revision 524ed86476e43c6c764a1b5335fc8d4fd281dacd)
+++ tests/test.py	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
@@ -86,4 +86,5 @@
 	parser = argparse.ArgumentParser(description='Script which runs cforall tests')
 	parser.add_argument('--debug', help='Run all tests in debug or release', type=yes_no, default='yes')
+	parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=yes_no, default='no')
 	parser.add_argument('--arch', help='Test for specific architecture', type=str, default='')
 	parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
