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 # Copyright (c) 2020 Michael Jeanson <mjeanson@efficios.com>
70 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
72 # This program is free software; you can redistribute it and/or modify it
73 # under the terms of the GNU General Public License as published by the
74 # Free Software Foundation; either version 2 of the License, or (at your
75 # option) any later version.
77 # This program is distributed in the hope that it will be useful, but
78 # WITHOUT ANY WARRANTY; without even the implied warranty of
79 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
80 # Public License for more details.
82 # You should have received a copy of the GNU General Public License along
83 # with this program. If not, see <https://www.gnu.org/licenses/>.
85 # As a special exception, the respective Autoconf Macro's copyright owner
86 # gives unlimited permission to copy, distribute and modify the configure
87 # scripts that are the output of Autoconf when processing the Macro. You
88 # need not follow the terms of the GNU General Public License when using
89 # or distributing such scripts, even though portions of the text of the
90 # Macro appear in them. The GNU General Public License (GPL) does govern
91 # all other use of the material that constitutes the Autoconf Macro.
93 # This special exception to the GPL applies to versions of the Autoconf
94 # Macro released by the Autoconf Archive. When you make and distribute a
95 # modified version of the Autoconf Macro, you may extend this special
96 # exception to the GPL to apply to your modified version as well.
101 # AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will
103 AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [
104 m4_define([ae_feature_default_arg], [yes])
105 m4_define([ae_feature_default_switch], [disable])
109 # AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will
110 # default to disable.
112 AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [
113 m4_define([ae_feature_default_arg], [no])
114 m4_define([ae_feature_default_switch], [enable])
118 # AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the
119 # user's choice if it was made.
121 AC_DEFUN([AE_FEATURE_ENABLE],[ dnl
122 enable_[]patsubst([$1], -, _)[]=yes
126 # AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the
127 # user's choice if it was made.
129 AC_DEFUN([AE_FEATURE_DISABLE],[ dnl
130 enable_[]patsubst([$1], -, _)[]=no
134 # AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?):
135 # Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run
136 # shell code ACTION-IF-NOT-ENABLED.
138 AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl
139 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
141 AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl
149 # AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED,
150 # ACTION-IF-NOT-NOT-ENABLED?):
151 # Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly
152 # enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED.
154 # The distinction with AE_IF_FEATURE_DISABLED is that this will also
155 # match a feature that is undefined.
157 # A feature is undefined when it's disabled by default and was not explicitly
158 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
160 AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl
161 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
163 AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl
171 # AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?):
172 # Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run
173 # shell code ACTION-IF-NOT-DISABLED.
175 AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl
176 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
178 AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl
186 # AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?):
187 # Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run
188 # shell code ACTION-IF-NOT-UNDEF.
190 # A feature is undefined when it's disabled by default and was not explicitly
191 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
193 AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl
194 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
196 AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl
204 # AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable
205 # for use in a shell if statement) that will return true if the FEATURE is
208 AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl
209 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
210 test "x$enable_[]FEATURE[]" = xyes dnl
214 dnl Disabled by default, unless already overriden
215 m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE])
218 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
219 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
220 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?):
223 AC_DEFUN([AE_FEATURE],[ dnl
224 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
226 dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes
227 AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl
228 enable_[]FEATURE[]="ae_feature_default_arg"
232 AS_HELP_STRING([--ae_feature_default_switch-$1],dnl
234 case "${enableval}" in
236 enable_[]FEATURE[]=yes
239 enable_[]FEATURE[]=no
242 AC_MSG_ERROR([bad value ${enableval} for feature --$1])
251 AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl
257 m4_popdef([FEATURE])dnl