summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 20 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 507f95d..7043b20 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,7 @@ FQBN = $(CORE):espmxdevkit
29MDNS_NAME = $(PROGNAME) 29MDNS_NAME = $(PROGNAME)
30OTA_PORT = 8266 30OTA_PORT = 8266
31OTA_PASS = 31OTA_PASS =
32SERIAL_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
43SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) 45cli = arduino-cli -b "$(FQBN)"
44 46
45ifneq (,$(wildcard init)) 47ifeq (,$(wildcard init))
46BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p' 48ifneq ($(MAKECMDGOALS),init)
47PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p' 49$(error please run make init)
48PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p' 50endif
51else
52BUILD_DIR != sed -ne 's/^build.path=//p' < init
53PLAT_PATH != sed -ne 's/^runtime.platform.path=//p' < init
54PY_PATH != sed -ne 's/^runtime.tools.python3.path=//p' < init
55endif
56ifneq (,$(filter ota, $(MAKECMDGOALS)))
49MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) 57MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip)
50endif 58endif
51 59
52cli = arduino-cli -b "$(FQBN)"
53
54SRC := CCS811.cpp $(PROGNAME).ino 60SRC := CCS811.cpp $(PROGNAME).ino
55HDRS := CCS811.h ota.h wifiinfo.h 61HDRS := CCS811.h ota.h wifiinfo.h
56BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin 62BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin
57ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf 63ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf
58 64
59all: $(ELF)
60.PHONY: all 65.PHONY: all
66all: $(ELF)
67 @ls -l $(ELF)
61 68
62compile: $(ELF) 69compile: $(ELF)
63.PHONY: compile 70.PHONY: compile
64 71
72build_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
68upload: $(ELF) 78upload: $(ELF)
79 [ -w "$(SERIAL_DEV)" ] || sudo chmod 666 "$(SERIAL_DEV)"
69 $(cli) upload -p "$(SERIAL_DEV)" 80 $(cli) upload -p "$(SERIAL_DEV)"
70 81
71ota: $(BIN) 82ota: $(BIN)