To compile individual files you have to either write an individual rule for each object, or use a generic rule as
%.o: %.c
$(CC) $(CFLAGS) -o $@ $< (refer toautomatic variables chapter in info make for the meaning of @ and <). Put this rule in place of lines 10-11.
Also be advised that your makefile does not know that main is really a target, so it would rebuild main each time, even if nothing changed. Replace all at line 7 with main.
Another recommendation is to explicitly list the source files at line 3. If you really really want make to figure that list out, use $(wildcard *.c).
Finally, you need to spell out the objfiles dependencies on .h headers (otherwise the project wouldn't rebuild on a header modification). Add a generic rule:
%.d: %.c
$(CC) %(CFLAGS) -MM -o $@ $< a definition of generated .d fragments:
DEPS := $(CFILES:%.c=%.d) and include them all:
-include $(DEPS) After that you are pretty much set. There is still a room to perfect it.