When "-ggdb" is among the CXXFLAGS in the environment, configure will remove the "-g" but leave the "gdb" in place, causing compiler errors. The corresponding line was introduced in r21 of the SVN repository:
CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-g//" -e "s/-O2//"`
As a workaround, you might use this line instead, in order to include any non-space characters following the -g:
CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-g\\S*//" -e "s/-O2//"`
I'm not convinced that manipulating the CXXFLAGS here is a good idea, though. If the user specified CXXFLAGS with debug options, what's the point in removing them again? Configure should imo never try to be more clever than the user calling it. The commit log message doesn't give an indication as to the intention of this line, either.
And even if there is a reason to remove the -g, and even if you apply my patch to address the -ggdb case, there might be strange cases like "-I/usr/lib-gnu" where the -g doesn't have the meaning you expect it to have. So you would need to take whitespace into account as well, and so on. The point I'm trying to make here is that this CXXFLAGS modification is a hack, and you are probably better off removing it than fixing it.
Remove -g including following word
Oh, I forgot to mention, this turned up in a Gentoo bug regarding audacious: https://bugs.gentoo.org/257489
Not audacious, but audacity, version 1.3.7 to be precise. Sorry for this noise. At least the URL is correct.
Drop modification of CXXFLAGS
At least Gentoo decided to completely drop those modifications of CXXFLAGS in order to give the user compiling the package full control over the flags used. Corresponding patch 257489c.patch attached. If there is no really good reason to have the package override flags specified by the user (and I can think of none), I'd prefer that patch to the one I attached before.
From experience I think the "reason" for this hack will be the fact that AC_PROG_CC tends to dribble "-g -O2" if $CFLAGS is blank and it finds GCC. There are however much more robust work-arounds that can be employed to stop this, i.e. saving and restoring the value of CXXFLAGS across the call to AC_PROG.. I have a patch for this in Audacity CVS at http://audacity.cvs.sourceforge.net/viewvc/\*checkout*/audacity/lib-src/sbsms/dont-mangle-cflags.patch