Autoconf: variable substitution for "configure --help"

I have a string that I want to use multiple times for output configure --help

. So I'm trying to do something like this in configure.ac

:

AC_ARG_ENABLE([foobar],
              AS_HELP_STRING([--enable-foobar], [$foobar_help_str]))

      

But no expansion or substitution is done, so the output is $foobar_help_str

.

+3


source to share


2 answers


Define the string as an M4 macro:



m4_define([FOOBAR_HELP_STR], [Turn on the foobar features])
AC_ARG_ENABLE([foobar], [AS_HELP_STRING([--enable-foobar], FOOBAR_HELP_STR)])

      

+1


source


FYI, if you look at the generated configure

script, you will see that the help text is pre-formatted to one chunk of text in the quoted "document here" (sent to stdout with cat

), i.e. there is no way for any form of replacement at the moment the script is run (i.e. when you run it as ./configure --help

). Surely one could argue that this is a bug, but on the other hand, since the processing done with the help autoconf

text is beautifully printed without any knowledge of how the final script will be executed, and thus without any or ideas what variables can be set and what range of values ​​they can take,autoconf

has no way of knowing how much space is allocated when formatting the help text for any values ​​(values) that any variable might have at runtime.



In cases where only binary options are desired (i.e. when the function is [=ARG]

not used / needed) then it should be possible to write a smart shell macro that will generate the appropriate help text based on the default value if this is the default by itself is defined as an M4 macro in a similar manner to what was suggested in the accepted answer .

+1


source







All Articles