This is a very simple Makefile which knows how to build Arduino sketches. It defines entire workflows for compiling code, flashing it to Arduino and even communicating through Serial monitor. You don't need to change anything in the Arduino sketches.
*.pdesketches as well as raw
*.hfiles lead to recompilation of sources which include them
If you're using FreeBSD, Debian, Raspbian or Ubuntu, you can find this in the
package which can be installed using
sudo apt-get install arduino-mk
If you're using homebrew (or linuxbrew) then you can find this in the
arduino-mk package which can be installed using the following commands.
Also make sure you have the necessary dependencies installed. Refer to the Requirements section below to install the dependencies.
# add tap$ brew tap sudar/arduino-mk# to install the last stable release$ brew install arduino-mk# to install the development version$ brew install --HEAD arduino-mk
Arch Linux users can use the unofficial AUR package arduino-mk. It can be installed using the following command.
yaourt -S arduino-mk
Fedora Linux users can use our packaging instructions here to build an RPM.
git clone firstname.lastname@example.org:sudar/Arduino-Makefile.git
You need to have the Arduino IDE. You can either install it through the installer or download the distribution zip file and extract it.
The Makefile also delegates resetting the board to a short Python program.
You'll need to install
pySerial to use it though.
On most systems you should be able to install it using either
pip install pyserial# or if you prefer easy_installeasy_install -U pyserial
If you prefer to install it as a package, then you can do that as well.
On Debian or Ubuntu:
apt-get install python-serial
yum install pyserial# or on Fedora 22+dnf install pyserial
zypper install python-serial
On Mac using MacPorts:
sudo port install py27-serial
You need to install Cygwin and its packages for Make, Perl and the following Serial library or you can install it using the pre-built package installer
You can also find more detailed instructions in this guide.
You can also checkout the sample makefiles inside the
examples/ directory, e.g. Makefile-example demonstrates some of the more advanced options,
whilst Blink demonstrates the minimal settings required for various boards like the Uno, Nano, Mega, Teensy, ATtiny etc.
Download a copy of this repo some where in your system or install it through a package.
On the Mac you might want to set:
ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/JavaARDMK_DIR = /usr/localAVR_TOOLS_DIR = /usrMONITOR_PORT = /dev/ttyACM0BOARD_TAG = mega2560
On Linux (if you have installed through package), you shouldn't need to set anything other than your board type and port:
BOARD_TAG = mega2560MONITOR_PORT = /dev/ttyACM0
On Windows (using cygwin), you might want to set:
ARDUINO_DIR = ../../arduinoARDMK_DIR = path/to/mkfileMONITOR_PORT = com3BOARD_TAG = mega2560
On Windows (using MSYS and PuTTY), you might want to set the following extra parameters:
MONITOR_CMD = puttyMONITOR_PARMS = 8,1,n,N
On Arduino 1.5+ installs, you should set the architecture to either
sam and if using a submenu CPU type, then also set that:
ARCHITECTURE = avrBOARD_TAG = atmegangBOARD_SUB = atmega168
It is recommended in Windows that you create a symbolic link to avoid problems with file naming conventions on Windows. For example, if your your Arduino directory is in:
c:\Program Files (x86)\Arduino
You will get problems with the special characters on the directory name. More details about this can be found in issue #94
To create a symbolic link, you can use the command “mklink” on Windows, e.g.
mklink /d c:\Arduino c:\Program Files \Arduino
After which, the variables should be:
ARDUINO_DIR=../../../../../Program\ Files\ \(x86\)/Arduino
BOARD_TAG- Type of board, for a list see boards.txt or
MONITOR_PORT- The port where your Arduino is plugged in, usually
/dev/ttyUSB0in Linux or Mac OS X and
com4, etc. in Windows.
ARDUINO_DIR- Path to Arduino installation. In Cygwin in Windows this path must be relative, not absolute (e.g. "../../arduino" and not "/c/cygwin/Arduino").
ARDMK_DIR- Path where the
*.mkare present. If you installed the package, then it is usually
AVR_TOOLS_DIR- Path where the avr tools chain binaries are present. If you are going to use the binaries that came with Arduino installation, then you don't have to set it. Otherwise set it realtive and not absolute.
The list of all variables that can be overridden is available at arduino-mk-vars.md file.
You can specify space separated list of libraries that are needed for your sketch to the variable
ARDUINO_LIBS = Wire SoftwareSerial
The libraries will be searched in the following places in the following order.
/librariesdirectory inside your sketchbook directory. Sketchbook directory will be auto detected from your Arduino preference file. You can also manually set it through
/librariesdirectory inside your Arduino directory, which is read from
The libraries inside user directories will take precedence over libraries present in Arduino core directory.
The makefile can autodetect the libraries that are included from your sketch and can include them automatically. But it can't detect libraries that are included from other libraries. (see issue #93)
To upload compiled files,
avrdude is used. This Makefile tries to find
avrdude and it's config (
ARDUINO_DIR. If you like to use the one installed on your system instead of the one which came with Arduino, you can try to set the variables
AVRDUDE_CONF. On a typical Linux system these could be set to
AVRDUDE = /usr/bin/avrdudeAVRDUDE_CONF = /etc/avrdude.conf
For Teensy 3.x support you must first install Teensyduino.
See examples/BlinkTeensy for example usage.
The current version of the makefile is
1.5. You can find the full history in the HISTORY.md file
This project adheres to Semantic Versioning 2.0.
This makefile and the related documentation and examples are free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
All contributions (even documentation) are welcome :) Open a pull request and I would be happy to merge them. Also checkout the contribution guide for more details.
If you are looking for ideas to work on, then check out the following TODO items or the issue tracker.
If you find an issue or have an idea for a feature then log them in the issue tracker
On-the-fly syntax checking in Emacs using the Flymake minor mode is now possible.
First, the flymake mode must be configured to recognize ino files :
Edit the flymake configuration :
M-x customize-option RETflymake-allowed-file-name-masks RET
Add the line :
Then click on "Apply and Save" button
Then, the following line must be added to the project Makefile :
check-syntax:$(CXX) -c -include Arduino.h -x c++ $(CXXFLAGS) $(CPPFLAGS) -fsyntax-only $(CHK_SOURCES)
In Code:Blocks open Project -> Properties -> Project settings tab -> check "This is custom Makefile".
Now go to Settings -> Environment -> Environment variables -> Add
Add three keys with paths as values, using full paths (!):
Now to set DEBUG target (this will compile the project) go to Build options -> Debug -> "Make" commands
In Build Project/Target remove $target:
$make -f $makefile
In Clean Project/Target remove $target:
$make -f $makefile clean
To set the RELEASE target (which will compile and upload) go to Build options -> Release -> "Make" commands
In Build Project/Target put:
$make -f $makefile upload
In Clean Project/Target remove $target:
$make -f $makefile clean
This project includes a suite of example Makefiles and small Arduino and chipKIT
programs to assist the maintainers of the Makefile. Run
tests/script/bootstrap.sh to attempt to automatically install the dependencies
(Arduino IDE, MPIDE, etc.). Run
tests/script/runtests.sh to attempt to compile
all of the examples. The bootstrap script is primarily intended for use by a
continuous integration server, specifically Travis CI. It is not intended for
If you are planning on using this makefile in a larger/professional project, you might want to take a look at the Bare-Arduino–Project framework.
Similar to HTML frameworks, Bare-Arduino–Project aims at providing a basic
Makefile configurations for both OS X and Linux and a handful of instruction on how to get started with a robust Arduino project architecture.
Please be sure to report issues to Bare-Arduino–Project if you use it instead of this project.