How to properly make an enable debugging option in configure

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to properly make an enable debugging option in configure

Andy Falanga (afalanga)
I would like to know the "proper" method for adding an "--enable-debug"
option to my build using autotools.  Perhaps what I should call this is
a "best-practice" or something similar.  So, some googling and Autotools
Mythbusters suggests it should be AC_ARG_ENABLE.  So, I put this into my
configure.ac file:

AC_ARG_ENABLE([debug],
      AC_HELP_STRING([--enable-debug],
                     [Additional output from binary and turns off
optimizations]),
      [CXXCPP="${CXXCPP} -DDEBUG"
       CXXFLAGS="${CXXFLAGS} -O0 -ggdb"],
      [CXXCPP=${CXXCPP}
       CXXFLAGS="${CXXFLAGS} -O2 -g"])


However, when I run configure, I get this:

checking how to run the C++ preprocessor...  -DDEBUG
configure: error: in `/home/afalanga/devel/o2archanges':
configure: error: C++ preprocessor " -DDEBUG" fails sanity check
See `config.log' for more details

So, I look in config.log but this doesn't really help.  Is there a
better way?  Should I instead make it add "#define DEBUG" in config.h if
"--enable-debug" is provided?  Did I make an incorrect assumption in the
actions arguments to AC_ARG_ENABLE()?  Any help is greatly appreciated.

Andy
Reply | Threaded
Open this post in threaded view
|

Re: How to properly make an enable debugging option in configure

Thomas Dickey-2
On Sat, Feb 13, 2016 at 12:31:51AM +0000, Andy Falanga (afalanga) wrote:

> I would like to know the "proper" method for adding an "--enable-debug"
> option to my build using autotools.  Perhaps what I should call this is
> a "best-practice" or something similar.  So, some googling and Autotools
> Mythbusters suggests it should be AC_ARG_ENABLE.  So, I put this into my
> configure.ac file:
>
> AC_ARG_ENABLE([debug],
>       AC_HELP_STRING([--enable-debug],
>                      [Additional output from binary and turns off
> optimizations]),
>       [CXXCPP="${CXXCPP} -DDEBUG"
CXXCPP doesn't appear to be set at this point, since it does not contribute
to the "checking" message below.

>        CXXFLAGS="${CXXFLAGS} -O0 -ggdb"],
>       [CXXCPP=${CXXCPP}
>        CXXFLAGS="${CXXFLAGS} -O2 -g"])

By the way, it's a common convention to put preprocessor options in
the CPPFLAGS variable, leaving CXXFLAGS for compiler options.
 

> However, when I run configure, I get this:
>
> checking how to run the C++ preprocessor...  -DDEBUG
> configure: error: in `/home/afalanga/devel/o2archanges':
> configure: error: C++ preprocessor " -DDEBUG" fails sanity check
> See `config.log' for more details
>
> So, I look in config.log but this doesn't really help.  Is there a
> better way?  Should I instead make it add "#define DEBUG" in config.h if
> "--enable-debug" is provided?  Did I make an incorrect assumption in the
> actions arguments to AC_ARG_ENABLE()?  Any help is greatly appreciated.
>
> Andy
--
Thomas E. Dickey <[hidden email]>
http://invisible-island.net
ftp://invisible-island.net

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to properly make an enable debugging option in configure

Andy Falanga (afalanga)
On 02/12/2016 06:06 PM, Thomas Dickey wrote:

> On Sat, Feb 13, 2016 at 12:31:51AM +0000, Andy Falanga (afalanga) wrote:
>> I would like to know the "proper" method for adding an "--enable-debug"
>> option to my build using autotools.  Perhaps what I should call this is
>> a "best-practice" or something similar.  So, some googling and Autotools
>> Mythbusters suggests it should be AC_ARG_ENABLE.  So, I put this into my
>> configure.ac file:
>>
>> AC_ARG_ENABLE([debug],
>>        AC_HELP_STRING([--enable-debug],
>>                       [Additional output from binary and turns off
>> optimizations]),
>>        [CXXCPP="${CXXCPP} -DDEBUG"
> CXXCPP doesn't appear to be set at this point, since it does not contribute
> to the "checking" message below.
>
>>         CXXFLAGS="${CXXFLAGS} -O0 -ggdb"],
>>        [CXXCPP=${CXXCPP}
>>         CXXFLAGS="${CXXFLAGS} -O2 -g"])
> By the way, it's a common convention to put preprocessor options in
> the CPPFLAGS variable, leaving CXXFLAGS for compiler options.
Right.  I thought CXXCPP was for C++ Preprocessor options.  It doesn't
matter much to me to to use CPPFLAGS instead.

Sorry for the late reply.