Бях написал свой собствен макрос NA_HELP_STRINGS()
за този вид ситуации:
dnl NA_HELP_STRINGS(list1, help1[, list2, help2[, ... listN, helpN]])
dnl **************************************************************************
dnl
dnl Similar to `AS_HELP_STRING()`, but with support for multiple strings, each
dnl one associated with one or more options
dnl
dnl From: https://github.com/madmurphy/not-autotools
dnl
dnl **************************************************************************
m4_define([NA_HELP_STRINGS],
[m4_if(m4_count($1), [1],
[m4_if([$#], [0], [], [$#], [1],
[m4_text_wrap($1, [ ])],
[AS_HELP_STRING(m4_normalize($1), [$2])m4_if([$#], [2], [], [m4_newline()NA_HELP_STRINGS(m4_shift2($@))])])],
[m4_text_wrap(m4_argn(1, $1)[,], [ ])m4_newline()NA_HELP_STRINGS(m4_dquote(m4_shift($1))m4_if([$#], [1], [], [, m4_shift($@)]))])])
Примерна употреба:
AC_ARG_ENABLE([foo],
[NA_HELP_STRINGS(
[--disable-foo],
[disable the `foo` feature; on some machines the package might not
work properly without the `foo` feature enabled],
[[--enable-foo], [--enable-foo=yes], [--enable-foo=enhanced]],
[install this package with the `foo` feature enabled; if `foo` is
enabled in `enhanced` mode Autoconf might get sentimental],
[[--enable-foo=auto], [--enable-foo=check], [@<:@omitted@:>@]],
[decide automatically whether it is opportune to enable the `foo`
feature on this machine or not]
)],
[:],
[AS_VAR_SET([enable_foo], ['check'])])
Изход, когато потребителят стартира ./configure --help
:
--disable-foo disable the `foo` feature; on some machines the
package might not work properly without the `foo`
feature enabled
--enable-foo,
--enable-foo=yes,
--enable-foo=enhanced install this package with the `foo` feature enabled;
if `foo` is enabled in `enhanced` mode Autoconf
might get sentimental
--enable-foo=auto,
--enable-foo=check,
[omitted] decide automatically whether it is opportune to
enable the `foo` feature on this machine or not
За още m4-ish примери, моля, погледнете Not Autotools проект.
person
madmurphy
schedule
05.12.2019
--enable-foo[=yes] ... [basic description]
- понякога това ме кара да изоставяAS_HELP_STRING
и да използвам ръчен отстъп, за да направя съобщението да изглежда „хубаво“ . - person Brett Hale   schedule 21.08.2015./share/autoconf/m4sugar/m4sh.m4
- и аз продължавам да отлагам изучаването на M4. Това не е грешка, но искане за функция към поддържащите autoconf може да си струва. За съжаление2.7x
е спрян за дълго време. - person Brett Hale   schedule 21.08.2015m4sh.m4
, няма начин да се справи с няколко реда, някакъв начин да го увиете в цикъл? (Разгледах цикъла с m4... оттук и коментара по-горе) - person Alex   schedule 21.08.2015