Autotools Mythbuster: automagically disabled dependencies

One question that I’ve been asked before, and to which I didn’t really have a good answer up to now is: should configure scripts fail, when a dependency is enabled explicitly, but it can’t be found? This is the automagic dependency problem, but on the other branch.

With proper automatic dependencies, if the user does not request explicitly whether to enable something or not, it’s customary that the dependency is checked for, and if found, the feature that it’s connected to is enabled. When the user has no way to opt out from it (which is bad), we call it an automagic dependency. But what happens if the user has requested it and the feature is not available?

Unfortunately, there is no standard for this, and myself I used both the “fail if asked and not found” and “warn if asked and not found” approaches. But the recent trouble between ncurses and freetype made me think that it’s important to actually make a point that there is a correct way to deal with this.

Indeed what happens is that right now, I have no way to tell you all that the tinderbox has found every single failure caused by sys-libs/ncurses[tinfo] even after the whole build completed: it might well be that a particular package, unable to link to ncurses, decided to disable it altogether. The same goes for freetype. Checking for all of that would be nice, but I have honestly no way to do it.

So to make sure that the user gets really what they want, please always make sure that you do verify that you’re proceeding how the user wanted. This makes sure that even in packaging, there won’t be any difference when a dependency is updated, or changed. In particular, with pkg-config, the kind of setup you should have is the following:

  AS_HELP_STRING([--with-foobar], [Enable the features needing foobar library]))

AS_IF([test "x$with_foobar" != "xno"], [
  PKG_CHECK_MODULES([FOOBAR], [foobar >= 123], [
    AC_DEFINE([HAVE_FOOBAR], [1], [Found foobar library])
  ], [
    AS_IF([test "x$with_foobar" = "xyes"], [

I’ll be discussing this and proposing this solution in the next update to Autotools Mythbuster (which is due anytime soon, including the usual eBook update for Kindle users). This would hopefully make sure that in the future, most configure scripts will follow this approach.

3 thoughts on “Autotools Mythbuster: automagically disabled dependencies

  1. That’s not the first public statement of Icaza making you wonder about his sanity.In this case, just look at the example. Somebody runs “” (on a side note, with autoreconf i’d consider “autogen.h” obsolete), so is using autotools himself. Either he has his source tree directly from the VCS, in which case he SHOULD know a little about autotools and m4, or someone thought it would be a good idea to distribute “” (it isn’t, it’s a very bad idea in fact …)So, his example for why he hates pkg.m4 so much is just invalid.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s