-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
59 lines (48 loc) · 1.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Default build architecture and board
TARGET ?= arduino:avr:uno
# Libraries needed for this application
LIBS ?= "Adafruit SSD1306" "Adafruit GFX Library"
# Default list of cores to install with `make setup`
CORES ?= arduino:avr adafruit:samd esp8266:esp8266 esp32:esp32
# Where to save the Arduino support files, this should match what is in .cli-config.yml
ARDUINO_DIR ?= .arduino
default:
#################################################################################################
# Initial setup: make .arduino/arduino-cli setup
#
# Build all the examples: make all TARGET=adafruit:samd:adafruit_feather_m0
#
# Install more cores: make setup CORES=arduino:samd
# (edit .cli-config.yml and add repository if needed)
#################################################################################################
ARDUINO_CLI_URL = http://downloads.arduino.cc/arduino-cli/arduino-cli-latest-linux64.tar.bz2
ARDUINO_CLI ?= $(ARDUINO_DIR)/arduino-cli --config-file .cli-config.yml
all: # Build all example sketches
all: tiny_scope.hex
%.hex: # Generic rule for compiling sketch to uploadable hex file
%.hex: tiny_scope/%.ino
$(ARDUINO_CLI) compile --warnings all --fqbn $(TARGET) $< --output $@
ls -l $@*
# Remove built objects
clean:
rm -fv *.{hex,elf}*
$(ARDUINO_DIR)/arduino-cli: # Download and install arduino-cli
$(ARDUINO_DIR)/arduino-cli:
mkdir -p $(ARDUINO_DIR)
cd $(ARDUINO_DIR)
curl -s $(ARDUINO_CLI_URL) \
| tar xfj - -O -C $(ARDUINO_DIR) \
> $@
chmod 755 $@
setup: # Configure cores and libraries for arduino-cli (which it will download if missing)
setup: $(ARDUINO_DIR)/arduino-cli
mkdir -p $(ARDUINO_DIR)/libraries
ln -sf $(CURDIR) $(ARDUINO_DIR)/libraries/
$(ARDUINO_CLI) config dump
$(ARDUINO_CLI) core update-index
$(ARDUINO_CLI) core install $(CORES)
$(ARDUINO_CLI) core list
for lib in $(LIBS); do \
$(ARDUINO_CLI) lib install "$${lib}" || true ; \
done
.PHONY: clean %.hex all setup