2 dnl virt-arg.m4: Helper macros for adding configure arguments
4 dnl Copyright (C) 2012-2014 Red Hat, Inc.
6 dnl This library is free software; you can redistribute it and/or
7 dnl modify it under the terms of the GNU Lesser General Public
8 dnl License as published by the Free Software Foundation; either
9 dnl version 2.1 of the License, or (at your option) any later version.
11 dnl This library is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 dnl Lesser General Public License for more details.
16 dnl You should have received a copy of the GNU Lesser General Public
17 dnl License along with this library. If not, see
18 dnl <http://www.gnu.org/licenses/>.
23 dnl To be used instead of AC_ARG_WITH
25 dnl See LIBVIRT_ARG_WITH_FEATURE if the argument you're adding is going to
26 dnl be used for switching a feature on and off.
28 dnl LIBVIRT_ARG_WITH([CHECK_NAME], [HELP_DESC], [DEFAULT_ACTION])
30 dnl CHECK_NAME: Suffix/prefix used for variables/flags, in uppercase.
31 dnl HELP_DESC: Description that will appear in configure --help
32 dnl DEFAULT_ACTION: Default configure action
34 dnl LIBVIRT_ARG_WITH([PACKAGER], [Extra packager name], [no])
35 dnl LIBVIRT_ARG_WITH([HTML_DIR], [path to base html directory], [$(datadir)/doc])
37 AC_DEFUN([LIBVIRT_ARG_WITH], [
38 m4_pushdef([check_name], [$1])
39 m4_pushdef([help_desc], [[$2]])
40 m4_pushdef([default_action], [$3])
42 m4_pushdef([check_name_lc], m4_tolower(check_name))
43 m4_pushdef([check_name_dash], m4_translit(check_name_lc, [_], [-]))
45 m4_pushdef([arg_var], [with-]check_name_dash)
46 m4_pushdef([with_var], [with_]check_name_lc)
48 m4_divert_text([DEFAULTS], [with_var][[=]][default_action])
49 AC_ARG_WITH([check_name_lc],
50 [AS_HELP_STRING([[--]arg_var],
51 ]m4_dquote(help_desc)[[ @<:@default=]]m4_dquote(default_action)[[@:>@])])
56 m4_popdef([check_name_dash])
57 m4_popdef([check_name_lc])
59 m4_popdef([default_action])
60 m4_popdef([help_desc])
61 m4_popdef([check_name])
65 dnl To be used instead of AC_ARG_WITH
67 dnl The difference between LIBVIRT_ARG_WITH and this macro is that the former
68 dnl is mostly an enhanced drop-in replacement for AC_ARG_WITH, whereas the
69 dnl latter is tailored for adding an argument that is going to be used to
70 dnl switch a feature on and off: as a consequence, it optionally supports
71 dnl specifying the minimum version for libraries the feature depends on and
72 dnl automatically builds a suitable description from the feature name.
74 dnl LIBVIRT_ARG_WITH_FEATURE([CHECK_NAME], [HELP_NAME], [DEFAULT_ACTION], [MIN_VERSION])
76 dnl CHECK_NAME: Suffix/prefix used for variables/flags, in uppercase.
77 dnl HELP_NAME: Name that will appear in configure --help
78 dnl DEFAULT_ACTION: Default configure action
79 dnl MIN_VERSION: Specify minimal version that will be added to
80 dnl configure --help (optional)
82 dnl LIBVIRT_ARG_WITH_FEATURE([SELINUX], [SeLinux], [check])
83 dnl LIBVIRT_ARG_WITH_FEATURE([GLUSTERFS], [glusterfs], [check], [3.4.1])
85 AC_DEFUN([LIBVIRT_ARG_WITH_FEATURE], [
86 m4_pushdef([check_name], [$1])
87 m4_pushdef([help_name], [[$2]])
88 m4_pushdef([default_action], [$3])
89 m4_pushdef([min_version], [$4])
91 m4_pushdef([check_name_lc], m4_tolower(check_name))
92 m4_pushdef([check_name_dash], m4_translit(check_name_lc, [_], [-]))
94 m4_pushdef([arg_var], [with-]check_name_dash)
95 m4_pushdef([with_var], [with_]check_name_lc)
97 m4_pushdef([version_text], m4_ifnblank(min_version, [[ (>= ]]min_version[[)]]))
99 m4_divert_text([DEFAULTS], [with_var][[=]][default_action])
100 AC_ARG_WITH([check_name_lc],
101 [AS_HELP_STRING([[--]arg_var],
102 [with ]]m4_dquote(help_name)m4_dquote(version_text)[[ support @<:@default=]]m4_dquote(default_action)[[@:>@])])
104 m4_popdef([version_text])
106 m4_popdef([with_var])
109 m4_popdef([check_name_dash])
110 m4_popdef([check_name_lc])
112 m4_popdef([min_version])
113 m4_popdef([default_action])
114 m4_popdef([help_name])
115 m4_popdef([check_name])
119 dnl To be used instead of AC_ARG_ENABLE
121 dnl LIBVIRT_ARG_ENABLE([CHECK_NAME], [HELP_DESC], [DEFAULT_ACTION])
123 dnl CHECK_NAME: Suffix/prefix used for variables/flags, in uppercase.
124 dnl HELP_DESC: Description that will appear in configure --help
125 dnl DEFAULT_ACTION: Default configure action
127 dnl LIBVIRT_ARG_ENABLE([DEBUG], [enable debugging output], [yes])
129 AC_DEFUN([LIBVIRT_ARG_ENABLE], [
130 m4_pushdef([check_name], [$1])
131 m4_pushdef([help_desc], [[$2]])
132 m4_pushdef([default_action], [$3])
134 m4_pushdef([check_name_lc], m4_tolower(check_name))
135 m4_pushdef([check_name_dash], m4_translit(check_name_lc, [_], [-]))
137 m4_pushdef([arg_var], [enable-]check_name_dash)
138 m4_pushdef([enable_var], [enable_]check_name_lc)
140 m4_divert_text([DEFAULTS], [enable_var][[=]][default_action])
141 AC_ARG_ENABLE([check_name_lc],
142 [AS_HELP_STRING([[--]arg_var],
143 ]m4_dquote(help_desc)[[ @<:@default=]]m4_dquote(default_action)[[@:>@])])
145 m4_popdef([enable_var])
148 m4_popdef([check_name_dash])
149 m4_popdef([check_name_lc])
151 m4_popdef([default_action])
152 m4_popdef([help_desc])
153 m4_popdef([check_name])