-# By including this file, we cause GNU make to automatically "make depend"
-# if it can't find it or it is out of date.
-include depend
+clean:
+ -rm -f *.[do] $(TARGET) sbcl.nm sbcl.h core *.tmp $(OS_CLEAN_FILES)
+
+%.d: %.c sbcl.h
+ @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+ rm -f $@.tmp
+
+%.d: %.S sbcl.h
+ @$(CC) $(DEPEND_FLAGS) $(CPPFLAGS) $< > $@.tmp; \
+ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.tmp > $@; \
+ rm -f $@.tmp
+
+# By including those files, we cause GNU make to automatically re-make
+# all dependencies of the .c file if necessary.
+ifneq ($(MAKECMDGOALS),clean)
+-include $(C_SRC:.c=.d) $(ASSEM_SRC:.S=.d)
+endif