1 # SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro
2 # SPDX-FileCopyrightText: 2020 Michael Jeanson <mjeanson@efficios.com>
3 # SPDX-FileCopyrightText: 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
7 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
8 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
9 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?)
13 # AE_FEATURE is a simple wrapper for AC_ARG_ENABLE.
15 # FEATURE-NAME should consist only of alphanumeric characters, dashes,
16 # plus signs, and dots.
18 # FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING.
20 # If the user gave configure the option --enable-FEATURE or --disable-FEATURE,
21 # run shell commands ACTION-IF-GIVEN. If neither option was given, run shell
22 # commands ACTION-IF-NOT-GIVEN. The name feature indicates an optional
24 # If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is
25 # disabled, run shell commands ACTION-IF-NOT-ENABLED.
27 # A FEATURE has 3 different states, enabled, disabled and undefined. The first
28 # two are self explanatory, the third state means it's disabled by default
29 # and it was not explicitly enabled or disabled by the user or by the
30 # AE_FEATURE_ENABLE and AE_FEATURE_DISABLE macros.
32 # A feature is disabled by default, in order to change this behaviour use the
33 # AE_FEATURE_DEFAULT_ENABLE and AE_FEATURE_DEFAULT_DISABLE
38 # AE_FEATURE_DEFAULT_ENABLE
39 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support])
43 # AE_FEATURE_DEFAULT_DISABLE
44 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support])
45 # AM_CONDITIONAL(YYYYY, AE_IS_FEATURE_ENABLED([feature_yyyyy]))
47 # AE_FEATURE_DEFAULT_ENABLE
52 # Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to
53 # enable or disable a specific feature.
55 # Another simple example:
57 # AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[])
59 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support],
60 # HAVE_XXXXX, [Define if you want XXXXX support])
61 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support],
62 # HAVE_YYYYY, [Define if you want YYYYY support])
66 # NOTE: AE_FEATURE_ENABLE/DISABLE() must be placed first of the relative
67 # AE_FEATURE() macro if you want the the proper ACTION-IF-ENABLED and
68 # ACTION-IF-NOT-ENABLED to run.
73 # AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will
75 AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [
76 m4_define([ae_feature_default_arg], [yes])
77 m4_define([ae_feature_default_switch], [disable])
81 # AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will
84 AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [
85 m4_define([ae_feature_default_arg], [no])
86 m4_define([ae_feature_default_switch], [enable])
90 # AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the
91 # user's choice if it was made.
93 AC_DEFUN([AE_FEATURE_ENABLE],[ dnl
94 enable_[]patsubst([$1], -, _)[]=yes
98 # AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the
99 # user's choice if it was made.
101 AC_DEFUN([AE_FEATURE_DISABLE],[ dnl
102 enable_[]patsubst([$1], -, _)[]=no
106 # AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?):
107 # Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run
108 # shell code ACTION-IF-NOT-ENABLED.
110 AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl
111 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
113 AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl
121 # AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED,
122 # ACTION-IF-NOT-NOT-ENABLED?):
123 # Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly
124 # enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED.
126 # The distinction with AE_IF_FEATURE_DISABLED is that this will also
127 # match a feature that is undefined.
129 # A feature is undefined when it's disabled by default and was not explicitly
130 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
132 AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl
133 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
135 AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl
143 # AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?):
144 # Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run
145 # shell code ACTION-IF-NOT-DISABLED.
147 AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl
148 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
150 AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl
158 # AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?):
159 # Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run
160 # shell code ACTION-IF-NOT-UNDEF.
162 # A feature is undefined when it's disabled by default and was not explicitly
163 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
165 AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl
166 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
168 AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl
176 # AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable
177 # for use in a shell if statement) that will return true if the FEATURE is
180 AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl
181 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
182 test "x$enable_[]FEATURE[]" = xyes dnl
186 dnl Disabled by default, unless already overridden
187 m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE])
190 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
191 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
192 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?):
195 AC_DEFUN([AE_FEATURE],[ dnl
196 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
198 dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes
199 AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl
200 enable_[]FEATURE[]="ae_feature_default_arg"
204 AS_HELP_STRING([--ae_feature_default_switch-$1],dnl
206 case "${enableval}" in
208 enable_[]FEATURE[]=yes
211 enable_[]FEATURE[]=no
214 AC_MSG_ERROR([bad value ${enableval} for feature --$1])
223 AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl
229 m4_popdef([FEATURE])dnl