4 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
5 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
6 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?)
10 # AE_FEATURE is a simple wrapper for AC_ARG_ENABLE.
12 # FEATURE-NAME should consist only of alphanumeric characters, dashes,
13 # plus signs, and dots.
15 # FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING.
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
21 # If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is
22 # disabled, run shell commands ACTION-IF-NOT-ENABLED.
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.
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
35 # AE_FEATURE_DEFAULT_ENABLE
36 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support])
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]))
44 # AE_FEATURE_DEFAULT_ENABLE
49 # Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to
50 # enable or disable a specific feature.
52 # Another simple example:
54 # AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[])
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])
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.
69 # SPDX-License-Identifier: GPL-2.0-or-later WITH Autoconf-exception-2.0
71 # Copyright (c) 2020 Michael Jeanson <mjeanson@efficios.com>
72 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
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.
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.
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/>.
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.
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.
103 # AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will
105 AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [
106 m4_define([ae_feature_default_arg], [yes])
107 m4_define([ae_feature_default_switch], [disable])
111 # AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will
112 # default to disable.
114 AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [
115 m4_define([ae_feature_default_arg], [no])
116 m4_define([ae_feature_default_switch], [enable])
120 # AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the
121 # user's choice if it was made.
123 AC_DEFUN([AE_FEATURE_ENABLE],[ dnl
124 enable_[]patsubst([$1], -, _)[]=yes
128 # AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the
129 # user's choice if it was made.
131 AC_DEFUN([AE_FEATURE_DISABLE],[ dnl
132 enable_[]patsubst([$1], -, _)[]=no
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.
140 AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl
141 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
143 AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl
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.
156 # The distinction with AE_IF_FEATURE_DISABLED is that this will also
157 # match a feature that is undefined.
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.
162 AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl
163 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
165 AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl
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.
177 AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl
178 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
180 AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl
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.
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.
195 AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl
196 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
198 AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl
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
210 AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl
211 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
212 test "x$enable_[]FEATURE[]" = xyes dnl
216 dnl Disabled by default, unless already overridden
217 m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE])
220 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
221 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
222 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?):
225 AC_DEFUN([AE_FEATURE],[ dnl
226 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
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"
234 AS_HELP_STRING([--ae_feature_default_switch-$1],dnl
236 case "${enableval}" in
238 enable_[]FEATURE[]=yes
241 enable_[]FEATURE[]=no
244 AC_MSG_ERROR([bad value ${enableval} for feature --$1])
253 AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl
259 m4_popdef([FEATURE])dnl