Makefile 972 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. override CPPFLAGS += --std=c++1z
  2. override CPPFLAGS += -MMD -MP
  3. override CPPFLAGS += -I../source -I../include
  4. override CPPFLAGS += $(shell cat ../.cxxflags 2> /dev/null | xargs )
  5. SOURCES := $(shell echo *.cpp)
  6. TARGETS := $(SOURCES:%.cpp=%.test)
  7. TEMPDIR := temp
  8. OBJECTS := $(SOURCES:%.cpp=$(TEMPDIR)/%.o)
  9. DEPENDS := $(OBJECTS:.o=.d)
  10. RUNS := $(OBJECTS:.o=.run)
  11. run: $(RUNS)
  12. build: $(TARGETS)
  13. $(TEMPDIR)/%.run: %.test
  14. ./$<
  15. @echo "This is a dummy file for make to keep track of test runs" > $@
  16. %.test: $(TEMPDIR)/%.o
  17. $(CXX) $(LDFLAGS) $< $(LDLIBS) -o $@
  18. $(TEMPDIR)/%.o: %.cpp | $(TEMPDIR)
  19. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
  20. $(TEMPDIR):
  21. @mkdir $@
  22. cleanrun:
  23. @rm $(RUNS) 2> /dev/null || true
  24. clean: cleanrun
  25. @rm $(DEPENDS) 2> /dev/null || true
  26. @rm $(OBJECTS) 2> /dev/null || true
  27. @rmdir $(TEMPDIR) 2> /dev/null || true
  28. @rm $(TARGETS) 2> /dev/null || true
  29. @echo All clean!
  30. -include $(DEPENDS)
  31. .PRECIOUS : $(OBJECTS) $(TARGETS)
  32. .PHONY : clean cleanrun