Skip to content

Instantly share code, notes, and snippets.

@tuna-f1sh
Last active October 25, 2023 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuna-f1sh/d18df94cf7afedd8f4153664c8f8cfbc to your computer and use it in GitHub Desktop.
Save tuna-f1sh/d18df94cf7afedd8f4153664c8f8cfbc to your computer and use it in GitHub Desktop.
arduino-cli Makefile
USER_LIB_PATH = lib
OBJDIR = bin
TARGET = $(firstword $(wildcard *.ino))
BOARD_TAG ?= arduino_zero_native
FQBN ?= adafruit:samd:adafruit_feather_m0
UPLOAD_PORT ?= $(wildcard /dev/tty.usbmodem*)
# just to trigger changes to target bin
CSRC := $(shell find . -type f -name '*.c')
CPPSRC := $(shell find . -type f -name '*.cpp')
INCSRC := $(shell find . -type f -name '*.h')
SRCS := $(strip ${TARGET} ${CSRC} ${CPPSRC} ${INCSRC})
ACLI = arduino-cli
CLI_FLAGS = --verbose --warnings default --fqbn ${FQBN}
default: ${OBJDIR}/${TARGET}.bin
${OBJDIR}/%.bin: ${SRCS} Makefile | ${OBJDIR}
${ACLI} compile ${CLI_FLAGS} --libraries ${USER_LIB_PATH} --output-dir ${OBJDIR} --build-property "compiler.cpp.extra_flags="
upload: ${OBJDIR}/${TARGET}.bin
${ACLI} upload --fqbn ${FQBN} --port ${UPLOAD_PORT}
clean:
${ACLI} compile --fqbn ${FQBN} --clean --libraries ${USER_LIB_PATH} --output-dir ${OBJDIR}
rm -rf bin/*.bin
monitor:
${ACLI} monitor --port ${UPLOAD_PORT}
tio:
tio ${UPLOAD_PORT} -b 115200 -e --map ONLCRNL
tags: ${SRCS}
ctags tags ${SRCS} --langmap=c++:+.ino.pde
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment