OSDN Git Service

Add sys/types include for sockaddr test to configure
[pg-rex/syncrep.git] / config / general.m4
1 # $Header: /cvsroot/pgsql/config/general.m4,v 1.1 2000/09/21 20:17:42 petere Exp $
2
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.
9 #
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.
13
14
15 # print an error message and exit (while running `autoconf')
16 define([pgac_error],
17        [errprint(__file__:__line__[: error: $1
18 ])
19         m4exit(10)])
20
21
22 # Convert type and name to shell variable name (e.g., "enable_long_strings")
23 define([pgac_arg_to_variable],
24        [$1[]_[]patsubst($2, -, _)])
25
26
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.
35
36 AC_DEFUN([PGAC_ARG],
37 [dnl Check arguments
38 ifelse([$1], enable, ,
39         [$1], with, ,
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
43 ifelse([$3], [], [],
44 [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
45 ac_help="$ac_help
46 [$3]"
47 AC_DIVERT_POP()])dnl
48 [#] Check whether --$1-$2 was given
49 if test x"[$]{pgac_variable+set}" = xset; then
50   case [$]pgac_variable in
51     yes)
52       ifelse([$4], [], :, [$4])
53       ;;
54     no)
55       ifelse([$5], [], :, [$5])
56       ;;
57 dnl Action if called with argument
58 ifelse([$6], [], [],
59 [    *)
60 dnl Set up $withval or $enableval
61       $1[]val=[$]pgac_variable
62       $6
63       ;;
64 ])[]dnl
65   esac [#] [$]pgac_variable
66 dnl Action if omitted
67 ifelse([$7], [], [],
68 [else
69   $7
70 ])[]dnl
71 fi[]dnl
72 undefine([pgac_variable])dnl
73 ])# PGAC_ARG
74
75
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
83 # execute.)
84
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
89 $5],
90                   [$3], no,  [pgac_arg_to_variable([$1], [$2])=no
91 $6],
92                   [pgac_error([third argument of $0 must be `yes' or `no', not `$3'])])])[]dnl
93 ])# PGAC_ARG_BOOL
94
95
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
99 # accepted.
100
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])],
105           [$4],
106           [$5])])# PGAC_ARG_REQ
107
108
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.
118 #
119 # The intent is to allow enabling a feature, and optionally pass an
120 # additional piece of information.
121
122 AC_DEFUN([PGAC_ARG_OPTARG],
123 [PGAC_ARG([$1], [$2], [$3], [$4], [],
124           [pgac_arg_to_variable([$1], [$2])=yes
125 $5],
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], [], [],
129 [
130 if test "[$]pgac_arg_to_variable([$1], [$2])" = yes; then
131   ifelse([$6], [], :, [$6])
132 ifelse([$7], [], [],
133 [else
134   $7
135 ])[]dnl
136 fi
137 ])[]dnl
138 ])# PGAC_ARG_OPTARG