Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. override LDFLAGS += -L../out/ -L../lib/
  6. override LDFLAGS += $(shell cat .ldflags 2> /dev/null | xargs)
  7. override LDARCH += $(shell cat .ldarch 2> /dev/null | xargs)
  8. ifeq ($(strip $(LDARCH)),)
  9. override LDLIBS += -lsimple_sdlcore
  10. else
  11. override LDLIBS += $(LDARCH)
  12. endif
  13. override LDLIBS += -lsimple_interactive -lSDL2
  14. TEMPDIR := temp
  15. DISTDIR := out
  16. SOURCES := $(shell echo *.cpp)
  17. TARGETS := $(SOURCES:%.cpp=$(DISTDIR)/%)
  18. OBJECTS := $(SOURCES:%.cpp=$(TEMPDIR)/%.o)
  19. DEPENDS := $(OBJECTS:.o=.d)
  20. build: make_parent $(TARGETS)
  21. make_parent:
  22. make -C ..
  23. $(DISTDIR)/%: $(TEMPDIR)/%.o ../out/libsimple_interactive.a $(LDARCH) | $(DISTDIR)
  24. $(CXX) $(LDFLAGS) $< $(LDLIBS) -o $@
  25. $(TEMPDIR)/%.o: %.cpp | $(TEMPDIR)
  26. $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
  27. $(TEMPDIR):
  28. @mkdir $@
  29. $(DISTDIR):
  30. @mkdir $@
  31. clean:
  32. @rm $(DEPENDS) 2> /dev/null || true
  33. @rm $(OBJECTS) 2> /dev/null || true
  34. @rmdir $(TEMPDIR) 2> /dev/null || true
  35. @echo Temporaries cleaned!
  36. distclean: clean
  37. @rm $(TARGETS) 2> /dev/null || true
  38. @rmdir $(DISTDIR) 2> /dev/null || true
  39. @echo All clean!
  40. -include $(DEPENDS)
  41. .PRECIOUS : $(OBJECTS)
  42. .PHONY : clean distclean make_parent