AS_HELP_STRING 多行

AS_HELP_STRING multiple lines

有没有办法让AS_HELP_STRING(或者有一些替​​代宏)很好地格式化多行帮助?

我有一个 --enable-option=,它可能有多个值 val1,val2,...,我想 configure --help 为每个值显示一个帮助行。

我已经为这种情况编写了自己的 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],
        [m4_if([$#], [0], [], [$#], [1],
            [m4_text_wrap(, [  ])],
            [AS_HELP_STRING(m4_normalize(), [])m4_if([$#], [2], [], [m4_newline()NA_HELP_STRINGS(m4_shift2($@))])])],
        [m4_text_wrap(m4_argn(1, )[,], [  ])m4_newline()NA_HELP_STRINGS(m4_dquote(m4_shift())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 项目。