Creating debug build of autotools' build source

dimba picture dimba · Nov 28, 2010 · Viewed 6.9k times · Source

Given:

  • source tar.gz
  • AFAIK, configure does support debug build (configure --help doesn't show --enable-debug)

Questions:

  • Is it safe to use debug build if the authors of the package didn't supplied it in the first place?
  • If the answer to pre.v question is yes, than how I can produce debug build? Should I patch configure.ac?

Thanks

Answer

dennycrane picture dennycrane · Nov 28, 2010

A properly crafted Autotools project supports user-supplied compiler and linker flags. Some authors choose to provide --enable-debug to simplify creation of debug builds, but its absence does not mean it cannot be done. The first thing I recommend you try is to specify compiler and linker flags that are suitable to your debugging needs. If you are using gcc on Linux, that could be

./configure CFLAGS="-ggdb3 -O0" CXXFLAGS="-ggdb3 -O0" LDFLAGS="-ggdb3"

It is recommended to specify the variables as parameters to configure, as shown, instead of as environment variables. By doing it this way, the Autotools will keep these settings when you make changes that trigger an automatic reconfiguration.

If that does not produce the desired result, yes, hacking the build system may be necessary.