10

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

dimba
  • 26,717
  • 34
  • 141
  • 196
  • Also see https://stackoverflow.com/questions/4553735/gnu-autotools-debug-release-targets. Not sure if it's a dupe. – sashoalm May 18 '16 at 09:28

2 Answers2

19

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.

dennycrane
  • 2,301
  • 18
  • 15
  • 1
    Remark: Even if you specify the parameters as environment variables (`CFLAGS=-foo ./configure`), they will be saved in `config.status` and correctly passed in when automatic reconfiguration is required. – Jack Kelly Nov 28 '10 at 23:10
  • @Jack Kelly, I always thought that the autoconf manual said somewhere that that is specifically not the case. I can't find it now. Has this been changed? – ptomato Nov 28 '10 at 23:21
  • @ptomato: I just tested with a minimal `configure.ac` and it works, with or without `-C` passed to `configure`. – Jack Kelly Nov 29 '10 at 03:01
1

You could define an alias that automatically sets the environment variables:

alias configuredebug='CPPFLAGS=-DDEBUG CFLAGS="-g -O0" CXXFLAGS="-g -O0" ./configure'

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
Chad A. Davis
  • 321
  • 1
  • 3