To get going on Mac, the software developer tools must be installed. These are usually supplied with the system software that comes with the computer, or can be downloaded from the Apple website. The tools include programs and utilities that are needed to build software, such as the program 'make'. To see if the developer tools are installed, open a terminal window and try the command 'make'. If it says 'command not found', then the tools are not installed.
Installing the GNU toolchain for Mac is actually pretty simple. Thankfully the GNU toolchain is available as a package from Darwin Ports. This makes installing simple. The package is called arm-elf-gcc and is available with installation instructions here.
Installing can take some time, as the programs are large. Once it is complete try the command 'arm-elf-gcc-4.0.0':
$ arm-elf-gcc-4.0.0 arm-elf-gcc-4.0.0: no input files
If it says 'no input files', then everything is working, and you're ready to compile programs.
To try out the toolchain, download the example program to a directory of your choosing. Open a terminal, unpack the archive. A directory HelloSineWave is created. Move to the directory, and run make:
$ tar xvf HelloSineWave.tar $ cd HelloSineWave $ make
If you get an error 'arm-elf-gcc: command not found' open the file called 'makefile' and change the third line from 'CC = arm-elf-gcc' to 'CC = arm-elf-gcc-4.0.0', and try it again.
If everything goes smootly, there should now be a file 'main.hex' in the directory, and you're ready to move to the upload step.
The program 'make' looks for a Makefile script which contains all the details of the compilation process. The Makefile is in the directory with the rest of the source files. It then invokes the necessary commands (from the GNU toolchain that we just downloaded) to build the final .hex file from the source files.
Basically it breaks down like this: the individual source files are compiled to create object (.o) files. Then these .o files are linked together to create a single binary file. This file is then converted to the .hex format. Take a look at the Makefile to see more details.
Once you have successfully compiled the example program run the command 'make clean'. This command removes all the compiled .o files. It is a convenient way to compile everything from scratch. ('make' uses the modified time of files to determine what source files need to be compiled. If those times get mixed up, things can get screwy. So it's always a good idea to run the command 'make clean' to bring everything up to date.)