I’m using a RTM List to track my milestones for this my GSoC this year. I’ll be making a blog post for each item ticked off that list, to share what I’ve learnt in my journey from n00b to someone whose code is good enough to be included in GNOME. This is part 1 in the series, where I tell you about autotools

My GSoC project involves, moving major parts (UI) of Cheese to a new language – Vala. Vala is more an extremely glorious C preprocessor than a language of its own – it just translates down to GObject based C code, rather than bytecode/objectcode. The syntax is very C#ish – I was using csharp-mode in emacs to code vala till I got bored enough to download vala-mode. It’s got closures – haven’t used them yet, here is to hoping they’re real closures. It has tons of libraries – it takes a few (minutes|hours) to write a binding for any C library, so many bindings already exist. You don’t lose speed – Vala is compiled down to C code. It also has one of Java’s suckiest features – Checked Exceptions. The documentation is non existent – you’ve to pretty much read through the bindings, or the original C library’s documentation to get anything done. And not many people know such a language exists (Kausik for example – but he also didn’t know you could output pdf from latex, so I don’t think his opinion counts :D)

Cheese uses autotools for building. I had to tweak their script to make it build my Vala code as well. I’ve never worked with any of the autotools stuff before – I didn’t even know .ac stood for autoconf and .am stood for automake. No big deal – Google knows it all and will tell you for free. I JFGI and found a bunch of articles about using autotools to successfully build vala projects. After reading this monstrous (180+ slides, but ~500 pages) Autotools presentation (which is actually very, very good, btw), I had a working build script. It built my single cheese.vala file that did nothing but run a loop and wait to be terminated. It had a place where I could add more .vala files and they should (should) be included in the build. It was hackish, but like most hacks, it worked. On My Machine(tm).

Nowhere else. Turned out my script wasn’t working at all – just faking it to me. I had initially tested out valac (the vala compiler), which had produced a .c file. Since make was supposed to produce the same file, and it wasn’t stale (I hadn’t touched my cheese.vala), it just proceeded to compiling the .c files with gcc. The Vala part of the build script wasn’t being executed at all. Removing the .c file told me that my hackish script hadn’t worked at all.

After banging my head for a while to figure out why it wasn’t working, I finally landed up on the official autotools docs. Autotools had added native vala support. The hack I found was not necessary.

facepalm

Moral of the Story: RTFM comes first, not JFGI.

Anyway, I rewrote the build script to be much more cleaner in a couple of minutes. And it worked.

Build systems are actually a lot of fun once you get the hang of it. A black screen with fast scrolling green text cryptic to everyone else but totally sensible to you is incredibly attractive, no? :)