GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
BSD.ARDUINO.MK(7) FreeBSD Miscellaneous Information Manual BSD.ARDUINO.MK(7)

bsd.arduino.mk
build Arduino sketches with make(1)

ARDUINO_MK_DIR=/usr/local/arduino-bsd-mk
...
.include "${ARDUINO_MK_DIR}/bsd.arduino.mk"

The file bsd.arduino.mk is used to build Arduino sketches from the command line using make(1). The goal is to efficiently build potentially complicated projects with simple Makefiles and completely bypass the Arduino graphical user interface.

Modules that are part of the standard Arduino distribution along with modules that are part of referenced Arduino libraries (specified with the ARDUINO_LIBS variable) are compiled once and stored in a library. Sketch modules are built as determined by make(1).

defines
Dump out the compiler defines specific to ARDUINO_BOARD.
flash
Compile, link and run avrdude(1) to program the target board.
install
An alias for flash.
lint
Run cppcheck(1) on all of the source files.
obj
Create a build directory.
objlink
Create a symlink to the build directory.
report
Use avrdude(1) to report the fuse settings.
size
Use avr-size(1) to list section sizes and total size.
tags
Create or update a tags file by running ctags(1) on SRCS and HFILES.

These variables must be set:
TARGET
The name of the sketch. If SRCS is not defined then the sketch is built from ${TARGET}.cpp or ${TARGET}.ino.
ARDUINO_BOARD
The name of the board. This is important as the arduino-boards script uses it to set the defaults for ARDUINO_CORE, ARDUINO_VARIANT, F_CPU and MCU from the Arduino boards.txt file.
ARDUINO_MK_DIR
The path to the arduino-bsd-mk installation directory.

It's frequently useful to set these variables:
SRCS
A list of .ino, .cpp and .c sources. This is used when the name of the module does not match TARGET and when more than one source is used.
ARDUINO_DIR
Top level of Arduino installation. This defaults to /usr/local/arduino but can be changed to point to a local Arduino distribution.
ARDUINO_LIBS
A list of Arduino libraries. For example:
ARDUINO_LIBS=SPI Wire
    

Since these are located by first looking in .CURDIR and then in one or more Arduino library directories the Arduino distribution tree it's possible to use local libraries and to override standard Arduino libraries.

AVRDUDE_PORT
The avrdude(1) programmer port when the programmer is "arduino". This is passed with the -P flag.
AVRDUDE_PROGRAMMER
An avrdude(1) programmer id string. The default this is set using boards.txt.

When AVRDUDE_PROGRAMMER is "arduino" AVRDUDE_PORT must be set using one of these methods:

  • In your shell environment before running "make flash"
  • With the make command line, e.g. "make flash AVRDUDE_PORT=/dev/ttyU3"
  • In Makefile.inc, e.g. "AVRDUDE_PORT=/dev/ttyU3"

When AVRDUDE_PROGRAMMER is one that uses USB, AVRDUDE_PORT can optionally specify the usb port. See the -P option in the avrdude(1) man page for more details.

AVRDUDE_SPEED
The avrdude(1) programmer speed when the programmer is "arduino". This is passed with the -b flag.

These options for these variables default those found in the Arduino boards.txt file by the arduino-boards script for ARDUINO_BOARD.
ARDUINO_CORE
This is the location of the core to link sketches against when compiling.
ARDUINO_VARIANT
This is the variant of
F_CPU
The the clock speed at which the microcontroller operates at. This is useful when under or overclocking.
MCU
The microcontroller on the board.

ARDUINO_CFLAGS
Additional compile C flags (added to CFLAGS).
ARDUINO_CXXFLAGS
Additional compile C++ flags (added to CXXFLAGS).
AVR_LIBC_DIR
Top level of the avr-libc installation. This defaults to /usr/local/avr.
AVR_LIBC_DIR
Top level of the avr-libc installation. This defaults to /usr/local/avr.
CPPCHECK_FLAGS
Additional cppcheck(1) flags to be used with "make lint"
HFILES
Specify include files that should also be processed by ctags(1) for "make tags".
WITH_CPPCHECK_XML
When set, "make lint" runs cppcheck(1) with XML output enabled using the --xml and --xml-version=2 flags.
WITH_CPPCHECK_CHECKCONFIG
When set, make lint" runs cppcheck(1) with the --check-config flag.

It's important to do a "make clean" if ARDUINO_BOARD or any other PROCESSOR OPTIONS options are changed.

To allow use of the avr-gcc(1) -Werror flag, standard and local Arduino library modules are compiled using the -w flag which inhibits warning messages. This makes it possible to add the -Wall, -Werror and -Wstrict-prototypes flags to ARDUINO_CFLAGS (which is recommended).

/usr/local/arduino/hardware/arduino/boards.txt
The Arduino boards database.
/usr/local/arduino/lib/version.txt
The Arduino version file.
/usr/local/arduino/libraries
The location of standard Arduino libraries.
/usr/local/arduino-bsd-mk
The default location of bsd.arduino.mk and the scripts directory.
/usr/local/arduino-bsd-mk/scripts/arduino-boards
Script used to parse boards.txt to determine various hardware related options.
/usr/local/arduino-bsd-mk/scripts/arduino-version
Script used to parse version.txt file.
/usr/local/arduino-bsd-mk/scripts/gcc-version
Script used to determine the version of avr-gcc(1).
/usr/local/avr
The default top level of the avr-libc installation.

Here's a sample Makefile:
TARGET= blink2
ARDUINO_BOARD= atmega328
ARDUINO_MK_DIR= /usr/local/arduino-bsd-mk
MAKEOBJDIRPREFIX=/usr/obj
ARDUINO_CFLAGS+= -Wall -Werror -Wstrict-prototypes
ARDUINO_CXXFLAGS+= -Wall -Werror -Wstrict-prototypes
.include "${ARDUINO_MK_DIR}/bsd.arduino.mk"

There is one source named blink2.ino or blink2.cpp. The board is a atmega328. Additional compiler flags are specified.

avr-gcc(1), avrdude(1), make(1)

bsd.arduino.mk was inspired by a gmake(1) makefile originally written by Martin Oldfield and described in his blog titled, "Arduino from the command line."

Craig leres ⟨leres@xse.com⟩
January, 9 2021 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 7 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.