diff --git a/Makefile b/Makefile
index 1c68273f991b37f40ca4eed8fde3f13d9040f53e..1f0c886f728804335762457e49e9556cffcdae0d 100644
--- a/Makefile
+++ b/Makefile
@@ -54,17 +54,14 @@ endif
 
 OBJS = ffmpeg.o ffserver.o
 SRCS = $(OBJS:.o=.c) $(ASM_OBJS:.o=.s)
-DEPS = $(OBJS:.o=.d)
 
 all: lib $(PROG) $(VHOOK)
 
--include $(DEPS)
-
 lib:
 	$(MAKE) -C libavcodec all
 	$(MAKE) -C libavformat all
 
-ffmpeg_g$(EXE): ffmpeg.o $(DEP_LIBS)
+ffmpeg_g$(EXE): .depend ffmpeg.o $(DEP_LIBS)
 	$(CC) $(LDFLAGS) -o $@ ffmpeg.o -L./libavcodec -L./libavformat \
               -lavformat -lavcodec $(EXTRALIBS)
 
@@ -83,10 +80,6 @@ ffplay: ffmpeg$(EXE)
 %.o: %.c
 	$(CC) $(CFLAGS) -c -o $@ $< 
 
-%.d: %.c
-	@echo $@ \\ > $@
-	$(CC) $(CFLAGS) -MM $< >> $@
-
 videohook:
 	$(MAKE) -C vhook all
 
@@ -108,8 +101,10 @@ installlib:
 
 dep:	depend
 
-depend:
-	$(CC) -MM $(CFLAGS) $(SRCS) 1>.depend
+depend: .depend
+
+.depend: $(SRCS)
+	$(CC) -MM $(CFLAGS) $^ 1>.depend
 
 clean: $(CLEANVHOOK)
 	$(MAKE) -C libavcodec clean
diff --git a/vhook/Makefile b/vhook/Makefile
index a3566821e5ef7595ad7bdf6f7a4b8ea61fc3a586..0f49299e3ced6194a14a253fa52919ad814412c2 100644
--- a/vhook/Makefile
+++ b/vhook/Makefile
@@ -30,7 +30,7 @@ imlib2.so: imlib2.o
 	$(CC) -g -o $@ $(SHFLAGS) $<
 
 clean:
-	rm -f *.o *.d *.so *~
+	rm -f *.o *.d .depend *.so *~
 
 ifneq ($(wildcard .depend),)
 include .depend