xref: /freebsd/contrib/ldns/m4/ax_config_feature.m4 (revision 190cef3d52236565eb22e18b33e9e865ec634aa3)
1# ===========================================================================
2#     http://www.gnu.org/software/autoconf-archive/ax_config_feature.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_CONFIG_FEATURE(FEATURE-NAME, FEATURE-DESCRIPTION, DEFINE, DEFINE-DESCRIPTION, [ACTION-IF-ENABLED [, ACTION-IF-NOT-ENABLED]])
8#
9# DESCRIPTION
10#
11#   AX_CONFIG_FEATURE is a simple wrapper for AC_ARG_ENABLE, it enables the
12#   feature FEATURE-NAME and AC_DEFINEs the passed DEFINE, depending on the
13#   user choice. DESCRIPTION will be used for AC_DEFINEs. ACTION-IF-ENABLED
14#   and ACTION-IF-NOT-ENABLED are the actions that will be run. A feature is
15#   enabled by default, in order to change this behaviour use the
16#   AX_CONFIG_FEATURE_DEFAULT_ENABLED and AX_CONFIG_FEATURE_DEFAULT_DISABLED
17#   macros.
18#
19#   A simple example:
20#
21#     AX_CONFIG_FEATURE_DEFAULT_ENABLED
22#     AX_CONFIG_FEATURE(feature_xxxxx, [turns on/off XXXXX support],
23#                       HAVE_XXXXX, [Define if you want XXXXX support])
24#
25#     ...
26#
27#     AX_CONFIG_FEATURE_DEFAULT_DISABLED
28#     AX_CONFIG_FEATURE(feature_yyyyy, [turns on/off YYYYY support],
29#                       HAVE_YYYYY, [Define if you want YYYYY support],
30#                       [enable_yyyyy="yes"], [enable_yyyyy="no"])
31#     AM_CONDITIONAL(YYYYY, [test "$enable_yyyyy" = "yes"])
32#
33#     AX_CONFIG_FEATURE_DEFAULT_ENABLED
34#     AX_CONFIG_FEATURE(...)
35#
36#     ...
37#
38#   If you have lot of features and you want a verbose dumping of each user
39#   selection use AX_CONFIG_FEATURE_VERBOSE. Use AX_CONFIG_FEATURE_SILENT in
40#   order to remove a previously AX_CONFIG_FEATURE_VERBOSE. By default
41#   features are silent.
42#
43#   Use AX_CONFIG_FEATURE_ENABLE or AX_CONFIG_FEATURE_DISABLE in order to
44#   enable or disable a specific feature.
45#
46#   Another simple example:
47#
48#     AS_IF([some_test_here],[AX_CONFIG_FEATURE_ENABLE(feature_xxxxx)],[])
49#
50#     AX_CONFIG_FEATURE(feature_xxxxx, [turns on/off XXXXX support],
51#                       HAVE_XXXXX, [Define if you want XXXXX support])
52#     AX_CONFIG_FEATURE(feature_yyyyy, [turns on/off YYYYY support],
53#                       HAVE_YYYYY, [Define if you want YYYYY support],
54#                       [enable_yyyyy="yes"], [enable_yyyyy="no"])
55#
56#     ...
57#
58#   NOTE: AX_CONFIG_FEATURE_ENABLE() must be placed first of the relative
59#   AX_CONFIG_FEATURE() macro ...
60#
61# LICENSE
62#
63#   Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
64#
65#   This program is free software; you can redistribute it and/or modify it
66#   under the terms of the GNU General Public License as published by the
67#   Free Software Foundation; either version 2 of the License, or (at your
68#   option) any later version.
69#
70#   This program is distributed in the hope that it will be useful, but
71#   WITHOUT ANY WARRANTY; without even the implied warranty of
72#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
73#   Public License for more details.
74#
75#   You should have received a copy of the GNU General Public License along
76#   with this program. If not, see <http://www.gnu.org/licenses/>.
77#
78#   As a special exception, the respective Autoconf Macro's copyright owner
79#   gives unlimited permission to copy, distribute and modify the configure
80#   scripts that are the output of Autoconf when processing the Macro. You
81#   need not follow the terms of the GNU General Public License when using
82#   or distributing such scripts, even though portions of the text of the
83#   Macro appear in them. The GNU General Public License (GPL) does govern
84#   all other use of the material that constitutes the Autoconf Macro.
85#
86#   This special exception to the GPL applies to versions of the Autoconf
87#   Macro released by the Autoconf Archive. When you make and distribute a
88#   modified version of the Autoconf Macro, you may extend this special
89#   exception to the GPL to apply to your modified version as well.
90
91#serial 10
92
93AC_DEFUN([AX_CONFIG_FEATURE],[ dnl
94m4_pushdef([FEATURE], patsubst([$1], -, _))dnl
95
96AC_ARG_ENABLE([$1],AS_HELP_STRING([--enable-$1],[$2]),[
97case "${enableval}" in
98   yes)
99     ax_config_feature_[]FEATURE[]="yes"
100     ;;
101   no)
102     ax_config_feature_[]FEATURE[]="no"
103     ;;
104   *)
105     AC_MSG_ERROR([bad value ${enableval} for feature --$1])
106     ;;
107esac
108])
109
110AS_IF([test "$ax_config_feature_[]FEATURE[]" = yes],[ dnl
111  AC_DEFINE([$3])
112  $5
113  AS_IF([test "$ax_config_feature_verbose" = yes],[ dnl
114    AC_MSG_NOTICE([Feature $1 is enabled])
115  ])
116],[ dnl
117  $6
118  AS_IF([test "$ax_config_feature_verbose" = yes],[ dnl
119    AC_MSG_NOTICE([Feature $1 is disabled])
120  ])
121])
122
123AH_TEMPLATE([$3],[$4])
124
125m4_popdef([FEATURE])dnl
126])
127
128dnl Feature global
129AC_DEFUN([AX_CONFIG_FEATURE_VERBOSE],[ dnl
130  ax_config_feature_verbose=yes
131])
132
133dnl Feature global
134AC_DEFUN([AX_CONFIG_FEATURE_SILENT],[ dnl
135  ax_config_feature_verbose=no
136])
137
138dnl Feature specific
139AC_DEFUN([AX_CONFIG_FEATURE_DEFAULT_ENABLED], [
140  ax_config_feature_[]FEATURE[]_default=yes
141])
142
143dnl Feature specific
144AC_DEFUN([AX_CONFIG_FEATURE_DEFAULT_DISABLED], [
145  ax_config_feature_[]FEATURE[]_default=no
146])
147
148dnl Feature specific
149AC_DEFUN([AX_CONFIG_FEATURE_ENABLE],[ dnl
150  ax_config_feature_[]patsubst([$1], -, _)[]=yes
151])
152
153dnl Feature specific
154AC_DEFUN([AX_CONFIG_FEATURE_DISABLE],[ dnl
155  ax_config_feature_[]patsubst([$1], -, _)[]=no
156])
157