Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision 19f857a3b361739b06d4f547174ae4ac1b99c651)
+++ kernel/Makefile	(revision 7c682dd18cb1e1cac93f7e180e1fc41df32f824c)
@@ -69,7 +69,4 @@
 SIZEOK_MAP = generic/src/debug/sizeok_map.o
 
-INCLUDES = generic/include
-OPTIMIZATION = 3
-
 .PHONY: all clean
 
@@ -84,7 +81,10 @@
 #
 
+INCLUDES = generic/include
+OPTIMIZATION = 3
+
 DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__
 
-GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
+GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
@@ -93,5 +93,5 @@
 	-Werror -pipe
 
-ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
+ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
 	-Werror-implicit-function-declaration -Werror -wd170
@@ -101,5 +101,5 @@
 	-erroff=E_ZERO_SIZED_STRUCT_UNION
 
-CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
+CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
@@ -107,7 +107,4 @@
 	-Werror-implicit-function-declaration -Wwrite-strings \
 	-pipe -arch $(CLANG_ARCH)
-
-LFLAGS = -M
-AFLAGS =
 
 -include arch/$(KARCH)/Makefile.inc
@@ -356,5 +353,5 @@
 
 $(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS)
-	$(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS) -o $@ -Map $(MAP)
+	$(LD) $(LFLAGS) -T $(LINK) -M -Map $(MAP) -o $@  $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SYMTAB_OBJECTS)
 
 $(LINK): $(LINK).in $(DEPEND)
@@ -368,5 +365,5 @@
 
 %.o: %.s $(DEPEND)
-	$(AS) $(AFLAGS) $< -o $@
+	$(AS) $(AFLAGS) -o $@ $<
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
@@ -399,5 +396,5 @@
 $(REAL_MAP).bin: $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS)
 	echo $(SYMTAB_SECTION) | $(AS) $(AFLAGS) -o $(EMPTY_MAP)
-	$(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP) -o $@ -Map $(MAP_PREV)
+	$(LD) $(LFLAGS) -T $(LINK) -M -Map $(MAP_PREV) -o $@  $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(EMPTY_MAP)
 	$(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
 	$(GENMAP) $(MAP_PREV) $(DUMP) $@
@@ -407,5 +404,5 @@
 	
 	echo $(SYMTAB_SECTION)" .incbin \"$@\"" | $(AS) $(AFLAGS) -o $(SIZEOK_MAP)
-	$(LD) -T $(LINK) $(LFLAGS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP) -o $@ -Map $(MAP_PREV)
+	$(LD) $(LFLAGS) -T $(LINK) -M -Map $(MAP_PREV) -o $@ $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(EXTRA_OBJECTS) $(SIZEOK_MAP)
 	$(OBJDUMP) -t $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) > $(DUMP)
 	$(GENMAP) $(MAP_PREV) $(DUMP) $@
Index: kernel/arch/ia64/Makefile.inc
===================================================================
--- kernel/arch/ia64/Makefile.inc	(revision 19f857a3b361739b06d4f547174ae4ac1b99c651)
+++ kernel/arch/ia64/Makefile.inc	(revision 7c682dd18cb1e1cac93f7e180e1fc41df32f824c)
@@ -34,6 +34,6 @@
 ICC_CFLAGS += $(CMN1)
 
-LFLAGS += -EL
-AFLAGS += -mconstant-gp
+LFLAGS = -EL
+AFLAGS = -mconstant-gp
 
 BITS = 64
Index: kernel/arch/ppc32/Makefile.inc
===================================================================
--- kernel/arch/ppc32/Makefile.inc	(revision 19f857a3b361739b06d4f547174ae4ac1b99c651)
+++ kernel/arch/ppc32/Makefile.inc	(revision 7c682dd18cb1e1cac93f7e180e1fc41df32f824c)
@@ -32,6 +32,6 @@
 
 GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
-AFLAGS += -a32
-LFLAGS += -no-check-sections -N
+AFLAGS = -a32
+LFLAGS = -no-check-sections -N
 
 BITS = 32
Index: kernel/arch/sparc64/Makefile.inc
===================================================================
--- kernel/arch/sparc64/Makefile.inc	(revision 19f857a3b361739b06d4f547174ae4ac1b99c651)
+++ kernel/arch/sparc64/Makefile.inc	(revision 7c682dd18cb1e1cac93f7e180e1fc41df32f824c)
@@ -34,5 +34,5 @@
 SUNCC_CFLAGS += -m64 -xarch=sparc -xregs=appl,no%float
 
-LFLAGS += -no-check-sections -N
+LFLAGS = -no-check-sections -N
 
 BITS = 64
