Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. MAKEFLAGS += -R -r
  2. ARDUINO_CLI = arduino-cli
  3. ZIP = zip
  4. PERL = perl
  5. SKETCH = max80
  6. TARGET = output/$(SKETCH).ino.bin
  7. fromcommon := $(patsubst ../common/%,$(SKETCH)/src/common/%,$(wildcard ../common/*.[ch]))
  8. GENFILES = www.zip
  9. WWW = www
  10. PORT ?= /dev/ttyACM0
  11. build_defines = -DBOARD_HAS_PSRAM -I. -Isrc/common
  12. BOARD = esp32:esp32:esp32s2usb
  13. ARDUINO_OPTS = -b $(BOARD) \
  14. --warnings all \
  15. --build-path ../build \
  16. --output-dir ../output \
  17. --build-cache-path ../cache \
  18. --build-property 'build.flash_size=4MB' \
  19. --build-property 'build.defines=$(build_defines)' \
  20. --build-property 'build.cdc_on_boot=1' \
  21. --build-property 'build.msc_on_boot=0' \
  22. --build-property 'build.dfu_on_boot=0' \
  23. --build-property 'build.partitions=min_spiffs'
  24. all: $(TARGET)
  25. properties:
  26. cd $(SKETCH) && \
  27. $(ARDUINO_CLI) compile --show-properties $(ARDUINO_OPTS)
  28. $(TARGET): $(shell find $(SKETCH) -type f) $(GENFILES) $(fromcommon)
  29. mkdir -p build output cache
  30. cd $(SKETCH) && \
  31. $(ARDUINO_CLI) compile $(ARDUINO_OPTS)
  32. common_dir:
  33. mkdir -p $(SKETCH)/src/common
  34. $(SKETCH)/src/common/%: ../common/% | common_dir
  35. cp -f $< $@
  36. .PHONY: zip
  37. zip: zipexclude
  38. mkdir -p zip
  39. if ! cmp -q ../version.mk www/version 2>/dev/null; then \
  40. cp -f ../version.mk www/version; \
  41. fi
  42. cd www && \
  43. TZ=GMT0 \
  44. $(ZIP) -9DrpX -UN=UTF8 -FS ../zip/www.zip . -x@../zipexclude
  45. # Ugly hack but needed to avoid unnecessary rebuilds
  46. www.zip: zip
  47. if [ ! -f $@ ] || [ zip/$@ -nt $@ ]; then \
  48. cp -f zip/$@ $@; \
  49. rm -f build/sketch/www.c build/sketch/www.c.*; \
  50. fi
  51. upload: $(TARGET)
  52. $(ARDUINO_CLI) upload -i $(TARGET) -p $(PORT) -b $(BOARD) $(SKETCH)
  53. clean:
  54. rm -rf build cache zip $(GENFILES) $(SKETCH)/src/common
  55. spotless: clean
  56. rm -rf output