1 # SPDX-FileCopyrightText: 2020 Michael Jeanson <mjeanson@efficios.com>
2 # SPDX-FileCopyrightText: 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
4 # SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro
8 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
9 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
10 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?)
14 # AE_FEATURE is a simple wrapper for AC_ARG_ENABLE.
16 # FEATURE-NAME should consist only of alphanumeric characters, dashes,
17 # plus signs, and dots.
19 # FEATURE-DESCRIPTION will be formatted with AS_HELP_STRING.
21 # If the user gave configure the option --enable-FEATURE or --disable-FEATURE,
22 # run shell commands ACTION-IF-GIVEN. If neither option was given, run shell
23 # commands ACTION-IF-NOT-GIVEN. The name feature indicates an optional
25 # If the feature is enabled, run shell commands ACTION-IF-ENABLED, if it is
26 # disabled, run shell commands ACTION-IF-NOT-ENABLED.
28 # A FEATURE has 3 different states, enabled, disabled and undefined. The first
29 # two are self explanatory, the third state means it's disabled by default
30 # and it was not explicitly enabled or disabled by the user or by the
31 # AE_FEATURE_ENABLE and AE_FEATURE_DISABLE macros.
33 # A feature is disabled by default, in order to change this behaviour use the
34 # AE_FEATURE_DEFAULT_ENABLE and AE_FEATURE_DEFAULT_DISABLE
39 # AE_FEATURE_DEFAULT_ENABLE
40 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support])
44 # AE_FEATURE_DEFAULT_DISABLE
45 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support])
46 # AM_CONDITIONAL(YYYYY, AE_IS_FEATURE_ENABLED([feature_yyyyy]))
48 # AE_FEATURE_DEFAULT_ENABLE
53 # Use AE_FEATURE_ENABLE or AE_FEATURE_DISABLE in order to
54 # enable or disable a specific feature.
56 # Another simple example:
58 # AS_IF([some_test_here],[AE_FEATURE_ENABLE(feature_xxxxx)],[])
60 # AE_FEATURE(feature_xxxxx, [turns on/off XXXXX support],
61 # HAVE_XXXXX, [Define if you want XXXXX support])
62 # AE_FEATURE(feature_yyyyy, [turns on/off YYYYY support],
63 # HAVE_YYYYY, [Define if you want YYYYY support])
67 # NOTE: AE_FEATURE_ENABLE/DISABLE() must be placed first of the relative
68 # AE_FEATURE() macro if you want the the proper ACTION-IF-ENABLED and
69 # ACTION-IF-NOT-ENABLED to run.
74 # AE_FEATURE_DEFAULT_ENABLE: The next feature defined with AE_FEATURE will
76 AC_DEFUN([AE_FEATURE_DEFAULT_ENABLE], [
77 m4_define([ae_feature_default_arg], [yes])
78 m4_define([ae_feature_default_switch], [disable])
82 # AE_FEATURE_DEFAULT_DISABLE: The next feature defined with AE_FEATURE will
85 AC_DEFUN([AE_FEATURE_DEFAULT_DISABLE], [
86 m4_define([ae_feature_default_arg], [no])
87 m4_define([ae_feature_default_switch], [enable])
91 # AE_FEATURE_ENABLE(FEATURE-NAME): Enable the FEATURE, this will override the
92 # user's choice if it was made.
94 AC_DEFUN([AE_FEATURE_ENABLE],[ dnl
95 enable_[]patsubst([$1], -, _)[]=yes
99 # AE_FEATURE_DISABLE(FEATURE-NAME): Disable the FEATURE, this will override the
100 # user's choice if it was made.
102 AC_DEFUN([AE_FEATURE_DISABLE],[ dnl
103 enable_[]patsubst([$1], -, _)[]=no
107 # AE_IF_FEATURE_ENABLED(FEATURE-NAME, ACTION-IF-ENABLED, ACTION-IF-NOT-ENABLED?):
108 # Run shell code ACTION-IF-ENABLED if the FEATURE is enabled, otherwise run
109 # shell code ACTION-IF-NOT-ENABLED.
111 AC_DEFUN([AE_IF_FEATURE_ENABLED],[ dnl
112 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
114 AS_IF([test "$enable_[]FEATURE[]" = yes],[ dnl
122 # AE_IF_FEATURE_NOT_ENABLED(FEATURE-NAME, ACTION-IF-NOT-ENABLED,
123 # ACTION-IF-NOT-NOT-ENABLED?):
124 # Run shell code ACTION-IF-NOT-ENABLED if the FEATURE is not explicitly
125 # enabled, otherwise run shell code ACTION-IF-NOT-NOT-DISABLED.
127 # The distinction with AE_IF_FEATURE_DISABLED is that this will also
128 # match a feature that is undefined.
130 # A feature is undefined when it's disabled by default and was not explicitly
131 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
133 AC_DEFUN([AE_IF_FEATURE_NOT_ENABLED],[ dnl
134 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
136 AS_IF([test "$enable_[]FEATURE[]" != yes],[ dnl
144 # AE_IF_FEATURE_DISABLED(FEATURE-NAME, ACTION-IF-DISABLED, ACTION-IF-NOT-DISABLED?):
145 # Run shell code ACTION-IF-DISABLED if the FEATURE is disabled, otherwise run
146 # shell code ACTION-IF-NOT-DISABLED.
148 AC_DEFUN([AE_IF_FEATURE_DISABLED],[ dnl
149 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
151 AS_IF([test "$enable_[]FEATURE[]" = no],[ dnl
159 # AE_IF_FEATURE_UNDEF(FEATURE-NAME, ACTION-IF-UNDEF, ACTION-IF-NOT-UNDEF?):
160 # Run shell code ACTION-IF-UNDEF if the FEATURE is undefined, otherwise run
161 # shell code ACTION-IF-NOT-UNDEF.
163 # A feature is undefined when it's disabled by default and was not explicitly
164 # enabled or disabled by the user or by AE_FEATURE_ENABLE/DISABLE.
166 AC_DEFUN([AE_IF_FEATURE_UNDEF],[ dnl
167 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
169 AS_IF([test "x$enable_[]FEATURE[]" = x],[ dnl
177 # AE_IS_FEATURE_ENABLED(FEATURE-NAME): outputs a shell condition (suitable
178 # for use in a shell if statement) that will return true if the FEATURE is
181 AC_DEFUN([AE_IS_FEATURE_ENABLED],[dnl
182 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
183 test "x$enable_[]FEATURE[]" = xyes dnl
187 dnl Disabled by default, unless already overridden
188 m4_ifndef([ae_feature_default_arg],[AE_FEATURE_DEFAULT_DISABLE])
191 # AE_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION,
192 # ACTION-IF-GIVEN?, ACTION-IF-NOT-GIVEN?,
193 # ACTION-IF-ENABLED?, ACTION-IF-NOT-ENABLED?):
196 AC_DEFUN([AE_FEATURE],[ dnl
197 m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
199 dnl If the option wasn't specified and the default is enabled, set enable_FEATURE to yes
200 AS_IF([test "x$enable_[]FEATURE[]" = x && test "ae_feature_default_arg" = yes],[ dnl
201 enable_[]FEATURE[]="ae_feature_default_arg"
205 AS_HELP_STRING([--ae_feature_default_switch-$1],dnl
207 case "${enableval}" in
209 enable_[]FEATURE[]=yes
212 enable_[]FEATURE[]=no
215 AC_MSG_ERROR([bad value ${enableval} for feature --$1])
224 AS_IF([test "$enable_[]FEATURE[]" = yes],[: dnl
230 m4_popdef([FEATURE])dnl