Slashdot Mirror


Autotools

Muad writes "John Calcote is a senior software engineer in Novell's Linux business, who after slogging up the steep learning curve the Autotools triad poses to those packaging software according to the portable GNU conventions for the first time, very kindly decided to make the experience easier to newcomers by sharing his years of experience and carefully crafted bag of tricks. His book is a welcome update to a field that has not seen entries now for a full ten years, so long has been the time since GNU Autoconf, Automake, and Libtool by Gary V. Vaughn, Ben Ellison, Tom Tromey, and Ian Lance Taylor hit the shelves. Unfortunately, the publishing industry is driven by the need to turn a profit to fund its endeavors, and specialist items like this book are not obvious candidates for volume selling - which is a credit to No Starch Press' willingness to venture down this path." Keep reading for the rest of Federico's review. Autotools: A practitioner's guide to GNU Autoconf, Automake, and Libtool author John Calcote pages 360 publisher No Starch Press rating 8/10 reviewer Federico Lucifredi ISBN 1593272065 summary Teaches how to master the Autotools build system to maximize your software The book opens with John's experiences in adopting the Autotools, and quickly offers what is in my view a very important word of caution that is often lacking in the few tutorials I have seen on the Net: the Autotools are not simply a set of tools but foremost the encoded embodiment of a set of practices and expectations in the way software should be packaged the GNU way. While it is acceptable for beginners not to know what these expectations are, the right frame of mind to approach the Autotools is to focus on learning what way the Autotools operate, what they are trying to accomplish, and why. Attempting to use the Autotools without understanding the bigger picture will lead to very high amounts of pain, as it is one of the toolsets most difficult to adapt for use separate from the policies they represent, so strongly are these conventions embedded in their fabric. With this understanding, it becomes possible to generate extensive configurations with a few lines of Autoconf or Automake - without this understanding, it very quickly becomes a battle to force a round peg into a square tool.

John's style is more extensive and takes a longer path to the "technical meat" of the problem than the 10-year old alternative, but in this reader's opinion it flows significantly better as there is an underlying story, a thread that connects the bits of what is otherwise a pretty arid subject. For those masters of shell-fu, this book is a page-turner, while for mere mortals it is a good, approachable, path into a difficult skill.

The book is structured around the packaging of two different projects, the first being a simplified "Hello, World" project to provide a digestible introduction to the processes and technology of the Autotools, while the second representing the full-blown packaging of a complex, real-world project (the FLAIM high-performance database). This is a very good approach, breaking the theory into many practical examples of practice, and providing many ready-made bits that the rest of us can start our own configuration build files from. The result is a first half providing a gentler, streamlined introduction to the subject matter, before the full jump into the gory details of the most complex possibilities the toolset offers. While it must be noted that John attempts to keep away from those most fine details which "may be subject to change" between minor releases of the tooling, which is doubtlessly good for both our scripts' and the book's shelf life, it must be observed that he does not shy away from very dense (and otherwise utterly undocumented) material, such as the use of M4 macros in Autoconf, something a colleague of mine once pointed to me as "the one more reason I'd rather chew broken glass than deal with Autotools".

Assuming you have the requisite knowledge of Make, Shell scripting (particularly Bash), and GCC that are essential to a developer, packager, maintainer or buildmaster of a Linux, BSD or *NIX project, or that you are on your way to achieving those skills, this is a book that belongs in your shelf, right next to the RPM documentation. This is material for experts or experts in the making, but in my opinion you will find no better introduction to this complex subject. I had it on my wish list well before it was ever printed, and its presence on my desk caused several other developers in my office to order their copies pretty much on the spot upon finding out of its existence. Either as a learning tool for a skill you are trying to attain, or as a reference to turn to when faced with the complexities of this unique set of tools, this book is well worth its price tag.

I certainly hope this is not the last publication we see on the Autotools in this decade, but either way, it is a good start indeed - and my hope is that the publisher will refresh the title when an update is warranted, without waiting ten years!

Federico Lucifredi is the maintainer of man (1) and a Product Manager for the SUSE Linux Enterprise and openSUSE distributions.

You can purchase Autotools: A practitioner's guide to GNU Autoconf, Automake, and Libtool from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

29 of 148 comments (clear)

  1. Autotools do not need a book by koinu · · Score: 5, Insightful

    ... they should be replaced by something else.

    1. Re:Autotools do not need a book by Urban+Garlic · · Score: 5, Interesting

      I often need to install software in an environment that's different from where it's going to be run, e.g. I install it on a file server, where the target directory is /export/apps/stow/, and then I use "stow" to put it in /export/apps, which clients mount as /usr/site, so they see "/usr/site/bin/", and are set up to look in /usr/site/lib for libraries, and so forth.

      I don't know if this is instrinsic to newer build schemes or not, but my recent experience has been that "old-style" (autotools-based) packages work just fine, they interoperate well with stow, accept the "--prefix" argument to configure, and work just fine for the clients. Cmake-based packages tend to hard-code path names into start-up scripts, which then break on the clients, which view the app in a different hierarchy -- they don't have /export, in particular.

      Now, it may well be that these are badly-written cmake scripts, and cmake is perfectly capable of doing it right, I honestly don't know. But it seems to me that cmake (and Python's easy-install, and every other new build scheme I've run across in the past few years) are all part of a new generation of tools which really want the build-time and run-time environments to be the same, because they're built around the "single-user isolated workstation" model.

      But it's not true. Lots of us still have centralized file servers that use NFS exports to make centrally-managed Linux applications available to many clients. The new tools make some things easier, but this, they make harder.

      Also, uphill through the snow both ways, and we liked it, get off my lawn, kids today don't know nothin', no respect I tell you.

      --
      2*3*3*3*3*11*251
    2. Re:Autotools do not need a book by GooberToo · · Score: 3, Informative

      I've run into the same problem with cmake. I don't really have that problem with python tools as python's virtual environment tools seem to handle things nicely. Tools such as pip natively handle virtual environments, automatically installing into it when one is active.

      Also, there are lots of nice wrappers to work with python's tools, for developers, such as gogo.

    3. Re:Autotools do not need a book by samjam · · Score: 2, Insightful

      If that were true you wouldn't have needed to say it

    4. Re:Autotools do not need a book by TheRaven64 · · Score: 3, Funny

      I've looked at cmake, and it seems like a really nice solution. When I work out what the corresponding problem is, I have no doubt I will use it.

      --
      I am TheRaven on Soylent News
    5. Re:Autotools do not need a book by Anonymous Coward · · Score: 2, Insightful

      "Now, it may well be that these are badly-written cmake scripts, and cmake is perfectly capable of doing it right"

      The critics about the book make a point about "the Autotools are not simply a set of tools but foremost the encoded embodiment of a set of practices and expectations in the way software should be packaged the GNU way".

      It's not that cmake can or can't be properly used in order to provide a platform-independent prebuild environment but it lacks the grayback experience. As the old motto says, "those who don't understand UNIX are condemned to reinvent it, poorly". Unix-zen, once "the cool wave" is about 40 years old now. New generations feel they know better than the old farts (and many times, they are right) and that they can do it better and simpler... just because they are not (still) aware of the whole landscape and its corner-cases. So, yes, they might re-implement the old farts' tools better and simpler (after all, they have the advantage of building of top on the shoulders of giants, so to say) but, at the same time, they are condemned to fail on the same stepstones their olders managed to workaround just because they choose to ignore them, and then add their own package of failures.

      "But it seems to me that cmake (and Python's easy-install, and every other new build scheme I've run across in the past few years) are all part of a new generation of tools which really want the build-time and run-time environments to be the same, because they're built around the "single-user isolated workstation" model."

      Young is always proud and think to know better than anybody else. They just produce tools for what they know and they choose to ignore everything else. No wonder they fail on things that would seem trivial for older people that already had to fight with them years ago.

      This is the generation of 'reinventing the wheel': they are doing better in some aspects and fail heavily on things that should be known by now.

    6. Re:Autotools do not need a book by JanneM · · Score: 4, Interesting

      I've just recently been in the situation of selecting a build system for a project with an existing codebase. I looked at the obvious alternatives, including cmake.

      In the end, I chose autotools.

      When you're doing a non-trivial project, cmake doesn't become any less complicated than autoconf and automake anymore - if your build is complex, you have to deal with that complexity somewhere after all. And there's a lot more and better resources for using autotools than cmake around, for figuring out odd corner cases. If you have a somewhat odd build requirement, chances are somebody else has already solved it using autotools already.

      From my experience so far, most of what people dislike about using autotools come from Automake. But Automake is of course completely optional to use, and Autoconf - which provides most of the benefits - was made to be standalone. If you have a system with existing makefiles, it makes a lot of sense to simply use Autoconf to configure the app and the makefiles and leave Automake alone.

      This is a lengthy but really illuminating document on using the autotools, that specifically goes through using autoconf alone and on how to adapt an existing project: http://www.freesoftwaremagazine.com/books/agaal/brief_introduction_to_gnu_autotools/

      --
      Trust the Computer. The Computer is your friend.
    7. Re:Autotools do not need a book by Anonymous Coward · · Score: 3, Interesting

      "I don't really have that problem with python tools as python's virtual environment tools seem to handle things nicely. Tools such as pip natively handle virtual environments, automatically installing into it when one is active."

      Which is another aspect of the very same problem. So their solution to ignoring they should seggregate functional development from bug fixing, that they should take API stability as an almost sacred cow is "reinventing" the "static linked environment"?

      Try to install two disparaged tools based on the same shared environment and welcome to the fun of app A asking for 'foo 1.2.3' and app B needing 'foo 1.2.4', so you end up producing a virtual environment for each and every app you install. Good luck then with tracking security advisories for "foo" (and all the other dependencies of each installed app). Good luck with finding an upgrade path that will just fix known security issues without breaking functionality for any of your installed apps.

      But, but, but... you should use the very bleedging edge -the developer of App A will say, without paying attention to the fact that you manage 2000 machines with 150 different main apps from different developers and dates, disregarding even that each of those developers will define "bleeding edge" as "whatever it happens to run in my development box, disregarding if it's really needed or it's stable or it will be supported by my dependecies' developers".

      Ahhh, youngsters... now, you get off my lawn!

    8. Re:Autotools do not need a book by Anonymous Coward · · Score: 2, Funny

      because they are not (still) aware of the whole landscape and its corner-cases

      Youngsters can undervalue knowledge of "the whole landscape and its corner-cases", but old farts can also overvalue it. The beauty of new tools like CMake is that they can leave the past behind, and stop worrying about corner cases on obsolete platforms. At one time I was an absolute expert on MSDOS and Windows 3.1. I leave that off my resume now because it no longer has any practical value, and it just makes me look old :-(

    9. Re:Autotools do not need a book by macshit · · Score: 2, Interesting

      I agree -- autoconf is independent, and does a great job handling system configuration stuff without involving automake -- but I think you're being a bit unfair to automake.

      For projects that "fit" automake, it's actually a wonderful tool, as it allows a highly concise description of the package contents and dependencies, with almost zero fat and overhead, and does pretty much all the typical boilerplate stuff (convenience targets, separate build-directory support, installation, automatic dependency generation, consistency checking, etc) automatically without the user ever having to see the ugly internals. However automake also imposes a degree of structure on a project (not surprisingly, roughly following that of many GNU packages), and is not so flexible if you want something different. For packages that don't follow this structure, or which make particularly complex demands on the build system, automake may not fit very well, and may end up just getting in the way. [It's not entirely inflexible though -- it does try to provide for customization to some degree, and remember, it's essentially a wrapper around makefiles, and will pass through traditional makefile rules largely unscathed.]

      I'd highly recommend trying automake first though, just to see if it works for you, because when it does work, it's really nice.

      From what I've been able to figure out, most people who say they hate the autotools aren't realllly griping about the actual functionality, but rather expressing their distaste at the really grody implementation. It's very true that the implementation details of autotools (a bizarre mixture of m4, bourne-shell, perl, make, etc, all of which are even more ugly that necessary in order to remain portable) is not for the squeamish. However a user of autotools doesn't have to care about the implementation details for the most part -- and from a user's point of view it actually works quite well, and has some very nice features.

      --
      We live, as we dream -- alone....
  2. I suppose it's nice by Vintermann · · Score: 4, Insightful

    I suppose it's nice that someone writes a book like this, since a lot of existing projects use autotools (or more commonly, try to by means of copy/paste and cargo-cult based build scripting).

    But autotools should really be phased out. It solves a lot of problems that aren't problems anymore, and makes a helluva lot of new ones in the process. There are a lot of up and coming build systems to challenge it, and then there's CMake which is an OK compromise between those and practicality.

    --
    xkcd is not in the sudoers file. This incident will be reported.
    1. Re:I suppose it's nice by Entrope · · Score: 4, Interesting

      The autotools suite requires that software developers keep revising things that worked before, because autotools has some new paradigm for some aspect of its operation every year or so.

      For example, one of my open source projects lets the user specify which extra modules should be compiled into the binary. (It doesn't use loadable modules because that was even more painful when we started out.) Over a span of about two years -- and I think three "minor" (1.x) releases of automake -- the approved way of conditionally linking object files changed twice. The changes were not documented, and nobody bothered to describe any way that would work across the several versions of automake that were in common use at the time. In contrast, doing the same thing with autoconf alone or with some non-autotools script is dead simple.

      autoconf has also gotten progressively fussier. For example, simple m4 macro invocations like FOO(bar) used to work fine. Now they often generate a warning that the argument is not quoted properly. To pick one example of prior art, C solved that particular precedence problem about 35 years ago. There is no good reason for autoconf to make the software maintainer throw in all the []s that it wants.

      Those are just a few examples from my experience; others will have more.

    2. Re:I suppose it's nice by DiegoBravo · · Score: 3, Insightful

      > Care to point out what new problems autotools creates?

      Builds that take half an hour just to "configure", checking for the existence of things like strcpy(), but anyway fail at compile or link time because a missing symbol in an upgraded dynamic library?

    3. Re:I suppose it's nice by djm · · Score: 5, Informative

      It's true, pretty much. We developed configure scripts and ways to generate them in the days of 28.8kbps modems and they had to work on Unix System III and Xenix and HP-UX. We couldn't assume anything like Perl or Python was available. Linux distros were only just appearing, and there were no package management systems. Windows was still a 16-bit DOS shell. It was a different world. I'm amazed this stuff has endured as long as it has with so few changes. By the time Automake was written, several years after Autoconf, we at least felt we could assume the presence of Perl.

      Want to know why it's called "Autoconf", which I think is a bit ugly of a name? I wanted to call it "Autoconfig", but when you add a version number and ".tgz" to that, you exceed the 14-character file name limit of some of the Unix variants it had to be downloaded and installed on!

      Dave MacKenzie
      Autoconf's main developer

  3. Let me get this straight: by larry+bagina · · Score: 5, Informative
    A guy from novell/suse is reviewing a book by another guy from novell/suse. When his novell/coworkers see the book at his novell/suse desk, they immediately buy a copy.

    Did I miss any novell/suses?

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  4. Crappy Approach by firewrought · · Score: 2, Insightful

    I understand that adoption/marketing/historical factors may have justified this particular approach to cross-platform builds of C/unix apps, but is this such a big problem that it requires 5-6 languages to solve (counting the syntax of C, sh, configure.ac, Makefile.am, makefile and possibly other intermediate formats)? Sheesh...

    --
    -1, Too Many Layers Of Abstraction
  5. I would rather carve a Makfile into my arm by Bitch-Face+Jones · · Score: 3, Insightful

    with a nail than use autotools

    1. Re:I would rather carve a Makfile into my arm by shutdown+-p+now · · Score: 2, Funny

      I would rather carve a Makfile into my arm with a nail

      I thought that's precisely what autotools is for?? ~

  6. why autotools suck - just google it by af1n · · Score: 5, Interesting

    Poul-Henning Kamp of the Varnish about autotools: "Did you call them autocrap tools ? Yes, in fact I did, because they are the worst possible non-solution to a self-inflicted problem." Read more at: http://www.varnish-cache.org/docs/2.1/phk/autocrap.html

  7. Shallow Learning Curve by the+eric+conspiracy · · Score: 2, Funny

    Shouldn't that be shallow learning curve? Steep would imply quick effortless progress towards expertise (at least if you put the independent variable on the abscissa and dependent on the ordinate as is customary). A shallow learning curve now would imply slow progress...

    1. Re:Shallow Learning Curve by Abcd1234 · · Score: 4, Insightful

      Oh, for the love of jesus, not this again...

      Yes, "learning curve" is a colloquialism that is not, literally, logically consistent. Move on already. Seriously.

    2. Re:Shallow Learning Curve by camperdave · · Score: 3, Informative

      No. When people talk of steep learning curves, the vertical axis is effort, the horizontal axis is expertise. Something with a steep learning curve requires a lot of effort to gain a little expertise. Something with a shallow learning curve requires almost no effort to gain knowledge.

      --
      When our name is on the back of your car, we're behind you all the way!
  8. RE: A not so Crappy Approach by ebuck · · Score: 2, Insightful

    Those who don't understand Automake are doomed to repeat the mistakes of build systems that are not designed like Automake.

    The one language that actually drives all of Automake is ML. Funny it is the one language you didn't list, but you listed a bunch of the high level macro files that get expanded with ML. If you don't know sh, then you shouldn't be programming on the command line (stick to an IDE that does the compilation for you). C isn't required for any component of Automake. If you write a makefile with automake, you made a big mistake, as Automake writes the makefiles for you.

    There are other systems out there which are easier to use, but there's only a handful that does things in a manner that is highly reliable and portable on many platforms. Those that do strive for such goals end up operating like Automake, but often they do so without allowing such easy access to the internal guts of what is really going on.

    Yes, I like cmake too, but bashing Automake just because you don't understand it is just the computer equivalent of name-calling.

  9. Re: A not so Crappy Approach by Waffle+Iron · · Score: 4, Insightful

    Hmmm... are you sure that you didn't mean the macro language M4? I thought that ML was the pure functional ancestor to languages like Haskell.

    Anyway, I played around with M4 a little bit because I thought it looked handy for a few things. It has a deceptively simple specification that only takes a few pages, but it's one of the most extreme examples of "emergent behavior" I've encountered. Even simple tasks rapidly become mind boggling due to the deceptively tricky nature of recursive text substitutions and quoting. It's a real brain teaser of a language. It does seem like it would be a nifty tool if I spent enough time to really figure it out.

  10. CMake by paugq · · Score: 4, Informative

    Obligatory link to a good autotools alternative: CMake. And my CMake tutorial, Learning CMake.

  11. FOR ALL AUTOTOOLS "REPLACEMENTS" by eexaa · · Score: 2, Insightful

    please note that all current 'replacements' are totally wrong and actually work only as puny build systems, not supporting any of the great portability benefits that autotools give. Scons, cmake, whatever else depend on their working installation on _build_ machine. This is wrong, only working shell+make+gcc should be needed to actually build software.

    So...

    Is there ANY good "replacement", preferably lightweight, with this great virtue? As far as I know, there's none.

    1. Re:FOR ALL AUTOTOOLS "REPLACEMENTS" by paugq · · Score: 2, Insightful

      What about Windows (Visual Studio) ? No shell. Incompatible makefiles. What is the answer then?

  12. No amount of documentation ... by Kaz+Kylheku · · Score: 5, Interesting

    can compensate for the low quality of this garbage, not to mention its poor performance (some builds spend more time running configure than actually compiling, installing, and tarring up the resulting run-time and devel packages!)

    These tools have to be redesigned from the ground up by someone who understands that free software has made large inroads into the embedded world where it needs to be, doh, cross-compiled.

    For my own projects, I develop a carefully-crafted configure shell script by hand and recommend everyone do the same.

    The script has carefully developed and tested support for (1) cross-compiling, (2) configuring/building in a separate directory, and (3) installation into a temporary package directory.

    Furthermore, this script should ONLY test the features that are actually needed by the program. (The program should assume a reasonably modern system; don't bother testing for obscure bugs in System V release 3, okay?) The script should make sure that it tests only header files and compiling with the toolchain that it is given. The configure test programs programs should never accidentally include something in the build machine /usr/include, or link something from /usr/lib!

    Configure scripts should never run any program that they compile because it may be the wrong architecture, and they should not have an "if cross compiling" check which disables their features when cross-compiling and substitutes dumb defaults! Quite simply, implement the tests so that cross-compiling is not needed.

    For instance, instead of making a C program which outputs values with printf, make it so that the values are used as initializers for static data. Then use the cross-compiling toolchain's "nm" utility to extract the values from the compiled object file. You don't have to run a program to know how wide a (void *) is. Just do "static char size_of_void_star[sizeof (void *)]". Compile it, and then interrogate the .o to discover what is the content of the size of the data region named by size_of_void_star!

    Look at the stupid configure script for GNU bash. When crossing, it assumes totally pessimistic values for all checks that can't be done when cross-compiling. Unless you explicitly override the ac_* variables yourself, you get a shell which has no job control! The bash build assumes that your kernel has a tty system dating back to the middle 1980's.

    Nobody should dig through a configure script to find out what broken tests they have to override by setting the variables manually.

    Shell code should never be generated by m4 macros, let alone ones which frequently change.

    Look at the stupidity of thisl. Suppose you want to produce a minimal patch for some open source project that uses autoconf. Suppose that as part of your patch you have to enhance the configure script with some new options. To do that, you have to modify configure.in. But projects ship with the generated configure script. So you want to regenerate that, right? Oops, your version of autoconf is different, and so you get a HUGE diff. Worse yet, the generated configure script breaks!

    So people end up with ten different versions of autoconf installed, so they can always run the right one which matches what the configure script was produced with that is in the tarball.

    Build configuration from scratch is not difficult. It is easy. Autotools do not simplify anything. They monstrously complicate something which is already simple and doesn't require simplification or automation. Using the Autotools is a false economy. You may think you are getting something for free and saving time, but in the end you will spend more time over the life of your project wrestling with this garbage (and also waste the time of countless other people you don't even know) than if you just carefully wrote a small configure script by hand.

  13. Re:Cross-platform, but not cross-compiling by wowbagger · · Score: 2, Insightful

    Now, configure something like CORBA targeting a PPC, but configuring on an X86, for compilation on an X86 using a cross compiler.

    Oops - all your structure padding code for the CORBA martialling is broken, because the autoconf scripts all assume they can find out the padding of the structures by emitting a program, building it, running it (whoops! wrong arch!) and getting the output.

    It's all well and good if the program is trivial enough that it does no serious probing of the system, or if the configure host is the same CPU type as the target, but break that, and unless the project's configure script is set up to correctly detect a cross compile, to provide a set of configuration parameters you can provide on the command line to set the variables that would normally be inferred by probing, AND has the wit to refuse to run without you providing those parameters because it detected you are cross compiling, and you will NOT get a running program by default, NOR will you be able to get one without major surgery on the configuration data by hand.