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