1 # $Header: /cvsroot/pgsql/config/general.m4,v 1.1 2000/09/21 20:17:42 petere Exp $
3 # This file defines new macros to process configure command line
4 # arguments, to replace the brain-dead AC_ARG_WITH and AC_ARG_ENABLE.
5 # The flaw in these is particularly that they only differentiate
6 # between "given" and "not given" and do not provide enough help to
7 # process arguments that only accept "yes/no", that require an
8 # argument (other than "yes/no"), etc.
10 # The point of this implementation is to reduce code size and
11 # redundancy in configure.in and to improve robustness and consistency
12 # in the option evaluation code.
15 # print an error message and exit (while running `autoconf')
17 [errprint(__file__:__line__[: error: $1
22 # Convert type and name to shell variable name (e.g., "enable_long_strings")
23 define([pgac_arg_to_variable],
24 [$1[]_[]patsubst($2, -, _)])
27 # PGAC_ARG(TYPE, NAME, HELP-STRING,
28 # [ACTION-IF-YES], [ACTION-IF-NO], [ACTION-IF-ARG],
29 # [ACTION-IF-OMITTED])
30 # ----------------------------------------------------------
31 # This is the base layer. TYPE is either "with" or "enable", depending
32 # on what you like. NAME is the rest of the option name, HELP-STRING
33 # as usual. ACTION-IF-YES is executed if the option is given without
34 # and argument (or "yes", which is the same); similar for ACTION-IF-NO.
38 ifelse([$1], enable, ,
40 [pgac_error([first argument of $0 must be `enable' or `with', not `$1'])])[]dnl
41 define([pgac_variable], [pgac_arg_to_variable([$1], [$2])])[]dnl
42 dnl Register help string, only if there is one
44 [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
48 [#] Check whether --$1-$2 was given
49 if test x"[$]{pgac_variable+set}" = xset; then
50 case [$]pgac_variable in
52 ifelse([$4], [], :, [$4])
55 ifelse([$5], [], :, [$5])
57 dnl Action if called with argument
60 dnl Set up $withval or $enableval
61 $1[]val=[$]pgac_variable
65 esac [#] [$]pgac_variable
72 undefine([pgac_variable])dnl
76 # PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING,
77 # [ACTION-IF-YES], [ACTION-IF-NO])
78 # -----------------------------------------------
79 # Accept a boolean option, that is, one that only takes yes or no.
80 # ("no" is equivalent to "disable" or "without"). DEFAULT is what
81 # should be done if the option is omitted; it should be "yes" or "no".
82 # (Consequently, one of ACTION-IF-YES and ACTION-IF-NO will always
85 AC_DEFUN([PGAC_ARG_BOOL],
86 [PGAC_ARG([$1], [$2], [$4], [$5], [$6],
87 [AC_MSG_ERROR([no argument expected for --$1-$2 option])],
88 [ifelse([$3], yes, [pgac_arg_to_variable([$1], [$2])=yes
90 [$3], no, [pgac_arg_to_variable([$1], [$2])=no
92 [pgac_error([third argument of $0 must be `yes' or `no', not `$3'])])])[]dnl
96 # PGAC_ARG_REQ(TYPE, NAME, HELP-STRING, [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN])
97 # -------------------------------------------------------------------------------
98 # This option will require an argument; "yes" or "no" will not be
101 AC_DEFUN([PGAC_ARG_REQ],
102 [PGAC_ARG([$1], [$2], [$3],
103 [AC_MSG_ERROR([argument required for --$1-$2 option])],
104 [AC_MSG_ERROR([argument required for --$1-$2 option])],
106 [$5])])# PGAC_ARG_REQ
109 # PGAC_ARG_OPTARG(TYPE, NAME, HELP-STRING, [DEFAULT-ACTION], [ARG-ACTION]
110 # [ACTION-ENABLED], [ACTION-DISABLED])
111 # -----------------------------------------------------------------------
112 # This will create an option that behaves as follows: If omitted, or
113 # called with "no", then set the enable_variable to "no" and do
114 # nothing else. If called with "yes", then execute DEFAULT-ACTION. If
115 # called with argument, set enable_variable to "yes" and execute
116 # ARG-ACTION. Additionally, execute ACTION-ENABLED if we ended up with
117 # "yes" either way, else ACTION-DISABLED.
119 # The intent is to allow enabling a feature, and optionally pass an
120 # additional piece of information.
122 AC_DEFUN([PGAC_ARG_OPTARG],
123 [PGAC_ARG([$1], [$2], [$3], [$4], [],
124 [pgac_arg_to_variable([$1], [$2])=yes
126 [pgac_arg_to_variable([$1], [$2])=no])
127 dnl Add this code only if there's a ACTION-ENABLED or ACTION-DISABLED.
128 ifelse([$6[]$7], [], [],
130 if test "[$]pgac_arg_to_variable([$1], [$2])" = yes; then
131 ifelse([$6], [], :, [$6])