Makefile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. MAKEFLAGS += -R -r
  2. ARDUINO_CLI = arduino-cli
  3. ZIP = zip
  4. SKETCH = max80
  5. TARGET = output/$(SKETCH).ino.bin
  6. GENFILES = www.zip
  7. WWW = www
  8. PORT ?= /dev/ttyACM2
  9. BOARD = esp32:esp32:esp32s2usb
  10. ARDUINO_OPTS = -b $(BOARD) \
  11. --warnings all \
  12. --build-path ../build \
  13. --output-dir ../output \
  14. --build-cache-path ../cache \
  15. --build-property 'build.flash_size=4MB' \
  16. --build-property 'build.defines=-DBOARD_HAS_PSRAM' \
  17. --build-property 'build.partitions=min_spiffs'
  18. all: $(TARGET)
  19. properties:
  20. cd $(SKETCH) && \
  21. $(ARDUINO_CLI) compile --show-properties $(ARDUINO_OPTS)
  22. $(TARGET): $(shell find $(SKETCH) -type f) $(GENFILES)
  23. mkdir -p build output cache
  24. cd $(SKETCH) && \
  25. $(ARDUINO_CLI) compile $(ARDUINO_OPTS)
  26. .PHONY: zip
  27. zip:
  28. mkdir -p zip
  29. cd www && \
  30. TZ=GMT0 \
  31. $(ZIP) -9DrpX -FS ../zip/www.zip . \
  32. -x '.*' -x '#*' -x '*~' -x '*.bak'
  33. # Ugly hack but needed to avoid unnecessary rebuilds
  34. www.zip: zip
  35. if [ ! -f $@ ] || [ zip/$@ -nt $@ ]; then \
  36. cp -f zip/$@ $@; \
  37. rm -f build/sketch/www.c build/sketch/www.c.*; \
  38. fi
  39. upload: $(TARGET)
  40. $(ARDUINO_CLI) upload -i $(TARGET) -p $(PORT) -b $(BOARD) $(SKETCH)
  41. clean:
  42. rm -rf build cache zip $(GENFILES)
  43. spotless: clean
  44. rm -rf output