1 # SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro
5 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
6 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
7 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?)
11 # AE_FEATURE is a simple wrapper for AC_ARG_ENABLE.
13 # FEATURE-NAME should consist only of alphanumeric characters, dashes,
14 # plus signs, and dots.
16 # FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING.
18 # If the user gave configure the option --enable-FEATURE or --disable-FEATURE,
19 # run shell commands ACTION-IF-GIVEN. If neither option was given, run shell
20 # commands ACTION-IF-NOT-GIVEN. The name feature indicates an optional
22 # If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is
23 # disabled, run shell commands ACTION-IF-NOT-ENABLED.
25 # A FEATURE has 3 different states, enabled, disabled and undefined. The first
26 # two are self explanatory, the third state means it's disabled by default
27 # and it was not explicitly enabled or disabled by the user or by the
28 # AE_FEATURE_ENABLE and AE_FEATURE_DISABLE macros.
30 # A feature is disabled by default, in order to change this behaviour use the
31 # AE_FEATURE_DEFAULT_ENABLE and AE_FEATURE_DEFAULT_DISABLE
36 # AE_FEATURE_DEFAULT_ENABLE
37 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support])
41 # AE_FEATURE_DEFAULT_DISABLE
42 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support])
43 # AM_CONDITIONAL(YYYYY, AE_IS_FEATURE_ENABLED([feature_yyyyy]))
45 # AE_FEATURE_DEFAULT_ENABLE
50 # Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to
51 # enable or disable a specific feature.
53 # Another simple example:
55 # AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[])
57 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support],
58 # HAVE_XXXXX, [Define if you want XXXXX support])
59 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support],
60 # HAVE_YYYYY, [Define if you want YYYYY support])
64 # NOTE: AE_FEATURE_ENABLE/DISABLE() must be placed first of the relative
65 # AE_FEATURE() macro if you want the the proper ACTION-IF-ENABLED and
66 # ACTION-IF-NOT-ENABLED to run.
70 # Copyright (c) 2020 Michael Jeanson <mjeanson@efficios.com>
71 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
73 # This program is free software; you can redistribute it and/or modify it
74 # under the terms of the GNU General Public License as published by the
75 # Free Software Foundation; either version 2 of the License, or (at your
76 # option) any later version.
78 # This program is distributed in the hope that it will be useful, but
79 # WITHOUT ANY WARRANTY; without even the implied warranty of
80 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
81 # Public License for more details.
83 # You should have received a copy of the GNU General Public License along
84 # with this program. If not, see <https://www.gnu.org/licenses/>.
86 # As a special exception, the respective Autoconf Macro's copyright owner
87 # gives unlimited permission to copy, distribute and modify the configure
88 # scripts that are the output of Autoconf when processing the Macro. You
89 # need not follow the terms of the GNU General Public License when using
90 # or distributing such scripts, even though portions of the text of the
91 # Macro appear in them. The GNU General Public License (GPL) does govern
92 # all other use of the material that constitutes the Autoconf Macro.
94 # This special exception to the GPL applies to versions of the Autoconf
95 # Macro released by the Autoconf Archive. When you make and distribute a
96 # modified version of the Autoconf Macro, you may extend this special
97 # exception to the GPL to apply to your modified version as well.
102 # AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will
104 AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [
105 m4_define([ae_feature_default_arg], [yes])
106 m4_define([ae_feature_default_switch], [disable])
110 # AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will
111 # default to disable.
113 AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [
114 m4_define([ae_feature_default_arg], [no])
115 m4_define([ae_feature_default_switch], [enable])
119 # AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the
120 # user's choice if it was made.
122 AC_DEFUN([AE_FEATURE_ENABLE],[ dnl
123 enable_[]patsubst([$1], -, _)[]=yes
127 # AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the
128 # user's choice if it was made.
130 AC_DEFUN([AE_FEATURE_DISABLE],[ dnl
131 enable_[]patsubst([$1], -, _)[]=no
135 # AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?):
136 # Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run
137 # shell code ACTION-IF-NOT-ENABLED.
139 AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl
140 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
142 AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl
150 # AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED,
151 # ACTION-IF-NOT-NOT-ENABLED?):
152 # Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly
153 # enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED.
155 # The distinction with AE_IF_FEATURE_DISABLED is that this will also
156 # match a feature that is undefined.
158 # A feature is undefined when it's disabled by default and was not explicitly
159 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
161 AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl
162 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
164 AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl
172 # AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?):
173 # Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run
174 # shell code ACTION-IF-NOT-DISABLED.
176 AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl
177 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
179 AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl
187 # AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?):
188 # Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run
189 # shell code ACTION-IF-NOT-UNDEF.
191 # A feature is undefined when it's disabled by default and was not explicitly
192 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
194 AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl
195 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
197 AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl
205 # AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable
206 # for use in a shell if statement) that will return true if the FEATURE is
209 AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl
210 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
211 test "x$enable_[]FEATURE[]" = xyes dnl
215 dnl Disabled by default, unless already overridden
216 m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE])
219 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
220 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
221 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?):
224 AC_DEFUN([AE_FEATURE],[ dnl
225 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
227 dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes
228 AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl
229 enable_[]FEATURE[]="ae_feature_default_arg"
233 AS_HELP_STRING([--ae_feature_default_switch-$1],dnl
235 case "${enableval}" in
237 enable_[]FEATURE[]=yes
240 enable_[]FEATURE[]=no
243 AC_MSG_ERROR([bad value ${enableval} for feature --$1])
252 AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl
258 m4_popdef([FEATURE])dnl