Alex
Alex

Reputation: 3454

AS_HELP_STRING multiple lines

Is there a way to get AS_HELP_STRING (or there's some alternative macro) to nicely format help on multiple lines?

I've an --enable-option= which may take multiple values val1,val2,... and I'd like configure --help to show one help line for each value.

Upvotes: 3

Views: 549

Answers (1)

madmurphy
madmurphy

Reputation: 1821

I had written my own NA_HELP_STRINGS() macro for this kind of situations:

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($@)]))])])

Sample usage:

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'])])

Output when the user launches ./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

For more m4-ish examples please have a look at the Not Autotools project.

Upvotes: 2

Related Questions