1- # $PostgreSQL: pgsql/config/general.m4,v 1.9 2006/11/30 22:21:23 tgl Exp $
1+ # $PostgreSQL: pgsql/config/general.m4,v 1.10 2008/10/29 09:27:24 petere Exp $
22
33# This file defines new macros to process configure command line
44# arguments, to replace the brain-dead AC_ARG_WITH and AC_ARG_ENABLE.
@@ -17,52 +17,57 @@ m4_define([pgac_arg_to_variable],
1717[ $1 [ ] _[ ] patsubst($2 , -, _)] )
1818
1919
20- # PGAC_ARG(TYPE, NAME, HELP-STRING,
20+ # PGAC_ARG(TYPE, NAME, HELP-STRING-LHS-EXTRA, HELP-STRING-RHS ,
2121# [ACTION-IF-YES], [ACTION-IF-NO], [ACTION-IF-ARG],
2222# [ACTION-IF-OMITTED])
23- # ----------------------------------------------------------
23+ # ------------------------------------------------------------
2424# This is the base layer. TYPE is either "with" or "enable", depending
25- # on what you like. NAME is the rest of the option name, HELP-STRING
26- # as usual. ACTION-IF-YES is executed if the option is given without
27- # an argument (or "yes", which is the same); similar for ACTION-IF-NO.
25+ # on what you like. NAME is the rest of the option name.
26+ # HELP-STRING-LHS-EXTRA is a string to append to the option name on
27+ # the left-hand side of the help output, e.g., an argument name. If
28+ # set to "-", append nothing, but let the option appear in the
29+ # negative form (disable/without). HELP-STRING-RHS is the option
30+ # description, for the right-hand side of the help output.
31+ # ACTION-IF-YES is executed if the option is given without an argument
32+ # (or "yes", which is the same); similar for ACTION-IF-NO.
2833
2934AC_DEFUN ( [ PGAC_ARG] ,
3035[
3136pgac_args="$pgac_args pgac_arg_to_variable([ $1 ] ,[ $2 ] )"
3237m4_case ( [ $1 ] ,
3338
3439enable ,[
35- AC_ARG_ENABLE ( [ $2 ] ,[ $3 ] ,[
40+ AC_ARG_ENABLE ( [ $2 ] ,[ AS_HELP_STRING ( [ -- ] m4_if ( $3 , - , disable , enable ) [ - $2 ] m4_if ( $3 , - , , $3 ) , [ $4 ] ) ] ,[
3641 case[ $] enableval in
3742 yes)
38- m4_default ( [ $4 ] ,: )
43+ m4_default ( [ $5 ] ,: )
3944 ;;
4045 no)
41- m4_default ( [ $5 ] ,: )
46+ m4_default ( [ $6 ] ,: )
4247 ;;
4348 *)
44- $6
49+ $7
4550 ;;
4651 esac
4752] ,
48- [ $7 ] ) [ ] dnl AC_ARG_ENABLE
53+ [ $8 ] ) [ ] dnl AC_ARG_ENABLE
4954] ,
5055
5156with ,[
52- AC_ARG_WITH ( [ $2 ] ,[ $3 ] ,[
57+ AC_ARG_WITH ( [ $2 ] ,[ AS_HELP_STRING ( [ -- ] m4_if ( $3 , - , without , with ) [ - $2 ] m4_if ( $3 , - , , $3 ) , [ $4 ] ) ] ,[
5358 case[ $] withval in
5459 yes)
55- m4_default ( [ $4 ] ,: )
60+ m4_default ( [ $5 ] ,: )
5661 ;;
5762 no)
58- m4_default ( [ $5 ] ,: )
63+ m4_default ( [ $6 ] ,: )
5964 ;;
6065 *)
61- $6
66+ $7
6267 ;;
6368 esac
6469] ,
65- [ $7 ] ) [ ] dnl AC_ARG_WITH
70+ [ $8 ] ) [ ] dnl AC_ARG_WITH
6671] ,
6772
6873[ m4_fatal ( [ first argument of$0 must be 'enable' or 'with', not '$1 '] ) ]
@@ -86,43 +91,52 @@ AC_DEFUN([PGAC_ARG_CHECK],
8691AC_MSG_WARN ( [ option ignored: --$pgac_txt] )
8792done] ) # PGAC_ARG_CHECK
8893
89- # PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING,
94+ # PGAC_ARG_BOOL(TYPE, NAME, DEFAULT, HELP-STRING-RHS,
9095# [ACTION-IF-YES], [ACTION-IF-NO])
91- # -----------------------------------------------
96+ # ---------------------------------------------------
9297# Accept a boolean option, that is, one that only takes yes or no.
9398# ("no" is equivalent to "disable" or "without"). DEFAULT is what
9499# should be done if the option is omitted; it should be "yes" or "no".
95100# (Consequently, one of ACTION-IF-YES and ACTION-IF-NO will always
96101# execute.)
97102
98103AC_DEFUN ( [ PGAC_ARG_BOOL] ,
99- [ PGAC_ARG([ $1 ] ,[ $2 ] ,[ $4 ] ,[ $5 ] ,[ $6 ] ,
104+ [ dnl The following hack is necessary because in a few instances this
105+ dnl macro is called twice for the same option with different default
106+ dnl values. But we only want it to appear once in the help. We achieve
107+ dnl that by making the help string look the same, which is why we need to
108+ dnl save the default that was passed in previously.
109+ m4_define ( [ _pgac_helpdefault] ,m4_ifdef ( [ pgac_defined_$1 _$2 _bool] ,[ m4_defn ( [ pgac_defined_$1 _$2 _bool] ) ] ,[ $3 ] ) ) dnl
110+ PGAC_ARG([ $1 ] ,[ $2 ] ,[ m4_if ( _pgac_helpdefault ,yes ,- ) ] ,[ $4 ] ,[ $5 ] ,[ $6 ] ,
100111[ AC_MSG_ERROR ( [ no argument expected for --$1 -$2 option] ) ] ,
101112[ m4_case ( [ $3 ] ,
102113yes ,[ pgac_arg_to_variable([ $1 ] ,[ $2 ] )=yes
103114$5 ] ,
104115no ,[ pgac_arg_to_variable([ $1 ] ,[ $2 ] )=no
105116$6 ] ,
106117[ m4_fatal ( [ third argument of$0 must be 'yes' or 'no', not '$3 '] ) ] ) ] )[ ] dnl
118+ m4_define ( [ pgac_defined_$1 _$2 _bool] ,[ $3 ] ) dnl
107119] ) # PGAC_ARG_BOOL
108120
109121
110- # PGAC_ARG_REQ(TYPE, NAME, HELP-STRING, [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN])
111- # -------------------------------------------------------------------------------
122+ # PGAC_ARG_REQ(TYPE, NAME, HELP-ARGNAME, HELP-STRING-RHS,
123+ # [ACTION-IF-GIVEN], [ACTION-IF-NOT-GIVEN])
124+ # -------------------------------------------------------
112125# This option will require an argument; "yes" or "no" will not be
113- # accepted.
126+ # accepted. HELP-ARGNAME is a name for the argument for the help output.
114127
115128AC_DEFUN ( [ PGAC_ARG_REQ] ,
116- [ PGAC_ARG([ $1 ] ,[ $2 ] ,[ $3 ] ,
129+ [ PGAC_ARG([ $1 ] ,[ $2 ] ,[ = $3 ] , [ $4 ] ,
117130[ AC_MSG_ERROR ( [ argument required for --$1 -$2 option] ) ] ,
118131[ AC_MSG_ERROR ( [ argument required for --$1 -$2 option] ) ] ,
119- [ $4 ] ,
120- [ $5 ] )] ) # PGAC_ARG_REQ
132+ [ $5 ] ,
133+ [ $6 ] )] ) # PGAC_ARG_REQ
121134
122135
123- # PGAC_ARG_OPTARG(TYPE, NAME, HELP-STRING, [DEFAULT-ACTION], [ARG-ACTION]
136+ # PGAC_ARG_OPTARG(TYPE, NAME, HELP-ARGNAME, HELP-STRING-RHS,
137+ # [DEFAULT-ACTION], [ARG-ACTION],
124138# [ACTION-ENABLED], [ACTION-DISABLED])
125- # -----------------------------------------------------------------------
139+ # ----------------------------------------------------------
126140# This will create an option that behaves as follows: If omitted, or
127141# called with "no", then set the enable_variable to "no" and do
128142# nothing else. If called with "yes", then execute DEFAULT-ACTION. If
@@ -134,18 +148,18 @@ AC_DEFUN([PGAC_ARG_REQ],
134148# additional piece of information.
135149
136150AC_DEFUN ( [ PGAC_ARG_OPTARG] ,
137- [ PGAC_ARG([ $1 ] ,[ $2 ] ,[ $3 ] ,[ $4 ] ,[ ] ,
151+ [ PGAC_ARG([ $1 ] ,[ $2 ] ,[ @<:@ = $3 @:>@ ] ,[ $4 ] , [ $5 ] ,[ ] ,
138152[ pgac_arg_to_variable([ $1 ] ,[ $2 ] )=yes
139- $5 ] ,
153+ $6 ] ,
140154[ pgac_arg_to_variable([ $1 ] ,[ $2 ] )=no] )
141155dnl Add this code only if there's a ACTION-ENABLED or ACTION-DISABLED.
142- m4_ifval ( [ $6 [ ] $7 ] ,
156+ m4_ifval ( [ $7 [ ] $8 ] ,
143157[
144158if test "[ $] pgac_arg_to_variable([ $1 ] ,[ $2 ] )" = yes; then
145- m4_default ( [ $6 ] ,: )
146- m4_ifval ( [ $7 ] ,
159+ m4_default ( [ $7 ] ,: )
160+ m4_ifval ( [ $8 ] ,
147161[ else
148- $7
162+ $8
149163] ) [ ] dnl
150164fi
151165] ) [ ] dnl