Last active
October 25, 2023 14:49
-
-
Save tuna-f1sh/d18df94cf7afedd8f4153664c8f8cfbc to your computer and use it in GitHub Desktop.
arduino-cli Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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