TARGET=raytracing.a
CXXFLAGS=-O2 -Wall -DLINUX -I..

-include Makefile.d

$(TARGET) : $(SRCOBJS)
	ar -rc $@ $+

rebuild: clean $(TARGET)

.PHONY : clean
clean:
	find ./ \( -name '*.o' -o -name '*.d' -o -name '*~' \) | xargs rm -f
	rm -f $(TARGET)


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


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

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