Makefile 1.6 KB

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