2
0

Makefile 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. MAKEFLAGS += -R -r
  2. PROJECT := max80
  3. SUBDIRS := esp32 tools rv32 fpga
  4. REVISIONS := v1 v2 bypass
  5. GIT_DIR ?= .git
  6. all clean spotless :
  7. $(MAKE) local.$@ $(SUBDIRS) goal=$@
  8. prefpga:
  9. $(MAKE) local.all $(filter-out fpga,$(SUBDIRS)) goal=all
  10. $(REVISIONS): prefpga
  11. $(MAKE) -C fpga $@
  12. .PHONY: $(SUBDIRS)
  13. $(SUBDIRS):
  14. $(MAKE) -C $@ $(goal)
  15. .PHONY: version.mk
  16. version.mk:
  17. if [ -d '$(GIT_DIR)' ]; then \
  18. TZ=UTC0 git log -n 1 --date=local --abbrev=8 \
  19. --pretty='format:COMMIT_VERSION=$(PROJECT)-%(describe:abbrev=6)%nCOMMIT_ID=%H%nCOMMIT_MAGIC=%h%nCOMMIT_DATE=%cd UTC%n' > $@.tmp ; \
  20. if cmp -q '$@' '$@.tmp' 2>/dev/null; then \
  21. rm -f $@.tmp; else mv -f $@.tmp $@; fi \
  22. fi
  23. version.%: version.mk version.%.sed
  24. sed -f $@.sed $< > $@
  25. $(SUBDIRS): version.mk
  26. esp32: version.h
  27. rv32: version.h | tools
  28. fpga: version.vh | rv32 esp32
  29. local.all:
  30. local.clean:
  31. rm -f *~ ./\#* \# *.bak *.tmp
  32. local.spotless: local.clean
  33. rm -f version.h version.vh
  34. if [ -d .git ]; then rm -f version.mk; fi
  35. # Obsolete target, need version
  36. program flash:
  37. @echo 'Please specify one of: $(foreach rev,$(REVISIONS),$@-$(rev))' 1>&2
  38. @false
  39. # FPGA-specific targets
  40. program-% flash-%: prefpga
  41. $(MAKE) -C fpga $@
  42. # ESP update by USB or serial port
  43. upload-esp:
  44. $(MAKE) -C esp32 upload
  45. # Update via HTTP
  46. ip=max80
  47. upload-%:
  48. curl -v --data-binary @fpga/output/$*.fw http://$(ip)/sys/fwupdate