Index: Makefile.am
===================================================================
--- Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ Makefile.am	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -23,5 +23,5 @@
 SUBDIRS = driver src . @LIBCFA_TARGET_DIRS@
 
-@LIBCFA_TARGET_MAKEFILES@ : Makefile
+@LIBCFA_TARGET_MAKEFILES@ : Makefile $(srcdir)/libcfa/configure
 	@$(eval config_file = $(dir $@)config.data)
 	@ls $(config_file) || (echo "Missing config.data, re-run configure script again" && false)
Index: Makefile.in
===================================================================
--- Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ Makefile.in	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -893,5 +893,5 @@
  # order important
 
-@LIBCFA_TARGET_MAKEFILES@ : Makefile
+@LIBCFA_TARGET_MAKEFILES@ : Makefile $(srcdir)/libcfa/configure
 	@$(eval config_file = $(dir $@)config.data)
 	@ls $(config_file) || (echo "Missing config.data, re-run configure script again" && false)
Index: configure
===================================================================
--- configure	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ configure	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -2488,5 +2488,5 @@
   yes) AM_DEFAULT_VERBOSITY=0;;
    no) AM_DEFAULT_VERBOSITY=1;;
-    *) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=0;;
 esac
 am_make=${MAKE-make}
@@ -2526,4 +2526,7 @@
 
 
+
+# don't use the default CFLAGS as they unconditonnaly add -O2
+: ${CFLAGS=""}
 
 am__api_version='1.15'
Index: configure.ac
===================================================================
--- configure.ac	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ configure.ac	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -7,7 +7,10 @@
 #AC_CONFIG_SRCDIR([src/main.cc])
 AC_CONFIG_HEADERS([config.h:src/config.h.in])
-AM_SILENT_RULES([no])
+AM_SILENT_RULES([yes])
 
 m4_include([automake/cfa.m4])
+
+# don't use the default CFLAGS as they unconditonnaly add -O2
+: ${CFLAGS=""}
 
 AM_INIT_AUTOMAKE([subdir-objects])
Index: libcfa/Makefile.in
===================================================================
--- libcfa/Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/Makefile.in	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -229,4 +229,6 @@
 CFLAGS = @CFLAGS@
 CONFIGURATION = @CONFIGURATION@
+CONFIG_CFAFLAGS = @CONFIG_CFAFLAGS@
+CONFIG_CFLAGS = @CONFIG_CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
Index: libcfa/configure
===================================================================
--- libcfa/configure	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/configure	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -623,4 +623,6 @@
 CFA_PREFIX
 CFA_NAME
+CONFIG_CFAFLAGS
+CONFIG_CFLAGS
 ARCH_FLAGS
 CFACPP
@@ -629,8 +631,4 @@
 CONFIGURATION
 ARCHITECTURE
-AM_BACKSLASH
-AM_DEFAULT_VERBOSITY
-AM_DEFAULT_V
-AM_V
 am__untar
 am__tar
@@ -656,4 +654,8 @@
 INSTALL_SCRIPT
 INSTALL_PROGRAM
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
 target_alias
 host_alias
@@ -1910,4 +1912,43 @@
 
 
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=0;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
 
 
@@ -2343,43 +2384,4 @@
 rmdir .tst 2>/dev/null
 
-# Check whether --enable-silent-rules was given.
-if test "${enable_silent_rules+set}" = set; then :
-  enableval=$enable_silent_rules;
-fi
-
-case $enable_silent_rules in # (((
-  yes) AM_DEFAULT_VERBOSITY=0;;
-   no) AM_DEFAULT_VERBOSITY=1;;
-    *) AM_DEFAULT_VERBOSITY=1;;
-esac
-am_make=${MAKE-make}
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
-$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
-if ${am_cv_make_support_nested_variables+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if $as_echo 'TRUE=$(BAR$(V))
-BAR0=false
-BAR1=true
-V=1
-am__doit:
-	@$(TRUE)
-.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
-  am_cv_make_support_nested_variables=yes
-else
-  am_cv_make_support_nested_variables=no
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
-$as_echo "$am_cv_make_support_nested_variables" >&6; }
-if test $am_cv_make_support_nested_variables = yes; then
-    AM_V='$(V)'
-  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
-else
-  AM_V=$AM_DEFAULT_VERBOSITY
-  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
-fi
-AM_BACKSLASH='\'
-
 if test "`cd $srcdir && pwd`" != "`pwd`"; then
   # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
@@ -2498,4 +2500,7 @@
 
 
+# don't use the default CFLAGS as they unconditonnaly add -O2
+: ${CFLAGS=""}
+
 # Allow program name tansformation
 # will fill program_transform_name with appropriate sed regex
@@ -2511,4 +2516,6 @@
 
 
+#==============================================================================
+#Handle specific flags
 case $ARCHITECTURE in
 	"x64"        ) ARCH_FLAGS="-m64";;
@@ -2516,4 +2523,22 @@
 	"arm"        ) ARCH_FLAGS="";;
 esac
+
+
+
+case $CONFIGURATION in
+	"debug"   )
+		CONFIG_CFLAGS="-O0 -g"
+		CONFIG_CFAFLAGS="-debug"
+	;;
+	"nodebug" )
+		CONFIG_CFLAGS="-O2 -s"
+		CONFIG_CFAFLAGS="-nodebug"
+	;;
+	"nolib"   )
+		CONFIG_CFLAGS=""
+		CONFIG_CFAFLAGS=""
+	;;
+esac
+
 
 
Index: libcfa/configure.ac
===================================================================
--- libcfa/configure.ac	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/configure.ac	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -5,8 +5,12 @@
 AC_INIT([cfa-cc],[1.0.0.0],[cforall@plg.uwaterloo.ca])
 AC_CONFIG_AUX_DIR([./automake])
+AM_SILENT_RULES([yes])
 
 m4_include([../automake/cfa.m4])
 
 AM_INIT_AUTOMAKE([subdir-objects])
+
+# don't use the default CFLAGS as they unconditonnaly add -O2
+: ${CFLAGS=""}
 
 # Allow program name tansformation
@@ -23,4 +27,6 @@
 AC_SUBST(CFACPP)
 
+#==============================================================================
+#Handle specific flags
 case $ARCHITECTURE in
 	"x64"        ) ARCH_FLAGS="-m64";;
@@ -30,4 +36,22 @@
 
 AC_SUBST(ARCH_FLAGS)
+
+case $CONFIGURATION in
+	"debug"   )
+		CONFIG_CFLAGS="-O0 -g"
+		CONFIG_CFAFLAGS="-debug"
+	;;
+	"nodebug" )
+		CONFIG_CFLAGS="-O2 -s"
+		CONFIG_CFAFLAGS="-nodebug"
+	;;
+	"nolib"   )
+		CONFIG_CFLAGS=""
+		CONFIG_CFAFLAGS=""
+	;;
+esac
+
+AC_SUBST(CONFIG_CFLAGS)
+AC_SUBST(CONFIG_CFAFLAGS)
 
 #==============================================================================
Index: libcfa/prelude/Makefile.am
===================================================================
--- libcfa/prelude/Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/prelude/Makefile.am	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -24,5 +24,6 @@
 
 CC = @CFACC@
-AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@
+AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
+AM_CFAFLAGS = @CONFIG_CFAFLAGS@
 
 $(DEPDIR) :
Index: libcfa/prelude/Makefile.in
===================================================================
--- libcfa/prelude/Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/prelude/Makefile.in	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -174,4 +174,6 @@
 CFLAGS = @CFLAGS@
 CONFIGURATION = @CONFIGURATION@
+CONFIG_CFAFLAGS = @CONFIG_CFAFLAGS@
+CONFIG_CFLAGS = @CONFIG_CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
@@ -263,5 +265,6 @@
 cfalib_DATA = gcc-builtins.cf builtins.cf extras.cf prelude.cf bootloader.c
 noinst_DATA = ../src/prelude.c
-AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@
+AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
+AM_CFAFLAGS = @CONFIG_CFAFLAGS@
 MOSTLYCLEANFILES = bootloader.c builtins.cf extras.cf gcc-builtins.c gcc-builtins.cf prelude.cf
 MAINTAINERCLEANFILES = ${addprefix ${libdir}/,${cfalib_DATA}} ${addprefix ${libdir}/,${lib_LIBRARIES}}
Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/src/Makefile.am	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -28,7 +28,7 @@
 # use -no-include-stdhdr to prevent rebuild cycles
 # The built sources must not depend on the installed headers
-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@
+AM_CFAFLAGS = -quiet -in-tree -imacros prelude.c -I$(srcdir)/stdhdr @CONFIG_CFAFLAGS@
+AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
+AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
 CFACC = @CFACC@
 
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ libcfa/src/Makefile.in	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -243,4 +243,6 @@
 CFLAGS = @CFLAGS@
 CONFIGURATION = @CONFIGURATION@
+CONFIG_CFAFLAGS = @CONFIG_CFAFLAGS@
+CONFIG_CFLAGS = @CONFIG_CFLAGS@
 CPPFLAGS = @CPPFLAGS@
 CXX = @CXX@
@@ -339,7 +341,7 @@
 # use -no-include-stdhdr to prevent rebuild cycles
 # The built sources must not depend on the installed headers
-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@
+AM_CFAFLAGS = -quiet -in-tree -imacros prelude.c -I$(srcdir)/stdhdr @CONFIG_CFAFLAGS@
+AM_CFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
+AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
 
 #----------------------------------------------------------------------------------------------------------------
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ tests/Makefile.am	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -33,5 +33,5 @@
 	-DIN_DIR="${srcdir}/.in/"
 
-AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS}
+AM_CFLAGS += ${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
 
 CC = @CFACC@
@@ -59,5 +59,5 @@
 
 .validate: .validate.c
-	@$(COMPILE) .validate.c -fsyntax-only
+	$(COMPILE) .validate.c -fsyntax-only -Wall -Wextra -Werror
 
 .validate.c:
Index: tests/Makefile.in
===================================================================
--- tests/Makefile.in	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ tests/Makefile.in	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -304,5 +304,5 @@
 AM_CFLAGS = $(if $(test), 2> $(test), ) -g -Wall -Wno-unused-function \
 	-quiet @CFA_FLAGS@ -DIN_DIR="${srcdir}/.in/" ${DEBUG_FLAGS} \
-	${INSTALL_FLAGS}
+	${INSTALL_FLAGS} ${ARCH_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
@@ -625,5 +625,5 @@
 
 .validate: .validate.c
-	@$(COMPILE) .validate.c -fsyntax-only
+	$(COMPILE) .validate.c -fsyntax-only -Wall -Wextra -Werror
 
 .validate.c:
Index: tests/pybin/settings.py
===================================================================
--- tests/pybin/settings.py	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ tests/pybin/settings.py	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -29,20 +29,36 @@
 	}
 
+	CrossCompileFlags = {
+		'x64' : 'ARCH_FLAGS=-m64',
+		'x86' : 'ARCH_FLAGS=-m32',
+	}
+
 	def __init__(self, arch):
+		try:
+			canonical_host = Architecture.makeCanonical( config.HOSTARCH )
+		except KeyError:
+			print("Unkown host architecture %s" % config.HOSTARCH, file=sys.stderr)
+			sys.exit(1)
+
 		if arch:
+			try:
+				arch = Architecture.makeCanonical( arch )
+			except KeyError:
+				print("Unkown architecture %s" % arch, file=sys.stderr)
+				sys.exit(1)
+
+		if arch and arch != canonical_host:
+			self.target = arch
 			self.cross_compile = True
-			try:
-				self.target = Architecture.makeCanonical( arch )
+			try :
+				self.flags = Architecture.CrossCompileFlags[arch]
 			except KeyError:
-				print("Unkown architecture %s" % arch)
+				print("Cross compilation not available for architecture %s" % arch, file=sys.stderr)
 				sys.exit(1)
+
 		else:
+			self.target = canonical_host
 			self.cross_compile = False
-			try:
-				arch = config.HOSTARCH
-				self.target = Architecture.makeCanonical( arch )
-			except KeyError:
-				print("Running on unkown architecture %s" % arch)
-				sys.exit(1)
+			self.flags = ""
 
 		self.string = self.target
@@ -65,5 +81,5 @@
 	def __init__(self, value):
 		self.string = "debug" if value else "no debug"
-		self.flags  = """DEBUG_FLAGS="%s" """ % ("-debug" if value else "-nodebug")
+		self.flags  = """DEBUG_FLAGS="%s" """ % ("-debug -O0" if value else "-nodebug -O2")
 
 class Install:
@@ -98,5 +114,5 @@
 		with open (".validate.err", "r") as myfile:
 			error=myfile.read()
-		print('ERROR: Invalid configuration', file=sys.stderr)
+		print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr)
 		print("       verify returned : \n%s" % error, file=sys.stderr)
 		tools.rm("%s/.validate.err" % BUILDDIR)
Index: tests/pybin/tools.py
===================================================================
--- tests/pybin/tools.py	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ tests/pybin/tools.py	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -101,4 +101,5 @@
 		'-s' if silent else '',
 		test_param,
+		settings.arch.flags,
 		settings.debug.flags,
 		settings.install.flags,
Index: tests/test.py
===================================================================
--- tests/test.py	(revision a5121bff2d239413034fc4cc466f9e5b15eebd1b)
+++ tests/test.py	(revision 575a6e500466575fde0acedd9b84c09b42ac2ee8)
@@ -98,5 +98,10 @@
 	parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
 
-	options =  parser.parse_args()
+	try:
+		options =  parser.parse_args()
+	except:
+		print('ERROR: invalid arguments', file=sys.stderr)
+		parser.print_help(sys.stderr)
+    		sys.exit(1)
 
 	# script must have at least some tests to run or be listing
