BASEDIR := ./ BINEXT := OBJEXT := .o LIBEXT := .a CXX := g++ CXXFLAGS := LDFLAGS := CURDIR := $(shell pwd) # each module will add to this, .os are derived from it TARGETLIBS := TARGETBINS := LIBS := LIBSRC := SRC := all: targets include alg/module.mk include alg/test/module.mk include gui/module.mk include module.mk # process what the module.mks defined OBJ := $(patsubst %.cxx,%.o, $(filter %.cxx,$(SRC))) DEPS := $(OBJ:.o=.d) targets: $(TARGETLIBS) $(TARGETBINS) # this make function came from # http://www.oreilly.com/catalog/make3/book/ch08.pdf # $(call make-depend,source-file,object-file,depend-file) define make-depend $(CXX) -MM -MF $3 -MP -MT $2 $(CFLAGS) $(CXXFLAGS) $1 endef %.d: %.cxx $(call make-depend,$<,$@,$(subst .o,.d,$@)) # makedepend -o.d $(dirname $^) $(CFLAGS) $(CXXFILAGS) $^ -f- > $@ %.o: %.cxx $(CXX) -c -o $@ $(CXXFLAGS) $^ include $(DEPS) clean: -rm $(OBJ) $(DEPS) $(TARGETLIBS) $(TARGETBINS)