Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating debug build of autotools' build 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

like image 478
dimba Avatar asked Nov 28 '10 20:11

dimba


2 Answers

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.

like image 193
dennycrane Avatar answered Oct 28 '22 08:10

dennycrane


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

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

like image 30
Chad A. Davis Avatar answered Oct 28 '22 06:10

Chad A. Davis