diff options
author | Andrew Cady <d@jerkface.net> | 2021-10-12 05:55:31 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2021-10-12 05:55:31 -0400 |
commit | 3626ad2442bb38fda9fa28492f7f1a3e861fcbd2 (patch) | |
tree | 6ff49c7c154340af24299ae440a8e677de19b929 | |
parent | 9c8af9adc9a60c8ff5487232656c4e3ec603721c (diff) |
improve Makefile
-rw-r--r-- | Makefile | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -29,6 +29,7 @@ FQBN = $(CORE):espmxdevkit | |||
29 | MDNS_NAME = $(PROGNAME) | 29 | MDNS_NAME = $(PROGNAME) |
30 | OTA_PORT = 8266 | 30 | OTA_PORT = 8266 |
31 | OTA_PASS = | 31 | OTA_PASS = |
32 | SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) | ||
32 | 33 | ||
33 | .DEFAULT_GOAL = all | 34 | .DEFAULT_GOAL = all |
34 | 35 | ||
@@ -39,33 +40,43 @@ init: | |||
39 | arduino-cli core install $(CORE) | 40 | arduino-cli core install $(CORE) |
40 | arduino-cli lib update-index | 41 | arduino-cli lib update-index |
41 | arduino-cli lib install 'DHT sensor library' | 42 | arduino-cli lib install 'DHT sensor library' |
43 | $(cli) compile --show-properties > $@ | ||
42 | 44 | ||
43 | SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) | 45 | cli = arduino-cli -b "$(FQBN)" |
44 | 46 | ||
45 | ifneq (,$(wildcard init)) | 47 | ifeq (,$(wildcard init)) |
46 | BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p' | 48 | ifneq ($(MAKECMDGOALS),init) |
47 | PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p' | 49 | $(error please run make init) |
48 | PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p' | 50 | endif |
51 | else | ||
52 | BUILD_DIR != sed -ne 's/^build.path=//p' < init | ||
53 | PLAT_PATH != sed -ne 's/^runtime.platform.path=//p' < init | ||
54 | PY_PATH != sed -ne 's/^runtime.tools.python3.path=//p' < init | ||
55 | endif | ||
56 | ifneq (,$(filter ota, $(MAKECMDGOALS))) | ||
49 | MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) | 57 | MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) |
50 | endif | 58 | endif |
51 | 59 | ||
52 | cli = arduino-cli -b "$(FQBN)" | ||
53 | |||
54 | SRC := CCS811.cpp $(PROGNAME).ino | 60 | SRC := CCS811.cpp $(PROGNAME).ino |
55 | HDRS := CCS811.h ota.h wifiinfo.h | 61 | HDRS := CCS811.h ota.h wifiinfo.h |
56 | BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin | 62 | BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin |
57 | ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf | 63 | ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf |
58 | 64 | ||
59 | all: $(ELF) | ||
60 | .PHONY: all | 65 | .PHONY: all |
66 | all: $(ELF) | ||
67 | @ls -l $(ELF) | ||
61 | 68 | ||
62 | compile: $(ELF) | 69 | compile: $(ELF) |
63 | .PHONY: compile | 70 | .PHONY: compile |
64 | 71 | ||
72 | build_flags = | ||
73 | |||
65 | $(BIN) $(ELF): $(SRC) $(HDRS) | 74 | $(BIN) $(ELF): $(SRC) $(HDRS) |
66 | $(cli) compile --warnings all | 75 | $(cli) compile $() $(addprefix --build-property build.extra_flags=,$(build_flags)) --warnings all |
76 | |||
67 | 77 | ||
68 | upload: $(ELF) | 78 | upload: $(ELF) |
79 | [ -w "$(SERIAL_DEV)" ] || sudo chmod 666 "$(SERIAL_DEV)" | ||
69 | $(cli) upload -p "$(SERIAL_DEV)" | 80 | $(cli) upload -p "$(SERIAL_DEV)" |
70 | 81 | ||
71 | ota: $(BIN) | 82 | ota: $(BIN) |