diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..481382a --- /dev/null +++ b/Makefile | |||
@@ -0,0 +1,60 @@ | |||
1 | # Optionally some environment variables can be set: | ||
2 | # | ||
3 | # FQBN Fully Qualified Board Name; if not set in the environment | ||
4 | # it will be assigned a value in this makefile | ||
5 | # | ||
6 | # SERIAL_DEV Serial device to upload the sketch; if not set in the | ||
7 | # environment it will be assigned: | ||
8 | # /dev/ttyUSB0 if it exists, or | ||
9 | # /dev/ttyACM0 if it exists, or | ||
10 | # unknown | ||
11 | # | ||
12 | # MDNS_NAME Hostname of the Arduino; if not set in the environment | ||
13 | # it will be assigned a value in this makefile. This is | ||
14 | # needed for OTA update, the device will be searched | ||
15 | # on the local subnet using this name | ||
16 | # | ||
17 | # OTA_PORT Port used by OTA update; if not set in the environment | ||
18 | # it will be assigned the default value of 8266 in this | ||
19 | # makefile | ||
20 | # | ||
21 | # OTA_PASS Password used for OTA update; if not set in the environment | ||
22 | # it will be assigned the default value of an empty string | ||
23 | |||
24 | PROGNAME = mush | ||
25 | |||
26 | FQBN = esp8266:esp8266:espmxdevkit | ||
27 | MDNS_NAME = $(PROGNAME) | ||
28 | OTA_PORT = 8266 | ||
29 | OTA_PASS = | ||
30 | |||
31 | SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) | ||
32 | |||
33 | cli = arduino-cli -b "$(FQBN)" | ||
34 | |||
35 | BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p' | ||
36 | |||
37 | SRC := CCS811.cpp $(PROGNAME).ino | ||
38 | HDRS := CCS811.h ota.h wifiinfo.h | ||
39 | BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin | ||
40 | ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf | ||
41 | |||
42 | all: $(ELF) | ||
43 | .PHONY: all | ||
44 | |||
45 | compile: $(ELF) | ||
46 | .PHONY: compile | ||
47 | |||
48 | $(BIN) $(ELF): $(SRC) $(HDRS) | ||
49 | $(cli) compile --warnings all | ||
50 | |||
51 | upload: | ||
52 | $(cli) upload -p "$(SERIAL_DEV)" | ||
53 | |||
54 | PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p' | ||
55 | PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p' | ||
56 | MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) | ||
57 | |||
58 | ota: $(BIN) | ||
59 | "$(PY_PATH)/python3" "$(PLAT_PATH)/tools/espota.py" -i "$(MDNS_IP)" -p "$(OTA_PORT)" --auth="$(OTA_PASS)" -f "$(BIN)" | ||
60 | |||