NOTE: Due to a lack of documentation from the developers, MOST of this information has been derived from my hacking experience with the IDE. Please don't hesitate to correct anything you find to be in error.
The Arduino IDE (at least since 1.05) has the wonderful capability of being customizable for new types of hardware. You can add code that supports pin/port assignments or even new kinds of processors (such as the xmega) by re-writing the core libraries and headers and placing them into new directories within the Arduino environment directories.
NOTE: In Arduino IDE version 1.5 onwards the format has changed somewhat. Here is the official Arduino IDE 1.5 3rd party Hardware specification
The most important single file is the 'boards.txt' file, located in the following directory:
where '{ARDUINO}' represents the directory into which the Arduino IDE and supporting files have been installed. This may be '/usr/local/arduino' or '/usr/share/arduino' or one of many OTHER possible choices depending on your operating system.
A typical entry for a processor may look as follows:
The prefix ('uno' in this case) is unique for a particular board. So if you create a new board, you would write a similar section and add it to 'boards.txt', with 'myboard' (or whatever) in place of 'uno' at the beginning of each string, and modify the description accordingly. Keep in mind that this is COMMON FOR ALL USERS (important for Linux and BSD), most likely requires a privileged user to edit the file, and will probably be overwritten when you update the IDE (so save a backup copy of your changes).
Some of these entries allow you to flash a particular bootloader onto your device. You might want to compile a custom bootloader using the available source. The source and output files are located in:
Some of the entries may be obvious, but I'll explain them anyway.
Sometimes you will need to customize a standard library for your own use. Unfortunately this may be due to the fact that, all too often, the libraries don't support your hardware properly, and/or do NOT have the common decency to mark members as 'protected' rather than 'private' (forcing you to edit the library or clone it, rather than creating a derived class). Fortunately, the Arduino IDE allows you to put your own libraries into a user-specific location:
Where '{SKETCHBOOK}' is the location of your default sketchbook repository (as specified in 'preferences').
The Arduino IDE will look in {SKETCHBOOK}/libraries for matching library names when you '#include' a header file in the main 'INO' (or PDE) file. So you will always need to specify the header file in the main 'INO' file so that the Arduino IDE can locate it (along with any source files).
Additional information about custom libraries can be found here: http://arduino.cc/en/Guide/Libraries
See also the official Arduino IDE 1.5+ Library specification
The {ARDUINO}/hardware/arduino/cores and {ARDUINO}/hardware/arduino/variants trees contain 'core' and 'variant' source and header files that are specific to a particular piece of hardware. As an example,
contains the core library and startup source specific to a standard Arduino, whereas
contains the same files but for the 'robot' implementation. You could add your own by 'cloning' the files from a similar project and creating a new directory, such as 'myboard' within the 'cores' directory structure.
Similarly, the {ARDUINO}/hardware/arduino/variants directory tree contains 'pins_arduino.h' files that are specific to a particular piece of hardware. The standard variant is, well, 'standard'. A typical variant that you might use might be 'mega' (for the MEGA2560) or 'eightanaloginputs' (when your project uses a surface mount ATmega328P rather than the through hole package, as the former has 2 additional analog inputs available).
See also the official Arduino Hardware Cores migration guide from 1.0 to 1.6
A Tour Inside Arduino Core: Source Files, How to Make A New Core and Arduino Building Steps