compute dependencies automatically

getting serious...

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/Makefile b/Makefile
index 4e41822..4149ef7 100644
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,11 @@
 obj-y += linuxboot.o
 
 all-y = bios.bin
+all: $(all-y)
 
-CFLAGS := -O2 -Wall -g
+CFLAGS := -O2 -g
 
+BIOS_CFLAGS += $(autodepend-flags) -Wall
 BIOS_CFLAGS += -m32
 BIOS_CFLAGS += -march=i386
 BIOS_CFLAGS += -mregparm=3
@@ -14,7 +16,9 @@
 BIOS_CFLAGS += -Iinclude
 $(obj16-y): BIOS_CFLAGS += -include code16gcc.h
 
-all: $(all-y)
+dummy := $(shell mkdir -p .deps)
+autodepend-flags = -MMD -MF .deps/cc-$(patsubst %/,%,$(dir $*))-$(notdir $*).d
+-include .deps/*.d
 
 .PRECIOUS: %.o
 %.o: %.c
@@ -30,3 +34,4 @@
 
 clean:
 	rm -f $(obj-y) $(all-y) bios.bin.elf
+	rm -rf .deps