Successfully Build an Ada Compiler in Arch
From ArchWiki
i18n |
---|
Español |
Contents |
Successfully Build an Ada Compiler in Arch
Introduction
The thing which was most annoying for me in Arch Linux is that I absolutely needed to have a working Ada compiler on my computer for my studies, and I found there was no Ada support in my favorite Linux distribution.
Unfortunately, an Ada compiler is required to build the Ada compiler. In this HowTo, I will describe how to properly install Ada support in the gcc package.
Getting a binary compiler
As I said before, an Ada compiler is required to compile an Ada compiler. Therefore you will have to get one from a binary distribution. I suggest (and highly recommend) you use one from http://gnuada.sourceforge.net/. These are the only ones I could get to compile gcc-ada.
So, grab an RPM for your architecture:
For example, I'll use this one: gnat-gcc-4.1.1-r6.FC6.i386.rpm.
Now, create a temporary folder for your build:
$ mkdir ~/ADA_BUILD
And extract the RPM to some directory (this requires rpmextract from extra):
$ cd ~/ADA_BUILD $ mkdir RPM $ cd RPM $ rpmextract.sh /<path to>/gnat-gcc-4.1.1-r6.FC6.i386.rpm
You now have a full gcc installation in ~/ADA_BUILD/RPM.
Updating the abs database
As root, run:
$ mkdir -p /var/abs #you don't need that if you ran it before already $ abs
and copy the gcc PKGBUILD and files to your temporary folder:
$ cd ~/ADA_BUILD $ cp -rv /var/abs/core/devel/gcc .
Editing the PKGBUILD
$ cd ~/ADA_BUILD/gcc
Now you will have to modify the PKGBUILD to add the Ada language to your compilation: Edit it as follows:
- In the sources array, replace:
ftp://gcc.gnu.org/pub/gcc/releases/gcc-${pkgver}/gcc-{core,g++,objc}-${pkgver}.tar.bz2
with
ftp://gcc.gnu.org/pub/gcc/releases/gcc-${pkgver}/gcc-{core,g++,objc,ada}-${pkgver}.tar.bz2
- Remove everything from "md5sums=(" to the next right parenthesis.
- Now find the ./configure line
and add ada to --enable-languages=...
../gcc-${pkgver}/configure --prefix=/usr --enable-shared \ --enable-languages=c,c++,objc,ada --enable-threads=posix \
Building the package
$ cd ~/ADA_BUILD/gcc
Clean up the directory if it's dirty.
$ rm -r pkg/ src/ *.pkg.tar.gz
You need to set your environment so that the Ada toolchain is used instead of the one installed on your system.
$ export PATH="~/ADA_BUILD/RPM/usr/bin:$PATH"
Check that your system now uses the right gcc compiler.
$ which gcc
This should point to the one you unpacked from the RPM. If that's OK, then you're ready to go.
$ makepkg
This will take a while. When it is built, upgrade it as root:
$ pacman -U gcc-*.pkg.tar.gz
You can now test your Ada compiler with the gnatmake command:
$ gnatmake helloworld.adb
Additional Notes
Once you have your Ada compiler up-and-running, you don't need to do this over and over again. When a new gcc is released, DON'T upgrade and overwrite your former one. Instead, get the latest PKGBUILD from abs, make the modifications, and recompile.
Troubleshooting
configure fails
If you get the following error from makepkg:
configure: error: C compiler cannot create executables
check your CFLAGS entry in /etc/makepkg.conf. In my case, I had to temporarily remove the "-mtune=generic" flag, as the compiler from the rpm did not support that.
For more information on what may be the problem, check the config.log file.