2
0

Makefile 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. MAKEFLAGS += -R -r
  2. dstdir := $(shell pwd)
  3. export dstdir
  4. ARDUINO = $(PERL) $(realpath arduino-wrapper)
  5. ZIP = zip
  6. PERL = perl
  7. SKETCH = max80
  8. TARGET = output/$(SKETCH).ino.bin
  9. GENFILES = $(SKETCH)/data/www.zip
  10. WWW = www
  11. PORT ?= /dev/ttyACM0
  12. all: $(TARGET)
  13. common := ../common
  14. output/%.ino.bin: $(GENFILES)
  15. cd $(SKETCH) && $(ARDUINO) compile
  16. -include $(SKETCH).deps
  17. %.deps:
  18. if ! test -L '$*/src/common'; then \
  19. rm -rf '$*/src/common' 2>/dev/null ; \
  20. cd '$*/src' && ln -sf ../../$(common) . ; \
  21. fi
  22. ( echo -n 'output/$*.ino.bin: ' && \
  23. find -L '$*' -type f '(' -path '$*/data/*' \
  24. $(patsubst %,-o -name '*.%',ino c h S cpp hpp tpp ipp) \
  25. ')' -printf '\\\n\t%p ' && \
  26. echo '' ) > '$@'
  27. .PHONY: zip
  28. zip: zipexclude
  29. mkdir -p zip
  30. if ! cmp -q ../version.mk www/version 2>/dev/null; then \
  31. cp -f ../version.mk www/version; \
  32. fi
  33. cd www && \
  34. TZ=GMT0 \
  35. $(ZIP) -9DrpX -UN=UTF8 -FS ../zip/www.zip . -x@../zipexclude
  36. # Ugly hack but needed to avoid unnecessary rebuilds
  37. $(SKETCH)/data/www.zip: zip
  38. if [ ! -f $@ ] || [ zip/$(@F) -nt $@ ]; then \
  39. mkdir -p $(@D) ; \
  40. cp -f zip/$(@F) $@; \
  41. rm -f build/sketch/www.c build/sketch/www.c.*; \
  42. fi
  43. upload: $(TARGET)
  44. cd $(SKETCH) && $(ARDUINO) upload -p $(PORT) $(SKETCH)
  45. clean:
  46. rm -rf build cache zip www.zip *.deps $(GENFILES) \
  47. $(SKETCH)/src/common
  48. spotless: clean
  49. rm -rf arduino output