Building and Installing a Cross Compiler

   

Prerequisites

You need a native GNAT compiler on your system. Nowadays almost all Linux distributions contain the Ada enabled gcc (≥ 3.4). On MinGW there is a precompiled gcc-3.4.2 with Ada support.

You need the GNU binutils and the avr-libc library. The first is available on any GNU mirror. Take at least version 2.14. The latter is available from the AVR libc home page. Any version after 1.0 will do. I use the release 1.2.5.

The gcc sources must be from the 3.4 branch of gcc. I did all my tests and modifications on gcc-3.4.4. There is a big delta of the Ada sources between gcc-3.3 and gcc-3.4. If you want to use gcc-3.3, take the old AVR-Ada-V0.1 release.

Get the latest patch from the AVR-Ada project. The same patch is also included in the full AVR-Ada package in the directory patches/.

Building the compiler (the hard way)

You first have to build and install the binutils package. To build the binutils use the configure options

--prefix=/opt/avr --target=avr

This way all files are installed in a separate directory (/opt/avr). They can easily be replaced or removed from the system.

Apply the patch to the gcc sources before configuring and compiling.

At the configure step ensure that you use the same prefix as for the binutils and that you enable "ada".

--prefix=/opt/avr --target=avr --enable-languages=c,ada

The following make will create the C and the basic Ada compiler.

make

GNAT comes with several very useful utility programs. For building them you have to step into the gcc directory and start

cd gcc
make cross-gnattools

Than go back up again and redo the make step followed by the final make install. The make command now renames the just built gnattools to <toolname>-cross. The make install renames the tools then to avr-<toolname> and copies them into the installation bin directory (/opt/avr/bin).

cd ..
make
make install

Building the compiler (the easy way)

Have a look at the shell scripts build-avr-ada-*.sh in the tools/build/ directory. It automates the build process and we use it exclusively for building our compilers and tools.