Makefile 1.5 KB

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