diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14d78d1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +**/build-*/* +/tmp/ + diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e801b13 --- /dev/null +++ b/Makefile @@ -0,0 +1,69 @@ +#!/usr/bin/make -f +# SPDX-License-Identifier: MPL-2.0 +#{ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/ +#} + +default: help + +topdir?=${CURDIR} +extra_dir?=${topdir}/tmp + +arduino_version?=1.8.5 +arduino_host?=linux32 +arduino_url?=https://downloads.arduino.cc/arduino-${arduino_version}-${arduino_host}.tar.xz +ARDUINO_DIR?=${extra_dir}/arduino-${arduino_version} + +arduino_mk_url?=https://github.com/sudar/Arduino-Makefile +ARDMK_DIR?=${extra_dir}/arduino-mk + + +help: + @echo "# Usage:" + @echo "# make setup # Will install tools and deps" + @echo "# make all # Will build all examples" + +${ARDUINO_DIR}: + mkdir -p ${@D} + cd ${@D} && curl ${arduino_url} | tar -xJ + +rule/arduino_dir: ${ARDUINO_DIR} + ls $< + +${ARDMK_DIR}: + mkdir -p ${@D} + git clone --recursive --depth 1 ${arduino_mk_url} $@ + +rule/arduino_mk_dir: ${ARDMK_DIR} + ls $< + +#{ Libraries +USER_LIB_PATH?=${extra_dir}/Arduino/libraries + +ArduinoJson_url?=https://github.com/bblanchon/ArduinoJson +ArduinoJson_dir?=${extra_dir}/Arduino/libraries/ArduinoJson + +${ArduinoJson_dir}: + @mkdir -p ${@D} + git clone --depth 1 --recursive ${ArduinoJson_url} $@ + +ArduinoMDNS_url=https://github.com/arduino-libraries/ArduinoMDNS +ArduinoMDNS_dir?=${extra_dir}/Arduino/libraries/ArduinoMDNS + +${ArduinoMDNS_dir}: + @mkdir -p ${@D} + git clone --depth 1 --recursive ${ArduinoMDNS_url} $@ + +rule/arduino_lib_dirs: ${ArduinoMDNS_dir} ${ArduinoJson_dir} + ls $^ +#} + +setup: rule/arduino_dir rule/arduino_mk_dir rule/arduino_lib_dirs + sync + +all: $(wildcard examples/*/Makefile | sort) + for file in $^; do \ + dirname=$$(dirname -- "$${file}") ; ${MAKE} -C $${dirname}; \ + done diff --git a/examples/LevelSensor/Makefile b/examples/LevelSensor/Makefile new file mode 100644 index 0000000..6f5d094 --- /dev/null +++ b/examples/LevelSensor/Makefile @@ -0,0 +1,43 @@ +#!/usr/bin/make -f +# SPDX-License-Identifier: MPL-2.0 +#{ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/ +#} + +default: all + @echo "# $@: $^" + +all: rule/setup + +top_reldir?=../.. +topdir?=${CURDIR}/${top_reldir} +-include ${topdir}/Makefile + +AVR_TOOLS_DIR?=${ARDUINO_DIR}/hardware/tools/avr +ARDUINO_DIR?=/usr/share/arduino +ARDMK_DIR?=${ARDUINO_DIR} +arduino_mk?=${ARDMK_DIR}/Arduino.mk + +#{ Config part +VARIANT?=mega +BOARD_TAG=mega2560 +BOARD_SUB= +MCU?=at${BOARD_TAG} +F_CPU?=16000000L +MONITOR_PORT?=$(shell ls /dev/ttyUSB* /dev/ttyACM* | head -n1) +#} + +ARCHITECTURE=avr +AVRDUDE_ARD_BAUDRATE?=115200 +MONITOR_BAUDRATE?=${AVRDUDE_ARD_BAUDRATE} +AVRDUDE_ARD_PROGRAMMER?=wiring + +CPPFLAGS+=-I${top_reldir} + +ARDUINO_LIBS += Ethernet SPI +ARDUINO_LIBS += ArduinoMDNS +ARDUINO_LIBS += ArduinoJson + +-include ${arduino_mk}