+# Automatic dependency generation: makes ccan/*.d files.
+DEPGEN=-MD
+-include ccan/*/*.d
+
+# Every directory with .c files (other than _info.c) is included.
+DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/[a-z]*.c))))
+
+# We compile all the ccan/foo/*.o files together into ccan/foo.o
+OBJFILES=$(DIRS:=.o)