Makefile 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 $(SKETCH)/sysvars_gen.c $(SKETCH)/sysvars_gen.h
  8. WWW = www
  9. PORT ?= /dev/ttyACM0
  10. build_defines = -DBOARD_HAS_PSRAM -I$(realpath ../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=1' \
  22. --build-property 'build.partitions=min_spiffs'
  23. all: $(TARGET)
  24. properties:
  25. cd $(SKETCH) && \
  26. $(ARDUINO_CLI) compile --show-properties $(ARDUINO_OPTS)
  27. $(TARGET): $(shell find $(SKETCH) -type f) $(GENFILES)
  28. mkdir -p build output cache
  29. cd $(SKETCH) && \
  30. $(ARDUINO_CLI) compile $(ARDUINO_OPTS)
  31. $(SKETCH)/%_gen.c $(SKETCH)/%_gen.h: %.vars sysvars.pl
  32. $(PERL) sysvars.pl $< $(SKETCH)/$*_gen.h $(SKETCH)/$*_gen.c
  33. .PHONY: zip
  34. zip: zipexclude
  35. mkdir -p zip
  36. if ! cmp -q ../version.mk www/version 2>/dev/null; then \
  37. cp -f ../version.mk www/version; \
  38. fi
  39. cd www && \
  40. TZ=GMT0 \
  41. $(ZIP) -9DrpX -UN=UTF8 -FS ../zip/www.zip . -x@../zipexclude
  42. # Ugly hack but needed to avoid unnecessary rebuilds
  43. www.zip: zip
  44. if [ ! -f $@ ] || [ zip/$@ -nt $@ ]; then \
  45. cp -f zip/$@ $@; \
  46. rm -f build/sketch/www.c build/sketch/www.c.*; \
  47. fi
  48. upload: $(TARGET)
  49. $(ARDUINO_CLI) upload -i $(TARGET) -p $(PORT) -b $(BOARD) $(SKETCH)
  50. clean:
  51. rm -rf build cache zip $(GENFILES)
  52. spotless: clean
  53. rm -rf output