Slashdot Mirror


Debugging Configure

An anonymous reader writes "All too often, checking the README of a package yields only the none-too-specific "Build Instructions: Run configure, then run make." But what about when that doesn't work? In this article, the author discusses what to do when an automatic configuration script doesn't work -- and what you can do as a developer to keep failures to a minimum. After all, if your build process doesn't work, users are just as badly off as if your program doesn't work once it's built."

24 of 72 comments (clear)

  1. Debugging configure by mopslik · · Score: 4, Funny

    ...what to do when an automatic configuration script doesn't work.

    I've written a little program that debugs configure automatically. To compile my program, simply run configure, then run ... oh, wait. Never mind.

    1. Re:Debugging configure by jamsho · · Score: 2, Interesting

      If configure fails the first thing to do is rm -R <the sources dir>, unpack sources and try again.... this can clean up some bugs involving the temporary files and the cache configure creates when it's run.... especially if you've run configure inside that source tree before.

      Infact I NEVER run configure in the same source tree twice (still smarting after bitter 2 days debugging experience that got resolved by doing exactly the above ... :)

    2. Re:Debugging configure by ffsnjb · · Score: 2, Informative

      'make clean' better trash the configure cache files, or someone didn't write their make files correctly. I've been using the same source trees for apache, postfix, ssh.com's ssh2, and bind for years, along with FreeBSD stable sources. Never once have I had a configure problem that 'make clean' didn't resolve.

      --
      "Why do you consent to live in ignorance and fear?" - Bad Religion
  2. You talk to the developer by samjam · · Score: 3, Insightful

    You send configure.log and the failure message to the developers, who hopefully understand autoconf a bit more and why it failed.

    Some projects you can't find the developers, then its time to learn how autoconf works and read the autoconf mailing lists and work out what test failed and why.

    Most tests fail because
    * some required feature is not supported on your platform,
    * or because the configure script is old and autoconf has been updated

    The latter is sadly quite common in badly maintained projects as autoconf has undergone revisions and badly written autoconf definitions have started failing.

    If your platform lacks a feature you write around it for your platform with "ifdefs" which get activiated according the the test failure. I dont know how to do this, fortunatly for me all my projects have been working under people who understand autoconf quite well.

    Sam

    1. Re:You talk to the developer by GigsVT · · Score: 2, Interesting

      Well the danger with that, is the authors being deluged by people who just don't have the right dependancies installed.

      Of course, it could be considered a bug if the configure script fails silently or ambiguously just because a dependancy was missing, but I see it a lot.

      It'd really help if the authors would put very verbose missing dependancy messages, even as far as including a URL for the dependancies, if they aren't common.

      One build that comes to mind that was total hell was Flightgear. That thing has dependancies all over the place, and not common things either.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    2. Re:You talk to the developer by anthony_dipierro · · Score: 3, Insightful

      First I always put the last line or two of error messages into google. 8 times out of 10, I find someone asking the same question, and usually someone has already posted an answer.

      Actually, before even that I check with Linux From Scratch (and Beyond LFS). But there are a whole lot of packages they don't cover.

  3. I find configure quite useful by neglige · · Score: 2, Informative

    Personally, I like configure. Editing Makefiles (or Imakefiles if you are lucky) is often like "reading core dumps", as someone put it. Maybe it depends on which system you run (Linux in x86 is probably mainstream and well tested). The automated configure process only failed my once, where the created script was about testing one feature but failed on another issue. Reading the log (as suggested by the author) solved the case. Plus, most problems arise after a system update, when some files/dev-packages/stuff are still missing. Once you get an application successfully through configure, similar apps should work as well.

    It's still better to see something like "Testing for SSL... failed" than go "Can't locate libmcop_mt.so -- Huh? What child is this? Let's google..."

    And if all else failes, remove the problematic code in configure, make, make install && pray ;)

    --
    My cats ate my karma. They also wrote this comment.
    1. Re:I find configure quite useful by cperciva · · Score: 3, Insightful

      Editing Makefiles (or Imakefiles if you are lucky) is often like "reading core dumps", as someone put it.

      Makefiles are often poorly written. In particular, people very often fail to use .include directives properly.

      If you want to see well-written Makefiles, look in the BSD source tree. Taking one at random, here's FreeBSD's src/usr.sbin/edquota/Makefile:

      # @(#)Makefile 8.1 (Berkeley) 6/6/93
      # $FreeBSD: /repoman/r/ncvs/src/usr.sbin/edquota/Makefile,v 1.8 2003/04/04 17:49:13 obrien Exp $

      PROG= edquota
      MAN= edquota.8

      WARNS?= 4

      .include <bsd.prog.mk>

    2. Re:I find configure quite useful by juhaz · · Score: 2, Insightful

      That may be simple and well written, but it only needs to compile on FreeBSD.

      What if you have a package that has to work on FreeBSD AND OpenBSD AND Linux AND bazillion other unixes AND win32/cygwin AND win32/mingw AND .... gazillion other os/library/whatever combinations.

      It won't be that simple any more, and at that point it's probably impossible to "write well" as well.

  4. Ports by cperciva · · Score: 4, Insightful

    Rather than attempting to include support for every architecture via autoconf, I think the BSD ports approach is far superior: Write code once, and have people put together their own sets of patches, makefile wrappers, et cetera to fit their own architecture.

    For example, I wrote my binary patching tool on FreeBSD, but I don't recommend that people (even on FreeBSD) build it directly from the source tarball; instead, I advise people to use the ports tree, since that puts BSDiff into FreeBSD's packaging system. If someone running Gentoo wants to use BSDiff, they can install it from portage, which adds workarounds for gmake and linux breakage.

    Most developers only have access to a couple platforms for testing their code. Rather than doing a poor job of supporting every platform, it makes much more sense to support one platform directly, and allow other people to step in and provide the necessary patches and packaging to support other platforms.

    1. Re:Ports by bogado · · Score: 2, Informative

      I think that this is the easy way out, this way the author of the original code can simply ignore the other plataforms. I think that the author should be consient that other plataforms do exists and he should actively try to separate code that is plataform dependent into separate files or libs. And learning autoconf do help to learn where the pifalls are.

      Said that, I do agree that a good autoconf configuration is very hard to acomplish, mainly when you doing it for the first time.

      --
      []'s Victor Bogado da Silva Lins

      ^[:wq

    2. Re:Ports by Anonymous Coward · · Score: 2, Interesting

      Ah, an interesting example. You see, I recently tried to evaluate your BSDiff program. Not only could I not build it, I couldn't even figure out how to modify it to make it build - because you haven't even tried to write portable code.

      For example, you rely on BSD make. That makes some sense for a BSD project, of course. But BSD make is not available on Cygwin. If you don't want to use the more widely available GNU make and its extensions, you could at least restrict your makefile to the subset of constructs that all make utilities support.

      In short, I'm sticking with the portable binary diff utility, xdelta. I'm sure BSDiff is as much better as you claim, but as I can't use it, that's not much good to me, is it?

    3. Re:Ports by aminorex · · Score: 2, Informative

      Supporting GNU make is laudable because it is
      by far the most portable and ubiquitous build
      system in the world.

      Portability is laudable because it allows
      people to use your code.

      If using GNU make could be a barrier to the
      adoption of your code, that might be a reason
      not to use it, but the license of GNU make
      doesn't have any obvious bearing on the
      usability of your application which is built
      by its mechanisms.

      --
      -I like my women like I like my tea: green-
  5. Autoheadache by dmelomed · · Score: 2, Insightful

    "aid that, I do agree that a good autoconf configuration is very hard to acomplish, mainly when you doing it for the first time."

    If autoconf is so problematic and PITA, why use it in the first place?
    autoconf/make is more trouble than it's worth. Portable makefiles and small portability test programs is the right way to do it.

    Some people just don't value complexity enough. These tools are needlessly complex. This page has more info: http://www.ohse.de/uwe/articles/aal.html

  6. The webpage missed a major resource by devphil · · Score: 4, Informative


    The GNU Autotools have their own published book, the electronic edition of which is online. This doesn't seem to be listed in the resources at the end of the article.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  7. Backwards by devphil · · Score: 4, Informative
    Rather than attempting to include support for every architecture via autoconf,
    [...]
    Rather than doing a poor job of supporting every platform, it makes much more sense to support one platform directly,

    That's exactly how autoconf doesn't work. "Including support for every architecture" is how previous build systems worked, like xmake. Those were an unmitigated disaster.

    Automake's goal is to allow the build system to adapt itself to whatever system happens to be available. It does not look at the OS and say, hey, I'm on Solaris, bring out these hardcoded settings. Instead it performs tests for each feature of interest -- where is the compiler? where are the SSL libraries? what's the exact function signature for this not-quite-standard-C subroutine? If your system has been customized from the factory default, so to speak, then hardcoded answers will be wrong, no matter how dilligently those porting people were in originally deriving them.

    The idea is to have configure discover whatever the correct answers are, and set variables appropriately so that you don't have to care about the differences -- you can write the code once, as you say, and let the automatics do the necessary adjustments, rather than other people. Assume you're running on a POSIX system, for example, and let configure #define things as necessary to make up for the non-POSIX systems.

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
    1. Re:Backwards by aminorex · · Score: 2, Insightful

      And you're saying that automake is NOT an
      unmitigated disaster?

      In my view any project that needs to resort
      to automake in order to configure the build
      environment has already failed. It has failed
      to deliver a portable Makefile, and failed to
      deliver portable application source code,
      and tried to work around that failure after
      the fact by patching it with automake.

      --
      -I like my women like I like my tea: green-
    2. Re:Backwards by devphil · · Score: 3, Insightful
      And you're saying that automake is NOT an unmitigated disaster?

      Huh? When did this switch from autoconf to automake? Okay, sure, I'll play. I think automake is a fine tool.

      In my view any project that needs to resort to automake in order to configure the build environment

      Your view is wrong, since that's not what automake is for. That's autoconf's job.

      It has failed to deliver a portable Makefile,

      Here you're clearly talking out of your ass. Go look at a generated Makefile.in. It's whole purpose in life is to be more portable than any hand-written makefile could ever be. Go ahead, try to implement the same complicated, real-world-necessary rule patterns yourself, without resorting to a nonportable feature of GNU make, or BSD make, or Sun make, or...

      The point is to save typing during the input (Makefile.am) and yet keep the output (Makefile.in/Makefile) utterly portable. And it succeeds admirably. What, you'd rather force everyone to maintain hundreds of lines of makefile by hand?

      and failed to deliver portable application source code,

      What the fuck does that have to do with the makefile? Or the build system? This is a red herring, and a specious argument.

      and tried to work around that failure after the fact by patching it with automake.

      ...a tool which, in fact, does not actually patch any files. Brilliant argument there, buddy. Perhaps you should pay attention to which tool does what.

      Feh. Go back to your hand-written tedious makefiles. I'll stick with tiny free-form automake files. And add you to my /. killfile.

      --
      You cannot apply a technological solution to a sociological problem. (Edwards' Law)
    3. Re:Backwards by bazongis · · Score: 2, Insightful

      I so totally agree with the parent post like I've never agreed with a slashdot post before ;)

      Sure, for small and simple programs you can resort to hand-crafted Makefiles and just skip all that autofoo business, no question.

      But once you bring stuff like multiple libraries (even if it's just no-install static libraries) or conditional compilation (enable/disable features that rely on certain libraries for example) into the equation, you'll have an extremely hard time getting this right on most platforms with a hand-crafted Makefile.

      Not to mention different versions of the tools required on one and the same platform.

      Also, let's not forget that most developers do not have 15 boxes with different architectures/OSes to play around with at home. If you have the expertise and know about all those different platforms and operating systems and their respective quirks, you sure have my respect. I don't think that's particularly common though.

      I really don't understand why everyone is complaining about the autofoo suite. It works great most of the time, and when it fails, it usually fails in known ways.

    4. Re:Backwards by Brandybuck · · Score: 2, Insightful

      You're both right and wrong.

      You're right in that xmake and similar systems didn't work well. You're right in that an automatic configuration system should query for capabilities.

      But you're wrong in that autoconf/automake is the answer. I tried to build some software yesterday and I got the error that I wasn't using the correct version of automake. WTF! When the specific versions of automake/autoconf are themselves configuration variables, something's seriously wrong.

      --
      Don't blame me, I didn't vote for either of them!
  8. Re:configure.in parsing by Anonymous Coward · · Score: 2, Interesting

    Would it be possible to have a program that read configure.in files directly, worked out what they were testing for etc, and just returned the right values?

    This is what the pre-make-kit project (http://pmk.sf.net) is trying do to. The project aims to provide an alternative to autoconf. You should have a look.

  9. tips and tricks by devphil · · Score: 4, Interesting


    The "code for checking" is all just a bunch of macros. Believe me, the slowdown you see isn't the shell reading a bunch of lines of text.

    Some points that might speed things up:

    • Some shells suck. The generated configure is designed to not require any modern shell features (in case you run it on some ancient piece of crap), so you can use whatever stripped-down streamlined implementation of Bourne shell you want. (Assuming the developers of whatever package you're installing haven't used such features themselves, and most don't, for the same reasons that autoconf recommends.)
    • Some shells really suck. Under Solaris and AIX, for example, /bin/sh is such a flaming piece of shit that people running non-trivial configures are advised to run configure with a different shell.
    • If you're getting the same results for commonly-used tests, strip them out of the generated cache, keep the cache around, and when you go to run a new package, preload the cache. (Can be tricky, but is usually safe. Just cache the safe stuff like, "checking if CPU is on fire... no".
    • On recent Linux systems, a big slowdown is the part at the very end, when files like Makefile and config.h are being created. These are basically huge sed operations. Recent versions of sed and glibc have really taken a performance hit in this area. (Depends on your distro. Some sed's are compiled with their own regex engine, some use glibc's. There're more details, but I'm pressed for time.) You might try timing the last part (running config.status over and over to get an average time), then putting a different sed in your PATH and trying again. I found old versions of "ssed" to really kick ass.
    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  10. Re:least favourite thing to have to change is... by anarxia · · Score: 2, Insightful

    Headers under include/linux are not guaranteed to work between kernel versions and that's why they need to be avoided. In fact it is not recommended to use them (except if you are libc). The headers are under include/linux because they ARE linux kernel headers and not because somebody wanted to break compatibility with BSD.

    For example, the joystick interface used to be pretty much the same as BSD (linux 2.0 era) but not anymore (the new interface is much better but that's another story). If linux used machine/joystick.h it would give the illusion of a uniform interface between linux and BSD but this is not always the case.

    Any application using linux or machine headers should either make them optional (at the expence of some functionality or performance) or stop claiming portability.

  11. Huh? by devphil · · Score: 2, Insightful
    "aid that, I do agree that a good autoconf configuration is very hard to acomplish, mainly when you doing it for the first time."

    I don't know of any aspect of computer programming that's both non-trivial and easy to accomplish, when you're going it for the first time.

    If autoconf is so problematic and PITA, why use it in the first place? autoconf/make is more trouble than it's worth.

    You know, I've never had that much trouble with it. I've never had more trouble than doing it by hand would have given me.

    I've certainly never found a different system that saves me more time while maintaining the degree of portability required for most of our projects. I'm sure if we decided that "all the world's a PC," or even "all the world runs Linux," we could do it by hand, but that's not good enough.

    Portable makefiles and small portability test programs is the right way to do it.

    I couldn't agree more. That's why I use a generator of insanely portable makefiles (it's a tool called automake), and a tool which creates and runs small portability test programs (it's called autoconf).

    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)