Index: src/InitTweak/FixGlobalInit.cc
===================================================================
--- src/InitTweak/FixGlobalInit.cc	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/InitTweak/FixGlobalInit.cc	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -74,5 +74,5 @@
   	std::string ret = name.substr( 0, name.find( '.' ) );
   	// replace invalid characters with _
-		static std::string invalid = "/-";
+		static std::string invalid = "/-@";
   	replace_if( ret.begin(), ret.end(), []( char c ) { return invalid.find(c) != std::string::npos; }, '_' );
   	return ret;
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/Makefile.am	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -44,5 +44,5 @@
 driver_cfa_cpp_SOURCES = ${SRC}
 driver_cfa_cpp_LDADD = -ldl			# yywrap
-driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
+driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I${abs_top_srcdir}/src/Parser -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
 driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
 
Index: src/Makefile.in
===================================================================
--- src/Makefile.in	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/Makefile.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -327,5 +327,6 @@
     *) (install-info --version) >/dev/null 2>&1;; \
   esac
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+	$(LISP)config.h.in
 # Read a list of newline-separated strings from the standard input,
 # and print each of them once, without duplicates.  Input order is
@@ -541,5 +542,5 @@
 driver_cfa_cpp_SOURCES = ${SRC}
 driver_cfa_cpp_LDADD = -ldl			# yywrap
-driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
+driver_cfa_cpp_CXXFLAGS = -Wno-deprecated -Wall -Wextra -DDEBUG_ALL -I./Parser -I${abs_top_srcdir}/src/Parser -I${abs_top_srcdir}/src/include -DYY_NO_INPUT -O2 -g -std=c++14
 driver_cfa_cpp_LDFLAGS = -Xlinker -export-dynamic
 all: $(BUILT_SOURCES)
Index: src/config.h.in
===================================================================
--- src/config.h.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
+++ src/config.h.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -0,0 +1,217 @@
+/* src/config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Location of include files. */
+#undef CFA_BACKEND_CC
+
+/* Location of cfa command. */
+#undef CFA_BINDIR
+
+/* compilation flags for cfa libraries and test programs. */
+#undef CFA_FLAGS
+
+/* Location of include files. */
+#undef CFA_INCDIR
+
+/* Location of cc1 and cfa-cpp commands. */
+#undef CFA_LIBDIR
+
+/* Location of cfa install. */
+#undef CFA_PREFIX
+
+/* Major.Minor */
+#undef CFA_VERSION
+
+/* Build version number. */
+#undef CFA_VERSION_BUILD
+
+/* Major.Minor.Patch.Build */
+#undef CFA_VERSION_FULL
+
+/* Major.Minor.Patch */
+#undef CFA_VERSION_LONG
+
+/* Major version number. */
+#undef CFA_VERSION_MAJOR
+
+/* Minor version number. */
+#undef CFA_VERSION_MINOR
+
+/* Patch version number. */
+#undef CFA_VERSION_PATCH
+
+/* Major */
+#undef CFA_VERSION_SHORT
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+#undef CRAY_STACKSEG_END
+
+/* Define to 1 if using `alloca.c'. */
+#undef C_ALLOCA
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+#undef HAVE_ALLOCA
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+#undef HAVE_ALLOCA_H
+
+/* Define to 1 if you have the <fenv.h> header file. */
+#undef HAVE_FENV_H
+
+/* Define to 1 if you have the <float.h> header file. */
+#undef HAVE_FLOAT_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the <malloc.h> header file. */
+#undef HAVE_MALLOC_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `putenv' function. */
+#undef HAVE_PUTENV
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at runtime.
+	STACK_DIRECTION > 0 => grows toward higher addresses
+	STACK_DIRECTION < 0 => grows toward lower addresses
+	STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
+   `char[]'. */
+#undef YYTEXT_POINTER
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+   <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+   #define below would cause a syntax error. */
+#undef _UINT8_T
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to the type of a signed integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int16_t
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef int32_t
+
+/* Define to the type of a signed integer type of width exactly 8 bits if such
+   a type exists and the standard includes do not define it. */
+#undef int8_t
+
+/* Define to the equivalent of the C99 'restrict' keyword, or to
+   nothing if this is not supported.  Do not define if restrict is
+   supported directly.  */
+#undef restrict
+/* Work around a bug in Sun C++: it does not support _Restrict or
+   __restrict__, even though the corresponding Sun C compiler ends up with
+   "#define restrict _Restrict" or "#define restrict __restrict__" in the
+   previous line.  Perhaps some future version of Sun C++ will work with
+   restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
+#if defined __SUNPRO_CC && !defined __RESTRICT
+# define _Restrict
+# define __restrict__
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to the type of an unsigned integer type of width exactly 16 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint16_t
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+   such a type exists and the standard includes do not define it. */
+#undef uint8_t
Index: src/driver/Makefile.am
===================================================================
--- src/driver/Makefile.am	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/driver/Makefile.am	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -28,7 +28,8 @@
 endif
 
+# don't install cfa directly
 noinst_PROGRAMS = cfa
-cfa_SOURCES = cfa.cc
 
+# use
 install-exec-hook:
 	@test -z "$(CFA_BINDIR)" || $(MKDIR_P) "$(CFA_BINDIR)"
@@ -40,4 +41,6 @@
 	cd "$(CFA_BINDIR)" && rm -f $(CFA_NAME)
 
+cfa_SOURCES = cfa.cc
+
 # put into lib for now
 cc1libdir = ${CFA_LIBDIR}
Index: src/driver/Makefile.in
===================================================================
--- src/driver/Makefile.in	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/driver/Makefile.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -626,4 +626,5 @@
 
 
+# use
 install-exec-hook:
 	@test -z "$(CFA_BINDIR)" || $(MKDIR_P) "$(CFA_BINDIR)"
Index: src/libcfa/Makefile.am
===================================================================
--- src/libcfa/Makefile.am	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/libcfa/Makefile.am	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -36,5 +36,5 @@
 	 ${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -D__CFA_DEBUG__ -Wall -O0 -c -o $@ $<
 
-EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
+EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@ $(DEFAULT_INCLUDES)
 
 AM_CCASFLAGS = @CFA_FLAGS@
@@ -43,6 +43,6 @@
 #use -no-include-stdhdr to prevent rebuild cycles
 #The built sources must not depend on the installed headers
-CFLAGS = -quiet -no-include-stdhdr -I${abs_top_srcdir}/src/libcfa/stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS}
-CC = ${abs_top_srcdir}/src/driver/cfa
+CFLAGS = -quiet -no-include-stdhdr -I${abs_top_srcdir}/src/libcfa/stdhdr -XCFA -t -B${abs_top_builddir}/src/driver ${EXTRA_FLAGS}
+CC = ${abs_top_builddir}/src/driver/cfa
 
 headers = fstream iostream iterator limits rational time stdlib common \
@@ -92,5 +92,5 @@
 libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug
 
-stdhdr = ${shell find stdhdr -type f -printf "%p "}
+stdhdr = ${shell find ${srcdir}/stdhdr -type f -printf "%p "}
 
 cfa_includedir = $(CFA_INCDIR)
Index: src/libcfa/Makefile.in
===================================================================
--- src/libcfa/Makefile.in	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/libcfa/Makefile.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -268,7 +268,8 @@
 	containers/result containers/vector concurrency/coroutine \
 	concurrency/thread concurrency/kernel concurrency/monitor \
-	concurrency/mutex ${shell find stdhdr -type f -printf "%p "} \
-	math gmp time_t.h bits/align.h bits/containers.h bits/defs.h \
-	bits/debug.h bits/locks.h concurrency/invoke.h
+	concurrency/mutex ${shell find ${srcdir}/stdhdr -type f \
+	-printf "%p "} math gmp time_t.h bits/align.h \
+	bits/containers.h bits/defs.h bits/debug.h bits/locks.h \
+	concurrency/invoke.h
 HEADERS = $(nobase_cfa_include_HEADERS)
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
@@ -302,5 +303,5 @@
 AWK = @AWK@
 BACKEND_CC = @BACKEND_CC@
-CC = ${abs_top_srcdir}/src/driver/cfa
+CC = ${abs_top_builddir}/src/driver/cfa
 CCAS = @CCAS@
 CCASDEPMODE = @CCASDEPMODE@
@@ -318,5 +319,5 @@
 #use -no-include-stdhdr to prevent rebuild cycles
 #The built sources must not depend on the installed headers
-CFLAGS = -quiet -no-include-stdhdr -I${abs_top_srcdir}/src/libcfa/stdhdr -XCFA -t -B${abs_top_srcdir}/src/driver ${EXTRA_FLAGS}
+CFLAGS = -quiet -no-include-stdhdr -I${abs_top_srcdir}/src/libcfa/stdhdr -XCFA -t -B${abs_top_builddir}/src/driver ${EXTRA_FLAGS}
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
@@ -422,5 +423,5 @@
 ARFLAGS = cr
 lib_LIBRARIES = $(am__append_1) $(am__append_2)
-EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@
+EXTRA_FLAGS = -g -Wall -Wno-unused-function -imacros libcfa-prelude.c @CFA_FLAGS@ $(DEFAULT_INCLUDES)
 AM_CCASFLAGS = @CFA_FLAGS@
 headers = fstream iostream iterator limits rational time stdlib common \
@@ -435,5 +436,5 @@
 libcfa_d_a_SOURCES = ${libsrc}
 libcfa_d_a_CFLAGS = -debug -O0 #No need for __CFA_DEBUG__ since we pass -debug
-stdhdr = ${shell find stdhdr -type f -printf "%p "}
+stdhdr = ${shell find ${srcdir}/stdhdr -type f -printf "%p "}
 cfa_includedir = $(CFA_INCDIR)
 nobase_cfa_include_HEADERS = \
Index: src/prelude/Makefile.am
===================================================================
--- src/prelude/Makefile.am	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/prelude/Makefile.am	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -23,5 +23,5 @@
 noinst_DATA = ../libcfa/libcfa-prelude.c
 
-CC = ${abs_top_srcdir}/src/driver/cfa
+CC = ${abs_top_builddir}/src/driver/cfa
 
 $(DEPDIR) :
@@ -32,13 +32,13 @@
 
 # create extra forward types/declarations to reduce inclusion of library files
-extras.cf : extras.regx extras.c
-	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf
+extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c
+	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf
 
 # create forward declarations for gcc builtins
-gcc-builtins.cf : gcc-builtins.c prototypes.sed
-	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E -P $< | sed -r -f prototypes.sed > $@
+gcc-builtins.cf : gcc-builtins.c ${srcdir}/prototypes.sed
+	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -I${srcdir} -E -P $< | sed -r -f ${srcdir}/prototypes.sed > $@
 
-gcc-builtins.c : builtins.def prototypes.awk sync-builtins.cf
-	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E prototypes.c | awk -f prototypes.awk > $@
+gcc-builtins.c : ${srcdir}/builtins.def ${srcdir}/prototypes.awk ${srcdir}/sync-builtins.cf ${srcdir}/prototypes.c
+	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -I${srcdir} -E ${srcdir}/prototypes.c | awk -f ${srcdir}/prototypes.awk > $@
 
 prelude.cf : prelude-gen.cc
@@ -58,9 +58,9 @@
 include $(DEPDIR)/builtins.Po
 
-../libcfa/libcfa-prelude.c : prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
-	${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -l prelude.cf $@  # use src/cfa-cpp as not in lib until after install
+../libcfa/libcfa-prelude.c : prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_builddir}/src/driver/cfa-cpp
+	${AM_V_GEN}${abs_top_builddir}/src/driver/cfa-cpp -l prelude.cf $@  # use src/cfa-cpp as not in lib until after install
 
-bootloader.c : bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
-	${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -tpm bootloader.cf $@  # use src/cfa-cpp as not in lib until after install
+bootloader.c : ${srcdir}/bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_builddir}/src/driver/cfa-cpp
+	${AM_V_GEN}${abs_top_builddir}/src/driver/cfa-cpp -tpm ${srcdir}/bootloader.cf $@  # use src/cfa-cpp as not in lib until after install
 
 maintainer-clean-local :
Index: src/prelude/Makefile.in
===================================================================
--- src/prelude/Makefile.in	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/prelude/Makefile.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -162,5 +162,5 @@
 AWK = @AWK@
 BACKEND_CC = @BACKEND_CC@
-CC = ${abs_top_srcdir}/src/driver/cfa
+CC = ${abs_top_builddir}/src/driver/cfa
 CCAS = @CCAS@
 CCASDEPMODE = @CCASDEPMODE@
@@ -501,13 +501,13 @@
 
 # create extra forward types/declarations to reduce inclusion of library files
-extras.cf : extras.regx extras.c
-	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f extras.regx > ${srcdir}/extras.cf
+extras.cf : ${srcdir}/extras.regx ${srcdir}/extras.c
+	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E ${srcdir}/extras.c | grep -f ${srcdir}/extras.regx > extras.cf
 
 # create forward declarations for gcc builtins
-gcc-builtins.cf : gcc-builtins.c prototypes.sed
-	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E -P $< | sed -r -f prototypes.sed > $@
-
-gcc-builtins.c : builtins.def prototypes.awk sync-builtins.cf
-	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -E prototypes.c | awk -f prototypes.awk > $@
+gcc-builtins.cf : gcc-builtins.c ${srcdir}/prototypes.sed
+	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -I${srcdir} -E -P $< | sed -r -f ${srcdir}/prototypes.sed > $@
+
+gcc-builtins.c : ${srcdir}/builtins.def ${srcdir}/prototypes.awk ${srcdir}/sync-builtins.cf ${srcdir}/prototypes.c
+	${AM_V_GEN}@BACKEND_CC@ @CFA_FLAGS@ -I${srcdir} -E ${srcdir}/prototypes.c | awk -f ${srcdir}/prototypes.awk > $@
 
 prelude.cf : prelude-gen.cc
@@ -527,9 +527,9 @@
 include $(DEPDIR)/builtins.Po
 
-../libcfa/libcfa-prelude.c : prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
-	${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -l prelude.cf $@  # use src/cfa-cpp as not in lib until after install
-
-bootloader.c : bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_srcdir}/src/driver/cfa-cpp
-	${AM_V_GEN}${abs_top_srcdir}/src/driver/cfa-cpp -tpm bootloader.cf $@  # use src/cfa-cpp as not in lib until after install
+../libcfa/libcfa-prelude.c : prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_builddir}/src/driver/cfa-cpp
+	${AM_V_GEN}${abs_top_builddir}/src/driver/cfa-cpp -l prelude.cf $@  # use src/cfa-cpp as not in lib until after install
+
+bootloader.c : ${srcdir}/bootloader.cf prelude.cf extras.cf gcc-builtins.cf builtins.cf ${abs_top_builddir}/src/driver/cfa-cpp
+	${AM_V_GEN}${abs_top_builddir}/src/driver/cfa-cpp -tpm ${srcdir}/bootloader.cf $@  # use src/cfa-cpp as not in lib until after install
 
 maintainer-clean-local :
Index: src/tests/.in/io.data
===================================================================
--- src/tests/.in/io.data	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
+++ src/tests/.in/io.data	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -0,0 +1,1 @@
+falseA 23 93 1 2 3 4 5 6 7 8 1.1 1.2 1.3 1.1+2.3 1.1-2.3 1.1-2.3 abc xyz
Index: src/tests/Makefile.am
===================================================================
--- src/tests/Makefile.am	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/Makefile.am	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -15,4 +15,5 @@
 ###############################################################################
 
+
 debug=yes
 
@@ -24,4 +25,6 @@
 concurrent='-Econcurrent'
 endif
+
+TEST_PY = python ${srcdir}/test.py
 
 # applies to both programs
@@ -41,5 +44,5 @@
 TEST_FLAGS = $(if $(test), 2> $(test), )
 AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
-CC = @CFA_BINDIR@/@CFA_NAME@
+CC = ${abs_top_builddir}/src/driver/cfa -DIN_DIR="${srcdir}/.in/"
 
 .PHONY : list
@@ -53,8 +56,8 @@
 
 all-local :
-	@+python test.py --debug=${debug} ${concurrent} ${quick_test}
+	@+${TEST_PY} --debug=${debug} ${concurrent} ${quick_test}
 
 all-tests :
-	@+python test.py --all --debug=${debug} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
+	@+${TEST_PY} --all --debug=${debug} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
 
 clean-local :
@@ -62,76 +65,72 @@
 
 list :
-	@+python test.py --list ${concurrent}
+	@+${TEST_PY} --list ${concurrent}
 
 concurrency :
-	@+python test.py --debug=${debug} -Iconcurrent
+	@+${TEST_PY} --debug=${debug} -Iconcurrent
 
-.dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@}				#don't use CFLAGS, this rule is not a real test
-
-
-% : %.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@}
+% : ${srcdir}/%.c @CFA_BINDIR@/@CFA_NAME@
+	$(COMPILE) $(abspath ${<}) -o ${@}
 
 declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 extension : extension.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 functions: functions.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 sched-ext-parse : sched-ext-parse.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -lgmp ${<} -o ${@}
+	$(COMPILE) -lgmp $(abspath ${<}) -o ${@}
 
 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 alloc-ERROR: alloc.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 fallthrough-ERROR: fallthrough.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 nested-types-ERR1: nested-types.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 nested-types-ERR2: nested-types.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR2 ${<} -o ${@}
+	$(COMPILE) -DERR2 $(abspath ${<}) -o ${@}
 
 # Constructor/destructor tests
 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR2 ${<} -o ${@}
+	$(COMPILE) -DERR2 $(abspath ${<}) -o ${@}
 
 raii/memberCtors-ERR1: raii/memberCtors.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 raii/ctor-autogen-ERR1: raii/ctor-autogen.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 # Warnings
 warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only
+	$(COMPILE) $(abspath ${<}) 2> ${@} -fsyntax-only
 
 #builtins
 builtins/sync: builtins/sync.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only
+	$(COMPILE) $(abspath ${<}) 2> ${@} -fsyntax-only
Index: src/tests/Makefile.in
===================================================================
--- src/tests/Makefile.in	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/Makefile.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -103,5 +103,5 @@
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_FILES = config.py
 CONFIG_CLEAN_VPATH_FILES =
 am__dirstamp = $(am__leading_dot)dirstamp
@@ -180,5 +180,6 @@
 ETAGS = etags
 CTAGS = ctags
-am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/automake/depcomp
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.py.in \
+	$(top_srcdir)/automake/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
@@ -191,5 +192,5 @@
 AWK = @AWK@
 BACKEND_CC = @BACKEND_CC@
-CC = @CFA_BINDIR@/@CFA_NAME@
+CC = ${abs_top_builddir}/src/driver/cfa -DIN_DIR="${srcdir}/.in/"
 CCAS = @CCAS@
 CCASDEPMODE = @CCASDEPMODE@
@@ -306,4 +307,5 @@
 @BUILD_CONCURRENCY_FALSE@concurrent = '-Econcurrent'
 @BUILD_CONCURRENCY_TRUE@concurrent = 
+TEST_PY = python ${srcdir}/test.py
 
 # applies to both programs
@@ -350,4 +352,6 @@
 	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
 $(am__aclocal_m4_deps):
+config.py: $(top_builddir)/config.status $(srcdir)/config.py.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 avltree/$(am__dirstamp):
 	@$(MKDIR_P) avltree
@@ -731,8 +735,8 @@
 
 all-local :
-	@+python test.py --debug=${debug} ${concurrent} ${quick_test}
+	@+${TEST_PY} --debug=${debug} ${concurrent} ${quick_test}
 
 all-tests :
-	@+python test.py --all --debug=${debug} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
+	@+${TEST_PY} --all --debug=${debug} ${concurrent}		# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
 
 clean-local :
@@ -740,77 +744,74 @@
 
 list :
-	@+python test.py --list ${concurrent}
+	@+${TEST_PY} --list ${concurrent}
 
 concurrency :
-	@+python test.py --debug=${debug} -Iconcurrent
-
-.dummy : .dummy.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${BUILD_FLAGS} -XCFA -n ${<} -o ${@}				#don't use CFLAGS, this rule is not a real test
-
-% : %.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} ${<} -o ${@}
+	@+${TEST_PY} --debug=${debug} -Iconcurrent
+
+% : ${srcdir}/%.c @CFA_BINDIR@/@CFA_NAME@
+	$(COMPILE) $(abspath ${<}) -o ${@}
 
 declarationSpecifier: declarationSpecifier.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 gccExtensions : gccExtensions.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 extension : extension.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 attributes : attributes.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 functions: functions.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 KRfunctions : KRfunctions.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 sched-ext-parse : sched-ext-parse.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -CFA -XCFA -p ${<} -o ${@}
+	$(COMPILE) -CFA -XCFA -p $(abspath ${<}) -o ${@}
 
 gmp : gmp.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -lgmp ${<} -o ${@}
+	$(COMPILE) -lgmp $(abspath ${<}) -o ${@}
 
 completeTypeError : completeTypeError.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 typedefRedef-ERR1: typedefRedef.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 alloc-ERROR: alloc.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 fallthrough-ERROR: fallthrough.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 nested-types-ERR1: nested-types.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 nested-types-ERR2: nested-types.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR2 ${<} -o ${@}
+	$(COMPILE) -DERR2 $(abspath ${<}) -o ${@}
 
 # Constructor/destructor tests
 raii/dtor-early-exit-ERR1: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 raii/dtor-early-exit-ERR2: raii/dtor-early-exit.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR2 ${<} -o ${@}
+	$(COMPILE) -DERR2 $(abspath ${<}) -o ${@}
 
 raii/memberCtors-ERR1: raii/memberCtors.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 raii/ctor-autogen-ERR1: raii/ctor-autogen.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} -DERR1 ${<} -o ${@}
+	$(COMPILE) -DERR1 $(abspath ${<}) -o ${@}
 
 # Warnings
 warnings/self-assignment: warnings/self-assignment.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only
+	$(COMPILE) $(abspath ${<}) 2> ${@} -fsyntax-only
 
 #builtins
 builtins/sync: builtins/sync.c @CFA_BINDIR@/@CFA_NAME@
-	${CC} ${AM_CFLAGS} ${CFLAGS} ${<} 2> ${@} -fsyntax-only
+	$(COMPILE) $(abspath ${<}) 2> ${@} -fsyntax-only
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
Index: src/tests/config.py.in
===================================================================
--- src/tests/config.py.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
+++ src/tests/config.py.in	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+config.py
+"""
+
+SRCDIR   = "@srcdir@"
+BUILDDIR = "@builddir@"
+HOSTARCH = "@host_cpu@"
Index: src/tests/io.data
===================================================================
--- src/tests/io.data	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ 	(revision )
@@ -1,1 +1,0 @@
-falseA 23 93 1 2 3 4 5 6 7 8 1.1 1.2 1.3 1.1+2.3 1.1-2.3 1.1-2.3 abc xyz
Index: src/tests/io2.c
===================================================================
--- src/tests/io2.c	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/io2.c	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -1,10 +1,10 @@
-// 
+//
 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
 //
 // The contents of this file are covered under the licence agreement in the
 // file "LICENCE" distributed with Cforall.
-// 
-// io2.c -- 
-// 
+//
+// io2.c --
+//
 // Author           : Peter A. Buhr
 // Created On       : Wed Mar  2 16:56:02 2016
@@ -12,7 +12,10 @@
 // Last Modified On : Thu May 24 21:17:41 2018
 // Update Count     : 103
-// 
+//
 
 #include <fstream>
+
+ #define xstr(s) str(s)
+#define str(s) #s
 
 int main() {
@@ -38,5 +41,5 @@
 	char s1[size], s2[size];
 
-	ifstream in = { "io.data" };						// create / open file
+	ifstream in = { xstr(IN_DIR) "io.data" };						// create / open file
 
 	sout | "input bacis types" | endl;
Index: src/tests/pybin/settings.py
===================================================================
--- src/tests/pybin/settings.py	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/pybin/settings.py	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -1,3 +1,16 @@
+from __future__ import print_function
+
+import os
 import sys
+
+try :
+	sys.path.append(os.getcwd())
+	import config
+
+	SRCDIR = os.path.abspath(config.SRCDIR)
+	BUILDDIR = os.path.abspath(config.BUILDDIR)
+except:
+	print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
+	sys.exit(1)
 
 class Architecture:
@@ -5,4 +18,5 @@
 		'x64'			: 'x64',
 		'x86-64'		: 'x64',
+		'x86_64'		: 'x64',
 		'x86'			: 'x86',
 		'i386'		: 'x86',
@@ -25,5 +39,5 @@
 			self.cross_compile = False
 			try:
-				arch = machine_default()
+				arch = config.HOSTARCH
 				self.target = Architecture.makeCanonical( arch )
 			except KeyError:
@@ -66,12 +80,7 @@
 	arch       = Architecture(options.arch)
 
+
 def updateMakeCmd(force, jobs):
 	global make
 
 	make = "make" if not force else ("make -j%i" % jobs)
-
-
-def set_machine_default( func ):
-	global machine_default
-
-	machine_default = func
Index: src/tests/pybin/test_run.py
===================================================================
--- src/tests/pybin/test_run.py	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/pybin/test_run.py	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -33,14 +33,14 @@
 
 	def expect(self):
-		return ("%s/.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch))
+		return ("%s.expect/%s%s.txt" % (os.path.join(settings.SRCDIR, self.path), self.name, '' if not self.arch else ".%s" % self.arch))
 
 	def error_log(self):
-		return ("%s/.err/%s.log"    % (self.path, self.name))
+		return ("%s.err/%s.log"    % (os.path.join(settings.BUILDDIR, self.path), self.name))
 
 	def output_log(self):
-		return ("%s/.out/%s.log"    % (self.path, self.name))
+		return ("%s.out/%s.log"    % (os.path.join(settings.BUILDDIR, self.path), self.name))
 
 	def input(self):
-		return ("%s/.in/%s.txt"     % (self.path, self.name))
+		return ("%s.in/%s.txt"     % (os.path.join(settings.SRCDIR, self.path), self.name))
 
 	def target_output(self):
@@ -49,4 +49,7 @@
 	def target(self):
 		return os.path.join(self.path, self.name)
+
+	def target_executable(self):
+		return os.path.join(settings.BUILDDIR, self.path, self.name)
 
 	@classmethod
Index: src/tests/pybin/tools.py
===================================================================
--- src/tests/pybin/tools.py	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/pybin/tools.py	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -9,4 +9,5 @@
 import stat
 import sys
+import fileinput
 
 from pybin import settings
@@ -33,4 +34,19 @@
 		out, err = proc.communicate()
 		return proc.returncode, out
+
+def is_ascii(fname):
+	if not os.path.isfile(fname):
+		return False
+
+	code, out = sh("file %s" % fname, print2stdout = False)
+	if code != 0:
+		return False
+
+	match = re.search(".*: (.*)", out)
+
+	if not match:
+		return False
+
+	return match.group(1) == "ASCII text"
 
 # Remove 1 or more files silently
@@ -105,17 +121,8 @@
 # helper function to replace patterns in a file
 def file_replace(fname, pat, s_after):
-    # first, see if the pattern is even in the file.
-    with open(fname) as f:
-        if not any(re.search(pat, line) for line in f):
-            return # pattern does not occur in file so we are done.
-
-    # pattern is in the file, so perform replace operation.
-    with open(fname) as f:
-        out_fname = fname + ".tmp"
-        out = open(out_fname, "w")
-        for line in f:
-            out.write(re.sub(pat, s_after, line))
-        out.close()
-        os.rename(out_fname, fname)
+	file = fileinput.FileInput(fname, inplace=True, backup='.bak')
+	for line in file:
+		print(line.replace(pat, s_after), end='')
+	file.close()
 
 # helper function to check if a files contains only a specific string
@@ -140,5 +147,7 @@
 # transform path to canonical form
 def canonicalPath(path):
-	return os.path.join('.', os.path.normpath(path) )
+	abspath = os.path.abspath(__main__.__file__)
+	dname = os.path.dirname(abspath)
+	return os.path.join(dname, os.path.normpath(path) )
 
 # compare path even if form is different
@@ -151,34 +160,14 @@
 		for name in names:
 			path = os.path.join(dirname, name)
-
 			op( path )
 
 	# Start the walk
-	os.path.walk('.', step, '')
+	abspath = os.path.abspath(__main__.__file__)
+	dname = os.path.dirname(abspath)
+	os.path.walk(dname, step, '')
 
 ################################################################################
 #               system
 ################################################################################
-
-# parses the Makefile to find the machine type (32-bit / 64-bit)
-def getMachineType():
-	sh('echo "void ?{}(int&a,int b){}int main(){return 0;}" > .dummy.c')
-	ret, out = make('.dummy', silent = True)
-
-	if ret != 0:
-		print("Failed to identify architecture:")
-		print(out)
-		print("Stopping")
-		rm( (".dummy.c",".dummy") )
-		sys.exit(1)
-
-	_, out = sh("file .dummy", print2stdout=False)
-	rm( (".dummy.c",".dummy") )
-
-	if settings.dry_run :
-		return 'x64'
-
-	return re.search(r"[^,]+,([^,]+),", out).group(1).strip()
-
 # count number of jobs to create
 def jobCount( options, tests ):
@@ -244,4 +233,2 @@
 	else:
 		print(text)
-
-settings.set_machine_default( getMachineType )
Index: src/tests/test.py
===================================================================
--- src/tests/test.py	(revision 40a7d9c4e045d2ccfb4f7032a6cc0e9e62d9c75c)
+++ src/tests/test.py	(revision 91788fa6e179ae25a8278f9ddc51d04624c41759)
@@ -19,5 +19,5 @@
 
 	def matchTest(path):
-		match = re.search("(\.[\w\/\-_]*)\/.expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt", path)
+		match = re.search("%s\/([\w\/\-_]*).expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt" % settings.SRCDIR, path)
 		if match :
 			test = Test()
@@ -116,8 +116,17 @@
 #               running test functions
 ################################################################################
+# fix the absolute paths in the output
+def fixoutput( fname ):
+	if not is_ascii(fname):
+		return
+
+	file_replace(fname, "%s/" % settings.SRCDIR, "")
+
+
 # logic to run a single test and return the result (No handling of printing or other test framework logic)
 def run_single_test(test):
 
 	# find the output file based on the test name and options flag
+	exe_file = test.target_executable();
 	out_file = test.target_output()
 	err_file = test.error_log()
@@ -129,5 +138,5 @@
 
 	# remove any outputs from the previous tests to prevent side effects
-	rm( (out_file, err_file, test.target()) )
+	rm( (out_file, err_file, exe_file) )
 
 	# build, skipping to next test on error
@@ -146,10 +155,10 @@
 	if make_ret == 0 or settings.dry_run:
 		before = time.time()
-		if settings.dry_run or fileIsExecutable(test.target()) :
+		if settings.dry_run or fileIsExecutable(exe_file) :
 			# run test
-			retcode, _ = sh("timeout 60 %s > %s 2>&1" % (test.target(), out_file), input = in_file)
+			retcode, _ = sh("timeout 60 %s > %s 2>&1" % (exe_file, out_file), input = in_file)
 		else :
 			# simply cat the result into the output
-			retcode, _ = sh("cat %s > %s" % (test.target(), out_file))
+			retcode, _ = sh("cat %s > %s" % (exe_file, out_file))
 
 		after = time.time()
@@ -170,4 +179,5 @@
 		else :
 			# fetch return code and error from the diff command
+			fixoutput(out_file)
 			retcode, error = diff(cmp_file, out_file)
 
@@ -241,6 +251,4 @@
 ################################################################################
 if __name__ == "__main__":
-	#always run from same folder
-	chdir()
 
 	# parse the command line arguments
