PROGRAM := prog DEBUGFLAGS := MODULES := mage libeast all: libeast/libeast $(PROGRAM) libeast/libeast: ln -s . libeast/libeast INCPATH := $(patsubst %,-I%,$(MODULES)) # Reset cflags CFLAGS := CPPFLAGS := $(INCPATH) CXXFLAGS := $(DEBUGFLAGS) # Extra libraries LIBS := -lstdc++ # Source files; modules add to this, of course SRC := # Include module descriptions include $(patsubst %,%/module.mk,$(MODULES)) # Determine the object files OBJ := $(patsubst %.cc,%.o,$(filter %.cc,$(SRC))) # Link the program $(PROGRAM): $(OBJ) $(CXX) -o $@ $(OBJ) $(LIBS) # Calculate include dependencies %.d: %.cc ./depend.sh $(CPPFLAGS) $< > $@ # Include C include dependencies DEP := $(patsubst %.cc,%.d,$(filter %.cc,$(SRC))) include $(DEP) # Remove generated files clean: -rm -f core $(PROGRAM) $(OBJ) distclean: clean -rm -f $(DEP) # Run the program run: $(PROGRAM) ./$(PROGRAM) # Tell make about special (non-file) targets .DEFAULT: all .PHONY: all clean distclean run