Index: kernel/Makefile
===================================================================
--- kernel/Makefile	(revision d75dc0561c7ce077e18de03f15c1afa664e05d5e)
+++ kernel/Makefile	(revision 8988fdea211b9827f60cfe7ed099a0d1bad17fcd)
@@ -49,6 +49,4 @@
 
 AGDEPEND = Makefile.ag.depend
-DEPEND = Makefile.depend
-DEPEND_PREV = $(DEPEND).prev
 RAW = kernel.raw
 BIN = kernel.bin
@@ -67,12 +65,12 @@
 SIZEOK_MAP = generic/src/debug/sizeok_map.o
 
-.PHONY: all clean autogen_clean
+.PHONY: all clean autogen_clean depend
 
 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(BIN) $(DISASM)
-	-[ -f $(DEPEND) ] && cp -a $(DEPEND) $(DEPEND_PREV)
 
 clean: autogen_clean
-	rm -f $(DEPEND) $(DEPEND_PREV) $(RAW) $(BIN) $(MAP) $(JOB) $(MAP_PREV) $(DISASM) $(DUMP) $(REAL_MAP).* arch/*/_link.ld arch/*/include/arch/common.h
+	rm -f $(RAW) $(BIN) $(MAP) $(JOB) $(MAP_PREV) $(DISASM) $(DUMP) $(REAL_MAP).* arch/*/_link.ld arch/*/include/arch/common.h
 	find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.o' -follow -exec rm '{}' \;
+	find generic/src/ arch/*/src/ genarch/src/ test/ -name '*.d' -follow -exec rm '{}' \;
 
 ## Common compiler flags
@@ -129,5 +127,4 @@
 -include arch/$(KARCH)/Makefile.inc
 -include genarch/Makefile.inc
--include $(DEPEND)
 -include $(AGDEPEND)
 
@@ -152,28 +149,11 @@
 #
 
-ifeq ($(COMPILER),gcc_native)
-	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
-	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
-	INSTRUMENTATION = -finstrument-functions
-endif
-
-ifeq ($(COMPILER),gcc_cross)
-	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
-	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
-	INSTRUMENTATION = -finstrument-functions
-endif
-
-ifeq ($(COMPILER),gcc_helenos)
-	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
-	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
-	INSTRUMENTATION = -finstrument-functions
-endif
-
 ifeq ($(COMPILER),clang)
 	CFLAGS = $(COMMON_CFLAGS) $(CLANG_CFLAGS)
-	DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
-	INSTRUMENTATION = -finstrument-functions
-endif
-
+else
+	CFLAGS = $(COMMON_CFLAGS) $(GCC_CFLAGS)
+endif
+
+INSTRUMENTATION = -finstrument-functions
 
 ## Generic kernel sources
@@ -364,4 +344,8 @@
 GENARCH_OBJECTS := $(addsuffix .o,$(basename $(GENARCH_SOURCES)))
 
+GENERIC_DEPENDS := $(addsuffix .d,$(basename $(GENERIC_SOURCES)))
+ARCH_DEPENDS := $(addsuffix .d,$(basename $(ARCH_SOURCES)))
+GENARCH_DEPENDS := $(addsuffix .d,$(basename $(GENARCH_SOURCES)))
+
 GENARCH_AUTOGENS_H := $(addsuffix .h,$(basename $(GENARCH_AUTOGENS_AG)))
 GENARCH_AUTOGENS_PROBE_C := $(addsuffix .ag.probe.c,$(basename $(GENARCH_AUTOGENS_AG)))
@@ -378,4 +362,8 @@
 LD_CFLAGS := $(addprefix -Xlinker ,$(LFLAGS))
 
+-include $(GENERIC_DEPENDS)
+-include $(ARCH_DEPENDS)
+-include $(GENARCH_DEPENDS)
+
 ifeq ($(COMPILER),clang)
 	AS_CFLAGS += -mllvm -asm-macro-max-nesting-depth=1000
@@ -408,5 +396,5 @@
 endif
 
-$(LINK): $(LINK).in $(DEPEND)
+$(LINK): $(LINK).in | depend
 	$(CC) $(DEFS) $(CFLAGS) -D__ASM__ -D__LINKER__ -E -x c $< | grep -v "^\#" > $@
 
@@ -416,18 +404,18 @@
 	$(AUTOGEN) generate $< <$<.probe.s >$@   
 
-%.o: %.S $(DEPEND)
-	$(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c -o $@ $<
+%.o: %.S | depend
+	$(CC) -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c -o $@ $<
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) -D__ASM__
 endif
 
-%.o: %.s $(DEPEND)
-	$(CC) $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c -o $@ $<
+%.o: %.s | depend
+	$(CC) -MD $(DEFS) $(CFLAGS) $(AS_CFLAGS) -D__ASM__ -c -o $@ $<
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ as asm $(DEFS) $(CFLAGS) $(EXTRA_FLAGS)
 endif
 
-%.o: %.c $(DEPEND)
-	$(CC) $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) $(if $(findstring $<,$(INSTRUMENTED_SOURCES)),$(INSTRUMENTATION)) -c -o $@ $<
+%.o: %.c | depend
+	$(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS) $(if $(findstring $<,$(INSTRUMENTED_SOURCES)),$(INSTRUMENTATION)) -c -o $@ $<
 ifeq ($(PRECHECK),y)
 	$(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_FLAGS) $(FPU_NO_CFLAGS)
@@ -470,7 +458,5 @@
 	done
 
-$(DEPEND): $(COMMON_HEADER_ARCH) $(AUTOGENS_H)
-	makedepend -f - -- $(DEPEND_DEFS) $(CFLAGS) -- $(ARCH_SOURCES) $(GENARCH_SOURCES) $(GENERIC_SOURCES) > $@ 2> /dev/null
-	-[ -f $(DEPEND_PREV) ] && diff -q $(DEPEND_PREV) $@ && mv -f $(DEPEND_PREV) $@
+depend: $(COMMON_HEADER_ARCH) $(AUTOGENS_H)
 
 $(COMMON_HEADER_ARCH): $(COMMON_HEADER)
