16

So a couple years back I took some time to grok make, and it's paid off enormously. Writing little makefiles for building my projects and automating tasks is fun and productive.

The downside is, of course, that my makefiles are overspecific, especially when it comes to platforms and library locations.

So this is the point at which people tell me "autotools to the rescue!" And they certainly seem to do the trick when other people do them (I love downloading something and running configure && make && sudo make install and watching it just work), but I can't wrap my head around them.

I've looked in some configure.ac and Makefile.am files, and I just don't understand what's going on. I don't know what part of identifiers is developer's choice, and what part is meaningful to the autotools. I'm not sure I understand the entire flow and the point of Makefile.in. I think I'm just hitting a mental wall going from the system I'm used to (make) to something that's a layer or two above that.

Can anyone point me towards a tutorial or book (preferably not an overly dry one) that can teach me the joy of autotools? What the steps are, and how I can use them, how I can write my own configure.ac and Makefile.am from scratch? Show me how to be effective and have fun with them?

rekire
  • 47,260
  • 30
  • 167
  • 264
rampion
  • 87,131
  • 49
  • 199
  • 315
  • 2
    Doesn't really answer your question, but you may want to consider cmake as well. I found it to be much simpler to work with than the usual autotools. – Evan Teran Jul 08 '10 at 21:34
  • 9
    You, as a user, learned the joy of autotools. Now you're going to learn it's pains :) – Vitor Py Jul 08 '10 at 21:37
  • 1
    I really can acknowledge the comments from @Evan Teran and @Vitor Py. The autotools (especially when they come together with libtool) does have a tendency to cause lots of pain. Here in the company we are currently move away from autotools to cmake, without regret. – Rudi Jul 09 '10 at 07:32
  • 8
    I'm getting tired of all this autotools bashing. I suspect that people who hate autotools are really using the wrong tool for the job. The autotools are meant to make it easy to implement the GNU coding standards and building conventions. They're not meant for you to implement whatever arbitrary workflow you want; if you try to do that, then yes, you will be just as unhappy as if you tried to fasten a screw using a hammer. By all means use Cmake if the GNU conventions are not what you want. – ptomato Jul 09 '10 at 09:48
  • 4
    Completely agree with @ptomato. People like to hate on the autotools, but CMake is worse. Shinier for the user, but worse. One feature that particularly stands out is its braindead concept of lists as semicolon-delimited strings. This causes (for instance) the `PKG_CHECK_MODULES` macro to fail spectacularly if the `.pc` file dares to declare more than one compiler or linker flag. The semicolon makes its way into the command-line, and kaboom! – Jack Kelly Sep 15 '10 at 01:54
  • 2
    Is the title of the question an intentional pun of a better known book by a similar name? Really I think there is no joy at all, and not one alike to that being alluded to. Perhaps you mean Misery of Autotools, which could equally parallel Misery of Celibacy or something similar? – Matt Joiner Sep 15 '10 at 13:12
  • 3
    @Matt Joiner, you mean the _Joy of Cooking_? ;-) – ptomato Nov 29 '10 at 11:09

2 Answers2

10

I am not sure you can have fun with build systems... Have you been reading the Autotools Tutorial?

http://www.lrde.epita.fr/~adl/autotools.html

There are various resources about autotools, the problem is they tend to be incomplete, a bit outdated etc...

One recent and excellent document is Autotools Mythbuster, although it's not an introduction:

http://www.flameeyes.eu/autotools-mythbuster/index.html

elmarco
  • 31,633
  • 21
  • 64
  • 68
  • 2
    +1 for the links, thanks! But I hope you're wrong about your initial claim. With programming (and any sufficiently complex build system is programming), I often think if you're not having fun, you're doing it wrong. This may be the same tendency that leads programmers to prefer the most complex solution when a simple one will do, but that seems to be a vote for moderation more than anything else. – rampion Jul 09 '10 at 00:11
  • 1
    The most enlightening section of the Autotools Tutorial for me was the diagram of which files are used to generate which other files, and what they're all meant to do. That was the moment I understood the Joy of Autotools, and stopped seeing them as voodoo. – ptomato Jul 09 '10 at 09:50
  • 1
    I very much second the mention of Alexandre Duret-Lutz's Autotools Tutorial (the first aforementioned link). For a time investment of just an hour or two of working your way through his excellent slide set, you'll learn enough of Autotools to get by for most use cases. – Arto Bendiken Nov 29 '10 at 10:15
7

Although I consider Alexandre Duret-Lutz's Autotools Tutorial, mentioned in elmarco's answer, to be the very best available, you should also know about the Goat Book:

http://sourceware.org/autobook/

The versions of the tools it deals with are rather old, but it's a nice introduction and it's presented in a logical order. It's also more complete than the Tutorial. It is perhaps best used as supplementary reading after you've worked through the Tutorial.

UPDATE There's also John Calcote's book, it was published around August 2010 and it's really good. I'm not sure whether the whole book is online at that link, but at least part of it is.

ptomato
  • 56,175
  • 13
  • 112
  • 165