Add key characteristics to rfc
[libside.git] / m4 / ae_config_feature.m4
1 #
2 # SYNOPSIS
3 #
4 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
5 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
6 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?)
7 #
8 # DESCRIPTION
9 #
10 # AE_FEATURE is a simple wrapper for AC_ARG_ENABLE.
11 #
12 # FEATURE-NAME should consist only of alphanumeric characters, dashes,
13 # plus signs, and dots.
14 #
15 # FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING.
16 #
17 # If the user gave configure the option --enable-FEATURE or --disable-FEATURE,
18 # run shell commands ACTION-IF-GIVEN. If neither option was given, run shell
19 # commands ACTION-IF-NOT-GIVEN. The name feature indicates an optional
20 #
21 # If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is
22 # disabled, run shell commands ACTION-IF-NOT-ENABLED.
23 #
24 # A FEATURE has 3 different states, enabled, disabled and undefined. The first
25 # two are self explanatory, the third state means it's disabled by default
26 # and it was not explicitly enabled or disabled by the user or by the
27 # AE_FEATURE_ENABLE and AE_FEATURE_DISABLE macros.
28 #
29 # A feature is disabled by default, in order to change this behaviour use the
30 # AE_FEATURE_DEFAULT_ENABLE and AE_FEATURE_DEFAULT_DISABLE
31 # macros.
32 #
33 # A simple example:
34 #
35 # AE_FEATURE_DEFAULT_ENABLE
36 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support])
37 #
38 # ...
39 #
40 # AE_FEATURE_DEFAULT_DISABLE
41 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support])
42 # AM_CONDITIONAL(YYYYY, AE_IS_FEATURE_ENABLED([feature_yyyyy]))
43 #
44 # AE_FEATURE_DEFAULT_ENABLE
45 # AE_FEATURE(...)
46 #
47 # ...
48 #
49 # Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to
50 # enable or disable a specific feature.
51 #
52 # Another simple example:
53 #
54 # AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[])
55 #
56 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support],
57 # HAVE_XXXXX, [Define if you want XXXXX support])
58 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support],
59 # HAVE_YYYYY, [Define if you want YYYYY support])
60 #
61 # ...
62 #
63 # NOTE: AE_FEATURE_ENABLE/DISABLE() must be placed first of the relative
64 # AE_FEATURE() macro if you want the the proper ACTION-IF-ENABLED and
65 # ACTION-IF-NOT-ENABLED to run.
66 #
67 # LICENSE
68 #
69 # SPDX-License-Identifier: GPL-2.0-or-later WITH Autoconf-exception-2.0
70 #
71 # Copyright (c) 2020 Michael Jeanson <mjeanson@efficios.com>
72 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
73 #
74 # This program is free software; you can redistribute it and/or modify it
75 # under the terms of the GNU General Public License as published by the
76 # Free Software Foundation; either version 2 of the License, or (at your
77 # option) any later version.
78 #
79 # This program is distributed in the hope that it will be useful, but
80 # WITHOUT ANY WARRANTY; without even the implied warranty of
81 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
82 # Public License for more details.
83 #
84 # You should have received a copy of the GNU General Public License along
85 # with this program. If not, see <https://www.gnu.org/licenses/>.
86 #
87 # As a special exception, the respective Autoconf Macro's copyright owner
88 # gives unlimited permission to copy, distribute and modify the configure
89 # scripts that are the output of Autoconf when processing the Macro. You
90 # need not follow the terms of the GNU General Public License when using
91 # or distributing such scripts, even though portions of the text of the
92 # Macro appear in them. The GNU General Public License (GPL) does govern
93 # all other use of the material that constitutes the Autoconf Macro.
94 #
95 # This special exception to the GPL applies to versions of the Autoconf
96 # Macro released by the Autoconf Archive. When you make and distribute a
97 # modified version of the Autoconf Macro, you may extend this special
98 # exception to the GPL to apply to your modified version as well.
99
100 #serial 2
101
102
103 # AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will
104 # default to enable.
105 AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [
106 m4_define([ae_feature_default_arg], [yes])
107 m4_define([ae_feature_default_switch], [disable])
108 ])
109
110
111 # AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will
112 # default to disable.
113 #
114 AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [
115 m4_define([ae_feature_default_arg], [no])
116 m4_define([ae_feature_default_switch], [enable])
117 ])
118
119
120 # AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the
121 # user's choice if it was made.
122 #
123 AC_DEFUN([AE_FEATURE_ENABLE],[ dnl
124 enable_[]patsubst([$1], -, _)[]=yes
125 ])
126
127
128 # AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the
129 # user's choice if it was made.
130 #
131 AC_DEFUN([AE_FEATURE_DISABLE],[ dnl
132 enable_[]patsubst([$1], -, _)[]=no
133 ])
134
135
136 # AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?):
137 # Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run
138 # shell code ACTION-IF-NOT-ENABLED.
139 #
140 AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl
141 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
142
143 AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl
144 $2
145 ],[: dnl
146 $3
147 ])
148 ])
149
150
151 # AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED,
152 # ACTION-IF-NOT-NOT-ENABLED?):
153 # Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly
154 # enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED.
155 #
156 # The distinction with AE_IF_FEATURE_DISABLED is that this will also
157 # match a feature that is undefined.
158 #
159 # A feature is undefined when it's disabled by default and was not explicitly
160 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
161 #
162 AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl
163 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
164
165 AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl
166 $2
167 ],[: dnl
168 $3
169 ])
170 ])
171
172
173 # AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?):
174 # Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run
175 # shell code ACTION-IF-NOT-DISABLED.
176 #
177 AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl
178 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
179
180 AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl
181 $2
182 ],[: dnl
183 $3
184 ])
185 ])
186
187
188 # AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?):
189 # Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run
190 # shell code ACTION-IF-NOT-UNDEF.
191 #
192 # A feature is undefined when it's disabled by default and was not explicitly
193 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
194 #
195 AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl
196 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
197
198 AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl
199 $2
200 ],[: dnl
201 $3
202 ])
203 ])
204
205
206 # AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable
207 # for use in a shell if statement) that will return true if the FEATURE is
208 # enabled.
209 #
210 AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl
211 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
212 test "x$enable_[]FEATURE[]" = xyes dnl
213 ])
214
215
216 dnl Disabled by default, unless already overridden
217 m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE])
218
219
220 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
221 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
222 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?):
223 #
224 #
225 AC_DEFUN([AE_FEATURE],[ dnl
226 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
227
228 dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes
229 AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl
230 enable_[]FEATURE[]="ae_feature_default_arg"
231 ])
232
233 AC_ARG_ENABLE([$1],
234 AS_HELP_STRING([--ae_feature_default_switch-$1],dnl
235 [$2]),[
236 case "${enableval}" in
237 yes)
238 enable_[]FEATURE[]=yes
239 ;;
240 no)
241 enable_[]FEATURE[]=no
242 ;;
243 *)
244 AC_MSG_ERROR([bad value ${enableval} for feature --$1])
245 ;;
246 esac
247
248 $3
249 ],[: dnl
250 $4
251 ])
252
253 AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl
254 $5
255 ],[: dnl
256 $6
257 ])
258
259 m4_popdef([FEATURE])dnl
260 ])
This page took 0.04056 seconds and 4 git commands to generate.