Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. PYS :=
  2. BOOTPY := boot.py
  3. MAINPY := main.py
  4. MAINPYDIR :=
  5. GSDS :=
  6. CONFS :=
  7. SRCDIR :=
  8. BUILDDIR :=
  9. MARCH := xtensawin
  10. MPYCROSS_OPTS := -O0
  11. GSDPARSER_OPTS := --dump-strip --dump-notext --dump-noextuserprmdata
  12. MPYCROSS := mpy-cross
  13. GSDPARSER := $(SRCDIR)/gsdparser
  14. MKDIR := mkdir
  15. CP := cp
  16. RM := rm
  17. _MPYS = $(sort $(patsubst %.py,$(2)/%.mpy,$(1)))
  18. _GSDMPYS = $(sort $(patsubst %.gsd,$(2)/%_gsd.mpy,$(1)))
  19. _GSDPYS = $(sort $(patsubst %.gsd,$(2)/%_gsd.py,$(1)))
  20. _CONFS = $(sort $(patsubst %.conf,$(2)/%.conf,$(1)))
  21. _MPYCROSS = $(MPYCROSS) "$(1)" -s "$(2)" -march="$(MARCH)" $(MPYCROSS_OPTS) -o "$(3)"
  22. all: $(call _MPYS,$(PYS),$(BUILDDIR)) \
  23. $(call _GSDMPYS,$(GSDS),$(BUILDDIR)) \
  24. $(call _CONFS,$(CONFS),$(BUILDDIR)) \
  25. $(BUILDDIR)/$(BOOTPY) \
  26. $(BUILDDIR)/$(MAINPY)
  27. $(BUILDDIR)/%.mpy: %.py
  28. @$(MKDIR) -p "$(dir $@)"
  29. $(call _MPYCROSS,$<,$(shell basename "$<"),$@)
  30. $(BUILDDIR)/%_gsd.mpy: %.gsd
  31. @$(MKDIR) -p "$(dir $@)"
  32. $(GSDPARSER) -D $(GSDPARSER_OPTS) -o "$(call _GSDPYS,$<,$(BUILDDIR))" "$<"
  33. $(call _MPYCROSS,$(call _GSDPYS,$<,$(BUILDDIR)),$(shell basename "$(call _GSDPYS,$<,$(BUILDDIR))"),$@)
  34. $(RM) "$(call _GSDPYS,$<,$(BUILDDIR))"
  35. $(BUILDDIR)/%.conf: %.conf
  36. @$(MKDIR) -p "$(dir $@)"
  37. $(CP) "$<" "$@"
  38. $(BUILDDIR)/$(BOOTPY) $(BUILDDIR)/$(MAINPY): $(BUILDDIR)/%.py: $(MAINPYDIR)/%.py
  39. @$(MKDIR) -p "$(dir $@)"
  40. $(CP) "$<" "$@"
  41. clean:
  42. $(RM) -rf $(BUILDDIR)
  43. .PHONY: all clean