From version 1.5.0 arduino has its own official CLI, see https://github.com/arduino/Arduino/blob/ide-1.5.x/build/shared/manpage.adoc following tool is unofficial but still on development
The popular command line builder, Ino (available at http://inotool.org/) has not seen active development in some time and no longer works with newer versions of the Arduino IDE. A fork of ino called Arturo (Available on Github) works with versions 1.6.1 and earlier but is, unfortunately, also broken for newer versions. Arturo 2 is under active development which is a complete rewrite of the ino codebase and promises to provide a python + make based solution (i.e. no Java) that integrates fully with the Arduino 3rd party Hardware specification.
It runs on Windows, Mac OS X, and Linux (+ARMv6).
// Restored the following text from history ~~TimPe, 2011-07-13
Here is a Makefile for compiling and uploading Arduino programs from the command line without the use of the Arduino environment or Java. You will still need a number of other programs. On the Mac or Windows, it's probably easiest just to download and install the Arduino software. Then grab this makefile: Attach:Makefile
On Linux, you will need to install avr-gcc (whose package is usually called gcc-avr), avr-libc and avrdude. On Debian you might try
sudo apt-get install gcc-avr avr-libc avrdude
On Gentoo, see the instructions, but don't worry about installing Java, RXTX, subversion, or jikes or checking anything out of subversion, but do substitute avrdude for uisp. Then, download this zip archive of the Arduino core (it includes the Makefile): Attach:arduino-core-0005.zip
Instructions for writing, compiling/verifying, and uploading your programs are in the Makefile.
Minor detail: on my OS X 10.4 box, I had to add a "-C /location/to/avrdude.conf" to AVRDUDE_FLAGS otherwise it's bombing out when avrdude wants to upload your code.
Link to the hacking section is a broken link? Where has this page gone?
(// Restored the following text from history ~~TimPe, 2011-07-13)