There is a new, portable command-line make script for building Arduino code, which implements all the steps described in the standard Arduino build process, as documented in
http://arduino.cc/en/Hacking/BuildProcess.
The arduinomake.tcl build script is written in TCL. The script still requires the standard Arduino software to be installed, but you no longer need to launch the Arduino IDE to build and upload the code to the Arduino board. Please note the the TCL shell interpreter is already included in the standard Arduino distribution for Windows (<Arduino>\hardware\tools\avr\bin\tclsh84.exe) and on other platforms, such as Linux, the TCL interpreter is available by default.
The arduinomake.tcl build script is designed to be called from the directory containing the Arduino sketch (.ino file). From this directory, you call the script as follows:
tclsh arduinomake.tcl <BARD> "<LIBS>" ["<DEFINES>"]
For example, to build a sketch for the UNO board, using the QP library as well as the Ethernet library and
providing the definitions for the symbols BAR and FOO=25, you call the arduinomake.tcl build script as
follows:
tclsh arduinomake.tcl UNO "qp Ethernet" "BAR FOO=25"
NOTE: The arduinomake.tcl build script requires the environment variable ARDUINO_HOME to
be defined and point to the installation directory of the standard Arduino software.
The arduinomake.tcl build script works as follows:
1. Builds the specified Arduino libraries using the avr-gcc compiler included in the standard Arduino
distribution. The libraries must exist in the <Arduino>\libraries\ directory and must be structured
according the the Arduino standard. The source code in the libraries can be located in the library
directory as well as the utility\ sub-directory. The compiled libraries (.a files) are created in the
lib\ sub-directory of the project directory.
2. Generates the dependency files for all .ino, .cpp, and .c source code files found in the project
directory. The dependency files (.d files) contain the information of all files included a given source
file, so that if any of these files changes, the dependent source file can be recompiled. The
dependency files are generated in the bin\ sub-directory of the project directory.
3. Parses the <Arduino>\hardware\arduino\boards.txt to determine the exact MCU type, the
AVR core, the Build variant, etc. needed to build the code. This information is extracted from the
boards.txt file based on the Arduino board parameter provided to the arduinomake.tcl build
script.
4. Builds the object files for all .ino, .cpp, and .c source code files that need recompilation. The
object files are generated in the bin\ sub-directory of the project directory.
5. Links the object files (.o files) in the bin\ sub-directory and the libraries (.a files) in the lib\ sub-
directory to form the <project>.elf file in the bin\ sub-directory of the project directory, where
<project> is the name of the project directory. The naming of the compiled image is chosen for
compatibility with the standard Arduino build process in the Arduino IDE.
6. Generates the HEX file (.hex file) from the .elf file in the bin\ sub-directory, which is used for
uploading the image to the Arduino board.
The arduinomake.tcl build script can be downloaded from
https://sourceforge.net/projects/qpc/files/QP_Arduino/4.5.03/ , as part of the QP for Arduino distribution.