On Wednesday 23 March 2005 21:14, Paul Eggert wrote: > > +The following example shows how to use the @code{AC_ARG_WITH} macro in > > +a very common situation. You want to let the user decide whether to > > enable > > Remove "very". > Use English spacing after sentences; i.e., two spaces after the period. > > > +support for an external library (e.g., the readline library); if the > > user +did not specify neither @option{--with-readline} nor > > did not specify -> specified > > > + [support fancy command line editing <default=check>])], > > Defaults should be in square brackets, not angle brackets. Thanks for the suggestions, they are included below. > One more-general comment: there is a lot of duplication here in the > three examples. Can you rewrite it to give just one example, and > then briefly discuss the modifications needed for the other two cases? > That would make it easier to follow. Yes, I thought about it. However, in a way it is justified: the whole point behind this proposal is that there is not a clear indication on the "standard" way to use AC_ARG_WITH. This is not just a teorethical statement, but is reflected in real world situations in a manifold of non-standard uses of that macro that really hurts us distributors, for the reasons discussed previously on this list. I think there's a gain in being as clear as possible when presenting the macro to the user in the autoconf manual, even if there's a bit of redundancy. Anyway, the patch below is just a suggestion. Feel free to take only the bits that you find appropriate for the manual. Gregorio
Index: doc/autoconf.texi =================================================================== RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v retrieving revision 1.884 diff -u -B -r1.884 autoconf.texi --- doc/autoconf.texi 23 Mar 2005 01:01:58 -0000 1.884 +++ doc/autoconf.texi 23 Mar 2005 22:25:00 -0000 @@ -13313,6 +13313,81 @@ You should format your @var{help-string} with the macro @code{AS_HELP_STRING} (@pxref{Pretty Help Strings}). + +The following example shows how to use the @code{AC_ARG_WITH} macro in +a common situation. You want to let the user decide whether to enable +support for an external library (e.g., the readline library); if the user +specified neither @option{--with-readline} nor @option{--without-readline}, +you want to enable support for readline only if the library is available +on the system. + +@c FIXME: Remove AS_IF when the problem of AC_REQUIRE within `if' is solved. +@example +AC_ARG_WITH(readline, + [AS_HELP_STRING(--with-readline, + [support fancy command line editing @@<:@@default=check@@:>@@])], + [], + with_readline=check) + +LIBREADLINE= +AS_IF([test "x$with_readline" != xno], + [AC_CHECK_LIB(readline, main, + [AC_SUBST(LIBREADLINE, "-lreadline -lncurses") + AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE, 1, [Define if you have libreadline]) + ], + [if test "x$with_readline" != xcheck; then + AC_MSG_FAILURE([--with-readline was given, but test for readline failed]) + fi + ], -lncurses)]) +@end example + +The next example shows how to use @code{AC_ARG_WITH} to give the user the +possibility to enable support for the readline library, in case it is still +experimental and not well tested, and is therefore disabled by default. + +@c FIXME: Remove AS_IF when the problem of AC_REQUIRE within `if' is solved. +@example +AC_ARG_WITH(readline, + [AS_HELP_STRING(--with-readline, + [enable experimental support for readline @@<:@@default=disabled@@:>@@])], + [], + with_readline=no) + +LIBREADLINE= +AS_IF([test "x$with_readline" != xno], + [AC_CHECK_LIB(readline, main, + [AC_SUBST(LIBREADLINE, "-lreadline -lncurses") + AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have libreadline]) + ], + [AC_MSG_FAILURE([--with-readline was given, but test for readline failed])], + -lncurses)]) +@end example + +The last example shows how to use @code{AC_ARG_WITH} to give the user the +possibility to disable support for the readline library, given that it is +an important feature and that it should be enabled by default. + +@c FIXME: Remove AS_IF when the problem of AC_REQUIRE within `if' is solved. +@example +AC_ARG_WITH(readline, + [AS_HELP_STRING(--without-readline, + [disable support for readline @@<:@@default=enabled@@:>@@])], + [], + with_readline=yes) + +LIBREADLINE= +AS_IF([test "x$with_readline" != xno], + [AC_CHECK_LIB(readline, main, + [AC_SUBST(LIBREADLINE, "-lreadline -lncurses") + AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have libreadline]) + ], + [AC_MSG_FAILURE([test for readline failed, use --without-readline if you want to force readline support off])], + -lncurses)]) +@end example + +These three examples can be easily adapted to the case where +@code{AC_ARG_ENABLE} should be preferred to @code{AC_ARG_WITH} (see +@ref{Package Options}). @end defmac @defmac AC_WITH (@var{package}, @var{action-if-given}, @ovar{action-if-not-given}) @@ -13383,6 +13458,10 @@ You should format your @var{help-string} with the macro @code{AS_HELP_STRING} (@pxref{Pretty Help Strings}). + +See the examples suggested with the definition of @code{AC_ARG_WITH} +(@pxref{External Software}) to get an idea of possible utilizations of +@code{AC_ARG_ENABLE}. @end defmac @defmac AC_ENABLE (@var{feature}, @var{action-if-given}, @ovar{action-if-not-given})
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf