And so I did.
Now we all know that Linux system is a very broad term, what with the abundance of versions available, but to me there's really only one that counts, and that is Slackware, so that's what I'm going to base this article on. Also I'm guessing that all you Debian, Red Hat and openSUSE folks already have much of this software readily available in your fancy package repositories. At least I know that there's an Ada Policy for Debian, which usually equals some packages also.
We'll be installing 5 Ada packages on a Slackware64 13.37 box. The 5 packages are:
- GNAT GPL (Ada compiler and IDE)
- Florist (POSIX library)
- XML/Ada (XML library)
- GNATcoll (Various utilities library)
- Ada Web Server (AWS)
All of these can be found at the libre.adacore.com website. We'll be working with a full install of Slackware, with PostgreSQL and TeX Live added to the default Slackware packages. Also a regular user named thomas has been created. Only the compiler will be installed as root, the rest of the libraries will be installed as thomas. Obviously you should substitute all references to thomas according to your own setup.
This article will not deal with how to install Slackware, nor how to obtain the above Ada packages from libre.adacore.com.
Movies You Say?
When I decided to write this article, I also decided I wanted to do 5 short videos to accompany it. "Why?" you might ask, and that would of course be a completely valid question. The answer is simple:
Because it's fun!
Also these 5 videos grant me the opportunity to get the phrase "Ada programming" on YouTube. Whether or not that actually help Ada's search rank is yet to be seen, but it properly wont make it any worse. I hope.
Please bear in mind that I know zero about making videos, English is not my first language, and I've not done anything like this before. These videos are at best an amateurs feeble attempts at making something useful. One thing they do document, despite their less than stellar quality, is the fact that the commands you'll read in this article actually works in real life.
Each video will be linked in the headline for the appropriate section below.
Those of you who really can't be bothered with videos will of course not be left behind. All the commands necessary to compile and install these Ada tools are made available in this article. Basically what you're getting is my Bash history, with one little addition: Whenever I type something in a program such as an installer or in emacs, the typed text is indented 4 spaces, like this:
In the first example some stuff is added to somefile using emacs, and in the second example RETURN is clicked while running the installer program. I hope this makes sense. Else watch the videos, as you'll be able to see exactly what's going on. Hey, I'm already getting pretty good at shamelessly plugging my own videos! I'm SEO personified. Or not.
Also when you see the year 2011 in file names and commands, you should of course substitute it with whatever edition you might've downloaded, be it newer or older. The same goes for obvious version numbers, such as 4.1 for XML/Ada.
Lets get to it..
Even though Slackware64 13.37 comes equipped with an Ada compiler out of the box, it's really a rather old one and it's not very suited as compiler for any remotely new Ada projects, and I know for a fact that it simply cannot compile AWS, so the first step is getting a new compiler on the system. My choice is the GNAT GPL compiler from AdaCore.
This is the file I've downloaded: gnat-gpl-2011-x86_64-pc-linux-gnu-bin.tar.gz
As root do:
Now, you can either re-type the .bashrc stuff into the /home/thomas/.bashrc file, or you can use this little trick:
That simply moves the last 9 lines from the /root/.bashrc to /home/thomas/.bashrc. Quite nifty eh'? You must of course adjust the 9 to suit your needs. It should be less if you haven't added the same amount of line breaks as I have.
Note that the Slackware system does not come with .bashrc setup by default, so you're going to have to create it yourself, if haven't already, and then source it manually. Or you can create a .bash_profile file to have it source automatically on login:
And with that you now have a brand spanking new Ada compiler in /usr/gnat/ on your Slackware box:
Compiling and installing Florist is about as easy as it can get. This is the file I've downloaded: florist-gpl-2011-src.tgz
As root do:
There are no tests nor demos available in the Florist source package, so the only way to test it, is to start using it. Simply add with florist; to your project file, and get cracking.
If you're looking for a deep and intensive challenge, then this section is not going to please you: XML/Ada is dead-simple to compile and install.
This is the file I've downloaded: xmlada-gpl-4.1-src.tgz
As thomas do:
With the GPR_PROJECT_PATH environment variable in place, all you have to do to use XML/Ada is with the necessary packages in your program, for example with DOM.Core.Documents; or with Sax.Readers;.
GNATcoll is the first of these libraries where you actually have to make some decisions. It's possible to enable/disable various components in GNATcoll, for example if you don't ever plan on using the facilities to handle project files or SQLite databases, then you can disable them in the configure step. Use ./configure --help to see your options.
This is the file I've downloaded: gnatcoll-gpl-2011-src.tgz
As thomas do:
Usage is as usual: with gnatcoll; or with gnatcoll_postgresql or, well, you get the point.
So far so good. 4 down, only one to go.
Last, but not least: The Ada Web Server. A marvelous piece of software that enables you to add HTTP(S) functionality to your Ada programs. And luckily it's just as easy to compile and install as all the other libraries.
This is the file I've downloaded: aws-gpl-2.10.0-src.tgz
As thomas do:
Note the missing ./configure step. Instead of that you edit the makefile.setup file to enable/disable various components and to define where AWS is installed.
with aws in your project file is all you have to do to make use of its powerful facilities. Be sure to check the documentation, as there's a lot of very interesting stuff in there.
One Final Note
In the above we've installed the latest official versions of the software (as per the time of writing), but that might not be the best solution. Actually I'll go as far as to say that it isn't the best solution, since AdaCore only release once each year. What I usually do is opt for the developer versions. There are usually fewer bugs in them, and you get to try some of the new stuff the AdaCore wizards are working on.
So, where might you find these fabled developer versions? Here of course:
I haven't been able to track down a dev repo for Florist, and so far I've never had any need to upgrade GNAT GPL more than once a year.
I hope you've enjoyed this little ride through Ada land, and as usual: If you find any errors in my scribblings, please let me know.