Non-interactively enabling menuselect debug options

I’m experiencing a segfault in Asterisk 20.6.0 and I’m trying to enable DONT_OPTIMIZE per Getting a Backtrace - Asterisk Documentation. I’m building asterisk non-interactively so the interactive nature of make menuselect is very painful. I’d like to be able to apply these flags so that they can be applied non-interactively to future builds, without needing to interact with a menu system. I found Configuring an Asterisk build from the command line ⋆ Asterisk but this doesn’t seem to work, if I do:

# Build menuselect/menuselect
echo q | make menuselect
# Enable DONT_OPTIMIZE
menuselect/menuselect --enable DONT_OPTIMIZE

the commands succeed but when I manually check by running make menuselect the option is still default disabled. Is there another way to enable the debug flags at the command line that can be run from a script?

Try:

menuselect/menuselect --enable DONT_OPTIMIZE menuselect.makeopts

Perfect, that worked great. Is there a better way to force compilation of menuselect/menuselect than echo q | make menuselect? This method works but launching menuselect just to quit it seems like I’m overlooking a better target. Without running that menuselect/menuselect isn’t present after running configure.

“make menuselect.makeopts” may do it.

That works great. I did notice that after that I’ll get a ncurses error if I run menuselect/menuselect without any args, but I don’t intend to do that in my pipeline so that’s fine. Just documenting for the future.

To document where I ended up here is what I’ve added to my Docker build, between configure and make:

# Enable debugging / error reporting options
# https://www.asterisk.org/configuring-an-asterisk-build-from-the-command-line/
# https://community.asterisk.org/t/non-interactively-enabling-menuselect-debug-options/100727
# DONT_OPTIMIZE: Enabled per https://docs.asterisk.org/Development/Debugging/Getting-a-Backtrace/
# BETTER_BACKTRACES: Enabled as it looks like a useful option
# COMPILE_DOUBLE: Disabled as it "recompile[s] with DONT_OPTIMIZE", which we need off per https://docs.asterisk.org/Development/Debugging/Getting-a-Backtrace/
RUN make menuselect.makeopts && \
    menuselect/menuselect --enable DONT_OPTIMIZE menuselect.makeopts && \
    menuselect/menuselect --enable BETTER_BACKTRACES menuselect.makeopts && \
    menuselect/menuselect --disable COMPILE_DOUBLE menuselect.makeopts

Stopping the build and manually running make menuselect after this step shows the options I expect. Thanks @jcolp for the help.