TARGET=diffusion
CXXFLAGS=-Wall -O2 -DLINUX
LOADLIBES=-lGL -lGLU -lglut

-include Makefile.d

$(TARGET) : $(SRCOBJS)
	g++ $+ -o $@ $(LOADLIBES)

run : $(TARGET)
	./$(TARGET)

rebuild: clean $(TARGET)

.PHONY : clean
clean:
	rm -f ./*.o
	rm -f ./*.d
	rm -f ./*~
	rm -f ./$(TARGET)

# Dependencies of the executable
Makefile.d:
	@echo -n SRCOBJS= > $@
	@ls *.cpp | sed 's/\(.*\.\)c\(pp\)\?/\1o \\/' >> $@


# Dependencies of the source files
%.d : %.cpp
	@g++ $(CXXFLAGS) -c $< -MM | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@;

-include $(SRCOBJS:.o=.d)
