# -*- makefile -*-

DEP_DIR := .deps

DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d

MAKEDEPEND = $(CPP) $(DEPFLAGS) $(CPPFLAGS) $< \
             | sed -n 's,^\# *[0-9][0-9]* *"\([^"<]*\)".*,$@: \1\n\1:,p' \
             | sort -u > $*.d


%.d : %.c $(DEP_DIR)/%.d | $(DEPDIR)
	@$(MAKEDEPEND)

$(DEP_DIR): ; @mkdir -p $@

DEPFILES := $(SRC_FILES:%.c=$(DEP_DIR)/%.d)

$(DEPFILES):

include $(wildcard $(DEPFILES))
