Index: HelenOS.config
===================================================================
--- HelenOS.config	(revision c12f8911dc227a24b5ab11008009157569740d86)
+++ HelenOS.config	(revision 795e2bfe0ca714517bdac2b7abae8091c5f88ee9)
@@ -299,29 +299,29 @@
 % Compiler
 @ "gcc_cross" GNU C Compiler (cross-compiler)
-@ "gcc_native" GNU C Compiler (native)
+@ "clang" Clang
 @ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
 @ "icc" Intel C Compiler
-@ "clang" Clang
+@ "gcc_native" GNU C Compiler (native)
 ! [PLATFORM=amd64|PLATFORM=ia32] COMPILER (choice)
 
 % Compiler
 @ "gcc_cross" GNU C Compiler (cross-compiler)
+@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
+@ "icc" Intel C Compiler
 @ "gcc_native" GNU C Compiler (native)
-@ "icc" Intel C Compiler
-@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
 ! [PLATFORM=ia64] COMPILER (choice)
 
 % Compiler
 @ "gcc_cross" GNU C Compiler (cross-compiler)
+@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
 @ "gcc_native" GNU C Compiler (native)
-@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
-! [PLATFORM=mips32|PLATFORM=ppc32] COMPILER (choice)
+! [PLATFORM=sparc32] COMPILER (choice)
 
 % Compiler
 @ "gcc_cross" GNU C Compiler (cross-compiler)
+@ "clang" Clang
+@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
 @ "gcc_native" GNU C Compiler (native)
-@ "gcc_helenos" GNU C Compiler (experimental HelenOS-specific cross-compiler)
-@ "clang" Clang
-! [PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=sparc32|PLATFORM=sparc64] COMPILER (choice)
+! [PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=abs32le|PLATFORM=arm32|PLATFORM=sparc64] COMPILER (choice)
 
 
Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision c12f8911dc227a24b5ab11008009157569740d86)
+++ kernel/Makefile	(revision 795e2bfe0ca714517bdac2b7abae8091c5f88ee9)
@@ -105,8 +105,7 @@
 CLANG_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-ffreestanding -fno-builtin -nostdlib -nostdinc \
-	-Wall -Werror -Wextra -Wno-unused-parameter -Wmissing-prototypes \
+	-std=gnu99 -Wall -Werror -Wextra -Wno-unused-parameter -Wmissing-prototypes \
 	-Werror-implicit-function-declaration -Wwrite-strings \
-	-integrated-as \
-	-pipe -target $(CLANG_TARGET)
+	-integrated-as -pipe -target $(CLANG_TARGET)
 
 ifeq ($(CONFIG_DEBUG),y)
Index: tools/autogen.py
===================================================================
--- tools/autogen.py	(revision c12f8911dc227a24b5ab11008009157569740d86)
+++ tools/autogen.py	(revision 795e2bfe0ca714517bdac2b7abae8091c5f88ee9)
@@ -66,12 +66,12 @@
 	for i in range(len(struct['members'])):
 		member = struct['members'][i]
-		code = code + ("\temit_constant(%s_OFFSET_%s, offsetof(%s_t, %s));\n" % 
+		code = code + ("\temit_constant(%s_OFFSET_%s, offsetof(%s_t, %s));\n" %
 		    (struct['name'].upper(), member['name'].upper(), struct['name'],
 		    member['name']))
-		code = code + ("\temit_constant(%s_SIZE_%s, sizeof(((%s_t *) 0)->%s));\n" % 
+		code = code + ("\temit_constant(%s_SIZE_%s, sizeof(((%s_t *) 0)->%s));\n" %
 		    (struct['name'].upper(), member['name'].upper(), struct['name'],
 		    member['name']))
 		if 'elements' in member.keys():
-			code = code + ("\temit_constant(%s_%s_ITEM_SIZE, sizeof(%s));\n" % 
+			code = code + ("\temit_constant(%s_%s_ITEM_SIZE, sizeof(%s));\n" %
 			    (struct['name'].upper(), member['name'].upper(), member['type']))
 			
@@ -83,5 +83,5 @@
 
 	code = """
-%s		
+%s
 
 #define str(s) #s
@@ -92,5 +92,7 @@
 %s
 
-int main()
+extern int main(int, char *[]);
+
+int main(int argc, char *argv[])
 {
 %s
@@ -100,5 +102,5 @@
 	""" % (generate_includes(struct), generate_struct(struct),
 	    generate_probes(struct), name.upper(), typename)
-
+	
 	return code
 
@@ -167,3 +169,2 @@
 
 run()
-
Index: tools/autotool.py
===================================================================
--- tools/autotool.py	(revision c12f8911dc227a24b5ab11008009157569740d86)
+++ tools/autotool.py	(revision 795e2bfe0ca714517bdac2b7abae8091c5f88ee9)
@@ -88,4 +88,6 @@
 	AUTOTOOL_DECLARE("floatsize", "", tag, #type, "", "", sizeof(type));
 
+extern int main(int, char *[]);
+
 int main(int argc, char *argv[])
 {
@@ -115,4 +117,6 @@
 	AUTOTOOL_DECLARE("intsize", "signed", tag, #type, "", "", sizeof(signed type));
 
+extern int main(int, char *[]);
+
 int main(int argc, char *argv[])
 {
@@ -216,22 +220,22 @@
 		if (config['CROSS_TARGET'] == "arm32"):
 			gnu_target = "arm-linux-gnueabi"
-			clang_target = "arm-unknown-linux"
+			clang_target = "arm-unknown-none"
 			helenos_target = "arm-helenos-gnueabi"
 		
 		if (config['CROSS_TARGET'] == "ia32"):
 			gnu_target = "i686-pc-linux-gnu"
-			clang_target = "i386-unknown-linux"
+			clang_target = "i686-unknown-none"
 			helenos_target = "i686-pc-helenos"
 		
 		if (config['CROSS_TARGET'] == "mips32"):
+			cc_args.append("-mabi=32")
 			gnu_target = "mipsel-linux-gnu"
-			clang_target = "mipsel-unknown-linux"
+			clang_target = "mipsel-unknown-none"
 			helenos_target = "mipsel-helenos"
-			common['CC_ARGS'].append("-mabi=32")
 	
 	if (config['PLATFORM'] == "amd64"):
 		target = config['PLATFORM']
 		gnu_target = "amd64-linux-gnu"
-		clang_target = "x86_64-unknown-linux"
+		clang_target = "x86_64-unknown-none"
 		helenos_target = "amd64-helenos"
 	
@@ -239,5 +243,5 @@
 		target = config['PLATFORM']
 		gnu_target = "arm-linux-gnueabi"
-		clang_target = "arm-unknown-linux"
+		clang_target = "arm-unknown-none-eabi"
 		helenos_target = "arm-helenos-gnueabi"
 	
@@ -245,5 +249,5 @@
 		target = config['PLATFORM']
 		gnu_target = "i686-pc-linux-gnu"
-		clang_target = "i386-unknown-linux"
+		clang_target = "i686-unknown-none"
 		helenos_target = "i686-pc-helenos"
 	
@@ -260,5 +264,5 @@
 			target = config['PLATFORM']
 			gnu_target = "mipsel-linux-gnu"
-			clang_target = "mipsel-unknown-linux"
+			clang_target = "mipsel-unknown-none"
 			helenos_target = "mipsel-helenos"
 		
@@ -266,5 +270,5 @@
 			target = "mips32eb"
 			gnu_target = "mips-linux-gnu"
-			clang_target = "mips-unknown-linux"
+			clang_target = "mips-unknown-none"
 			helenos_target = "mips-helenos"
 	
@@ -276,5 +280,5 @@
 			target = config['PLATFORM']
 			gnu_target = "mips64el-linux-gnu"
-			clang_target = "mips64el-unknown-linux"
+			clang_target = "mips64el-unknown-none"
 			helenos_target = "mips64el-helenos"
 	
@@ -282,5 +286,5 @@
 		target = config['PLATFORM']
 		gnu_target = "ppc-linux-gnu"
-		clang_target = "powerpc-unknown-linux"
+		clang_target = "ppc-unknown-none"
 		helenos_target = "ppc-helenos"
 	
@@ -293,5 +297,5 @@
 		target = config['PLATFORM']
 		gnu_target = "sparc64-linux-gnu"
-		clang_target = "sparc-unknown-linux"
+		clang_target = "sparc-unknown-none"
 		helenos_target = "sparc64-helenos"
 	
@@ -417,5 +421,5 @@
 	
 	for typedef in floatsizes:
-		outf.write("\nDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
+		outf.write("\tDECLARE_FLOATSIZE(\"%s\", %s);\n" % (typedef['tag'], typedef['type']))
 	
 	outf.write(PROBE_TAIL)
@@ -889,8 +893,9 @@
 		
 		if (config['COMPILER'] == "icc"):
-			common['CC'] = "icc"
 			check_app([common['CC'], "-V"], "Intel C++ Compiler", "support is experimental")
 			check_gcc(None, "", common, PACKAGE_GCC)
 			check_binutils(None, binutils_prefix, common, PACKAGE_BINUTILS)
+			
+			common['CC'] = "icc"
 		
 		if (config['COMPILER'] == "clang"):
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision c12f8911dc227a24b5ab11008009157569740d86)
+++ uspace/Makefile.common	(revision 795e2bfe0ca714517bdac2b7abae8091c5f88ee9)
@@ -247,10 +247,9 @@
 # something won't break because of that:
 # -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) -finput-charset=UTF-8
-CLANG_CFLAGS = $(LIBC_INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
+CLANG_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-ffreestanding -fno-builtin -nostdlib -nostdinc \
 	-Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
-	-Werror-implicit-function-declaration -Wwrite-strings \
-	-integrated-as \
-	-pipe -g -target $(CLANG_TARGET) -D__$(ENDIANESS)__
+	-std=gnu99 -Werror-implicit-function-declaration -Wwrite-strings \
+	-integrated-as -pipe -g -target $(CLANG_TARGET) -D__$(ENDIANESS)__
 
 LIB_CFLAGS = $(CFLAGS) -fPIC -D__IN_SHARED_LIBC__
@@ -290,26 +289,25 @@
 
 ifeq ($(COMPILER),gcc_cross)
-	CFLAGS += $(GCC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS += $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),gcc_helenos)
-	CFLAGS += $(GCC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS += $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),gcc_native)
-	CFLAGS += $(GCC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS += $(GCC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),icc)
-	CFLAGS += $(ICC_CFLAGS) $(EXTRA_CFLAGS)
+	CFLAGS += $(ICC_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
 
 ifeq ($(COMPILER),clang)
-	CFLAGS += $(CLANG_CFLAGS) $(EXTRA_CFLAGS)
-	GCC_CFLAGS += $(EXTRA_CFLAGS)
+	CFLAGS += $(CLANG_CFLAGS)
 	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
 endif
@@ -373,7 +371,7 @@
 
 %.o: %.S $(DEPEND)
-	$(GCC) $(DEFS) $(GCC_CFLAGS) -D__ASM__ -c $< -o $@
-ifeq ($(PRECHECK),y)
-	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
+	$(GCC) $(DEFS) $(GCC_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
 endif
 
@@ -385,19 +383,19 @@
 
 %.o: %.c $(DEPEND)
-	$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
-ifeq ($(PRECHECK),y)
-	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+	$(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS)
 endif
 
 %.test.o: %.c $(DEPEND)
-	$(CC) $(DEFS) $(CFLAGS) $(TEST_CFLAGS) -c $< -o $@
-ifeq ($(PRECHECK),y)
-	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+	$(CC) $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS)
 endif
 
 %.lo: %.S $(DEPEND)
-	$(CC) $(DEFS) $(LIB_CFLAGS) -D__ASM__ -c $< -o $@
-ifeq ($(PRECHECK),y)
-	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
+	$(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__
 endif
 
@@ -409,11 +407,11 @@
 
 %.lo: %.c $(DEPEND)
-	$(CC) $(DEFS) $(LIB_CFLAGS) -c $< -o $@
-ifeq ($(PRECHECK),y)
-	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS)
+	$(CC) $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+ifeq ($(PRECHECK),y)
+	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS)
 endif
 
 $(DEPEND): $(PRE_DEPEND)
-	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(SOURCES) $(TEST_SOURCES) > $@ 2> /dev/null
+	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -- $(SOURCES) $(TEST_SOURCES) > $@ 2> /dev/null
 	-[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
 
