]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
* lib/autotest/general.m4: Comment various HELP_* diversions.
authorDerek Price <derek@ximbiot.com>
Tue, 19 Aug 2003 18:21:39 +0000 (18:21 +0000)
committerDerek Price <derek@ximbiot.com>
Tue, 19 Aug 2003 18:21:39 +0000 (18:21 +0000)
(PARSE_ARGS_BEGIN): New section for option parsing related
initialization.
(AT_ARG_OPTION,AT_ARG_OPTION_ARG,_AT_ARG_OPTION): New macros to define
package specific options and associated help.

ChangeLog
lib/autotest/general.m4

index ab03144e76092fa1b52e3ba92155b9738564d50d..f68de523593b9343605dfbcaa2dc9e61a15d83dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-08-19  Derek Price  <derek@ximbiot.com>
+
+       * lib/autotest/general.m4: Comment various HELP_* diversions.
+       (PARSE_ARGS_BEGIN): New section for option parsing related
+       initialization.
+       (AT_ARG_OPTION,AT_ARG_OPTION_ARG,_AT_ARG_OPTION): New macros to define
+       package specific options and associated help.
+
 2003-08-19  Akim Demaille  <akim@epita.fr>
 
        * config/announce-gen, Makefile.cfg: New.
index 3d2d591f5861fa84bbe8707519755145f558a611..8397e5554d7a557cc50ae4b3728bee21f367d5d7 100644 (file)
 # Defined below:
 #  - DEFAULTS
 #    Overall initialization, value of $at_groups_all.
+#  - PARSE_ARGS_BEGIN
+#    Setup defaults required for option processing.
 #  - PARSE_ARGS
 #    Option processing.  After AT_INIT, user options can be entered here as
 #    cases of a case statement.
 #  - PARSE_ARGS_END
 #    Finish up the option processing.
 #  - HELP
-#    Start printing the help message.  User help can be appended to this as
-#    self-contained cat'd here-docs.
+#    Start printing the help message.
+#  - HELP_MODES
+#    Modes help text.  Additional modes can be appended as self-contained
+#    cat'd here-docs as generated by AS_HELP_STRING.
+#  - HELP_TUNING
+#    TUning help text.  Additional tuning options can be appended as
+#    self-contained cat'd here-docs as generated by AS_HELP_STRING.
+#  - HELP_OTHER
+#    User help can be appended to this as self-contained cat'd here-docs.
 #  - HELP_END
 #    Finish up the help texts.
 #  - PREPARE_TESTS
@@ -89,8 +98,9 @@
 #    The code for each test, the ``normal'' diversion
 
 m4_define([_m4_divert(DEFAULTS)],           100)
-m4_define([_m4_divert(PARSE_ARGS)],         200)
-m4_define([_m4_divert(PARSE_ARGS_END)],     201)
+m4_define([_m4_divert(PARSE_ARGS_BEGIN)],   200)
+m4_define([_m4_divert(PARSE_ARGS)],         201)
+m4_define([_m4_divert(PARSE_ARGS_END)],     202)
 m4_define([_m4_divert(HELP)],               300)
 m4_define([_m4_divert(HELP_MODES)],         301)
 m4_define([_m4_divert(HELP_TUNING)],        302)
@@ -889,6 +899,128 @@ m4_wrap([m4_divert_pop([KILL])[]])
 ])# AT_INIT
 
 
+# _AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ARGS],[ACTION-IF-GIVEN],
+#                [ACTION-IF-NOT-GIVEN])
+# ---------------------------------------------------------------------------
+# Internal implementation of AT_ARG_OPTION & AT_ARG_OPTION_ARG
+m4_defun([_AT_ARG_OPTION],
+[m4_divert_once([HELP_OTHER],
+[cat <<_ATEOF
+
+Other options:
+_ATEOF
+])dnl m4_divert_once HELP_OTHER
+m4_divert_text([HELP_OTHER],
+[cat <<_ATEOF
+$2
+_ATEOF])dnl
+dnl Turn our options into our desired strings
+m4_ifdef([AT_first_option],[m4_undefine([AT_first_option])])dnl
+m4_ifdef([AT_case],[m4_undefine([AT_case])])dnl
+m4_ifdef([AT_case_no],[m4_undefine([AT_case_no])])dnl
+m4_ifdef([AT_case_arg],[m4_undefine([AT_case_arg])])dnl
+m4_foreach([AT_option], m4_split(m4_normalize([$1]),[[ \|]+]),
+[m4_define_default([AT_first_option],AT_option)dnl
+m4_append([AT_case],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option, [ | ])dnl
+m4_append([AT_case_no],[--no]AT_option, [ | ])dnl
+m4_append([AT_case_arg],m4_if(m4_len(AT_option),1,[],[-])[-]AT_option[=*], [ | ])dnl
+])dnl m4_foreach AT_option
+dnl keep track so we or the user may process ACTION-IF-NOT-GIVEN
+m4_divert_once([PARSE_ARGS_BEGIN],
+[
+##
+## Set up package specific options.
+##
+])dnl
+m4_divert_text([PARSE_ARGS_BEGIN],
+[dnl Provide a default value for options without arguments.
+m4_ifvaln([$3],,[at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false])dnl
+at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=false
+])dnl m4_divert_text DEFAULTS
+m4_ifval([$3],[m4_divert_once([PARSE_ARGS_END],
+[
+##
+## Verify our last option didn't require an argument
+##
+AS_IF([test -n "$at_prev"],[AS_ERROR([`$at_prev' requires an argument.])])])])
+m4_divert_text([PARSE_ARGS],
+[dnl Parse the options and args when necessary.
+m4_ifvaln([$3],
+[    AT_case )
+       at_prev=--m4_bpatsubst([AT_first_option], -, _)
+       ;;
+    AT_case_arg )
+       at_arg_[]m4_bpatsubst([AT_first_option], -, _)=$at_optarg
+       at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+       $4
+       ;;],
+[    AT_case )
+       at_optarg=:
+       at_arg_[]m4_bpatsubst([AT_first_option], -, _)=:
+       at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+       m4_ifval([$4],[$4])dnl
+       ;;
+    AT_case_no )
+       at_optarg=false
+       at_arg_[]m4_bpatsubst([AT_first_option], -, _)=false
+       at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)=:
+       m4_ifval([$4],[$4])dnl
+       ;;])dnl m4_ifvaln $3
+])dnl m4_divert_text PARSE_ARGS
+m4_ifvaln([$5],
+[m4_divert_once([PARSE_ARGS_END],
+[
+##
+## Process package specific options when _not_ supplied.
+##])dnl m4_divert_once PARSE_ARGS_END
+m4_divert_text([PARSE_ARGS_END],
+[
+AS_IF([$at_arg_given_[]m4_bpatsubst([AT_first_option], -, _)],,[$5])dnl
+])dnl m4_divert_text PARSE_ARGS_END
+])dnl m4_ifvaln $5
+])dnl _AT_ARG_OPTION
+
+
+# AT_ARG_OPTION(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
+# ------------------------------------------------------------------------
+# Accept a set of OPTIONS with arguments.  Add HELP-TEXT to the HELP_OTHER
+# diversion.
+#
+# Preceding dashes should not be passed into OPTIONS.  Users will be required
+# to pass `--' before long options and `-' before single character options.
+#
+# $at_arg_OPTION will be set to `:' if this option is received, `false' if
+# if --noOPTION is received, and `false' by default.
+#
+# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with 
+# $at_optarg set to `:' or `false' as appropriate.  $opt_arg is actually
+# just a copy of $at_arg_OPTION.
+#
+# ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
+# if no option from OPTIONS was found.
+m4_defun([AT_ARG_OPTION],[_AT_ARG_OPTION([$1],[$2],,[$3],[$4])])
+
+
+# AT_ARG_OPTION_ARG(OPTIONS,HELP-TEXT,[ACTION-IF-GIVEN],[ACTION-IF-NOT-GIVEN])
+# ---------------------------------------------------------------------------
+# Accept a set of OPTIONS with arguments, seperated by commas.  Add HELP-TEXT
+# to the HELP_OTHER diversion.
+#
+# Preceding dashes should not be passed into OPTIONS.  Users will be required
+# to pass `--' before long options and `-' before single character options.
+#
+# By default, any argument to these options will be assigned to the shell
+# variable $at_arg_OPTION, where OPTION is the first option in OPTIONS with
+# any `-' characters replaced with `_'.
+#
+# Run ACTION-IF-GIVEN each time an option in OPTIONS is encountered with 
+# $at_optarg set.  $at_optarg is actually just a copy of $at_arg_OPTION.
+#
+# ACTION-IF-NOT-GIVEN will be run once after option parsing is complete
+# if no option from OPTIONS was found.
+m4_defun([AT_ARG_OPTION_ARG],[_AT_ARG_OPTION([$1],[$2],1,[$3],[$4])])
+
+
 # AT_TESTED(PROGRAMS)
 # -------------------
 # Specify the list of programs exercised by the test suite.  Their