В общем есть такой makefile
PROG := awesome-prog
SOURCES := $(wildcard *.c)
OBJECTS := $(patsubst %c,%o,$(SOURCES))
DEPFILES := $(patsubst %.c,%.d,$(SOURCES))
$(PROG): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $^
%.o: %.d
%.d: %.c
$(CC) $(CFLAGS) -MM -MT '$(patsubst %.c,%.o,$<)' $< -MF $@
ifeq (0, $(words $(findstring $(MAKECMDGOALS), clean print_vars cleanall)))
include $(DEPFILES)
endif
.PHONY: all
all:
$(MAKE) $(PROG)