diff --git a/make.mk b/make.mk index 0792e64f..25401642 100644 --- a/make.mk +++ b/make.mk @@ -159,6 +159,7 @@ else CFLAGS += -W -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations CFLAGS += -Wno-format -Wno-unused-parameter +CFLAGS += -MD -MP -MT $(BUILD)/$(*F).o -MF $(BUILD)/$(@F).d INCLUDES += \ -I$(TOP)/boards/$(BOARD) \ diff --git a/rules.mk b/rules.mk index 8de3fc1e..2c4acec1 100644 --- a/rules.mk +++ b/rules.mk @@ -1,3 +1,5 @@ +.SUFFIXES: + CFLAGS += $(INCLUDES) $(DEFINES) OBJS = $(addprefix $(BUILD)/, $(notdir %/$(subst .c,.o, $(SRCS)))) @@ -60,6 +62,6 @@ clean: analyze: @$(COBRA) basic $(INCLUDES) $(DEFINES) $(SRCS) -DEPFILES := $(SRCS:%.c=$(BUILD)/%.d) +DEPFILES := $(OBJS:%.o=%.o.d) -include $(wildcard $(DEPFILES))