LOCAL_PATH = ..

include $(LOCAL_PATH)/Local.mak

DEFINES +=
CXXFLAGS += 
INCLUDES += 
LDFLAGS += 
ENDING = cpp

SOURCES := $(wildcard *.$(ENDING)) 
DEPFILES := $(wildcard .depend.*.$(ENDING))
OFILES := $(patsubst %.$(ENDING), %.o, $(SOURCES))

GOALS = libplatypus.a 
SUBDIRS = cores local types smodels builder factories algorithm

ifeq ($(BUILD_FORK), yes)
	SUBDIRS += fork
endif

%.o: %.$(ENDING)
	rm -f $(patsubst %.$(ENDING), .depend.%.$(ENDING), $<)
	make $(patsubst %.$(ENDING), .depend.%.$(ENDING), $<)
	$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -c $< -o $@

.depend.%.$(ENDING): %.$(ENDING)
	$(CXX) -MM $(CXXFLAGS) $(DEFINES) $(INCLUDES) $< > $@


all: $(GOALS)

.PHONY: subdirs $(SUBDIRS) clean

subdirs: $(SUBDIRS)

$(SUBDIRS):
	$(MAKE) -C $@


libplatypus.a: subdirs $(OFILES)
	ar cvrs  $(LOCAL_PATH)/lib/$@ *.o

clean:
	$(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) clean;)
	rm -f *.o *~ *.core $(GOALS) *.a .depend.*

include $(DEPFILES)







