include project.mk all: $(PROGRAM) INCPATH += $(patsubst %,-I%,$(MODULES)) CFLAGS += -pipe $(LIBPATH) $(INCPATH) # Include module descriptions include $(patsubst %,%/module.mk,$(MODULES)) # Determine object and dependency files OBJ := $(patsubst %.c,%.o,$(filter %.c,$(SRC))) DEP := $(patsubst %.c,%.d,$(filter %.c,$(SRC))) # Link the program $(PROGRAM): $(OBJ) $(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBS) # Generate object and dependency files from source %.d %.o: %.c $(CC) $(CFLAGS) -MMD -c -o $(patsubst %.d,%.o,$@) $< # Include dependencies -include $(DEP) # Remove generated files clean: -rm -f core $(PROGRAM) $(OBJ) $(DEP) # Run the exectable run: all ./$(PROGRAM) # Tell make about special (non-file) targets .DEFAULT: all .PHONY: all clean run