Next: , Previous: Package Options, Up: Site Configuration


12.3 Making Your Help Strings Look Pretty

Properly formatting the `help strings' which are used in AC_ARG_WITH (see External Software) and AC_ARG_ENABLE (see Package Options) can be challenging. Specifically, you want your own `help strings' to line up in the appropriate columns of `configure --help' just like the standard Autoconf `help strings' do. This is the purpose of the AS_HELP_STRING macro.

— Macro: AS_HELP_STRING (left-hand-side, right-hand-side)

Expands into an help string that looks pretty when the user executes `configure --help'. It is typically used in AC_ARG_WITH (see External Software) or AC_ARG_ENABLE (see Package Options). The following example will make this clearer.

          AC_DEFUN([TEST_MACRO],
          [AC_ARG_WITH([foo],
                       AS_HELP_STRING([--with-foo],
                                      [use foo (default is NO)]),
                       [ac_cv_use_foo=$withval], [ac_cv_use_foo=no])
          AC_CACHE_CHECK([whether to use foo],
                         [ac_cv_use_foo], [ac_cv_use_foo=no])])
     

Please note that the call to AS_HELP_STRING is unquoted. Then the last few lines of `configure --help' will appear like this:

          --enable and --with options recognized:
            --with-foo              use foo (default is NO)
     

The AS_HELP_STRING macro is particularly helpful when the left-hand-side and/or right-hand-side are composed of macro arguments, as shown in the following example.

          AC_DEFUN(MY_ARG_WITH,
          [AC_ARG_WITH([$1],
                       AS_HELP_STRING([--with-$1], [use $1 (default is $2)]),
                       ac_cv_use_$1=$withval, ac_cv_use_$1=no),
          AC_CACHE_CHECK(whether to use $1, ac_cv_use_$1, ac_cv_use_$1=$2)])