This article explains how to build the code for APM2.x with Make on
Windows, Mac and Linux.

Warning

Copter 3.3 firmware (and later) and builds after Plane 3.4.0 no
longer fit on APM boards. Plane, Rover and AntennaTracker builds can
still be installed at time of writing but you can no longer build APM2.x
off the master branch (you will need to build off a supported release
branch).

The preferred way for developers to build APM applications is using the
Makefile system distributed with the repository. This Makefile system is
the canonical way to build APM. APM applications can no longer be built
with the standard Arduino IDE, as the APM build requires the Arduino IDE
base libraries to be excluded from the build.

For developers who would prefer not to use make, a modified Arduino IDE
which emulates the custom APM build process is available.

The build process itself attempts to diagnose problems that would
prevent a successful build outside of code errors. It may emit the
following diagnostics:

WARNING: More than one copy of Arduino was found, using …(Mac OS
only)

Spotlight found more than one copy of Arduino installed on your system.
Check the path that is printed to ensure that the correct version is
being used. To avoid this problem, either remove old versions of Arduino
or specify the ARDUINO option when invoking the build system. Typically
the installation that will be chosen is the one that was most recently
launched.

ERROR: must set BOARD before including this file.

The sketch Makefile has not defined the BOARD variable. This is normally
set to `atmega2560` for APM2.x builds.

ERROR: Spotlight cannot find Arduino on your system.(Mac OS only)

Arduino is not installed, or it is installed in a location that is not
being indexed by Spotlight. You can either enable Spotlight for the
location where Arduino is installed, or specify the location explicitly
by setting the ARDUINO option as described above. Note that Spotlight
indexing may take some time, so enabling it for the location containing
Arduino may not immediately correct this issue.

ERROR: Cannot find Arduino on this system

(Linux and Windows only)Arduino was not found in one of the standard
locations. Either move Arduino to a standard location, or specify its
current location with the ARDUINO option in the config.mk file

ERROR: cannot find the compiler tools anywhere on the path …

The compiler and related tools cannot be found. For Mac OS and Windows
the tools are normally part of Arduino and this message indicates that
the Arduino installation is damaged.

For Linux systems, this means that the AVR tools are not installed in a
standard location. Either set the TOOLPATH option to point to the
directory containing the AVR tools, or install them in a standard
location. Normally installing Arduino on a Linux system will result in a
correct installation of the AVR tools.

ERROR: cannot find gawk - you may need to install GNU awk

(Linux and Windows only)The GNU awk utility is required, but it has not
been installed or cannot be found. Check that `gawk –version` works
at the command promp. You may need to specify its location explicitly
with the AWK option.