1 dnl Autoconf helper functions for the SysDB plugin handling.
2 dnl
3 dnl Copyright (C) 2005-2012 Florian 'octo' Forster <octo@verplant.org>
4 dnl Copyright (C) 2009-2012 Sebastian 'tokkee' Harl <sh@tokkee.org>
5 dnl
6 dnl This program is free software; you can redistribute it and/or modify it
7 dnl under the terms of the GNU General Public License as published by the
8 dnl Free Software Foundation; only version 2 of the License is applicable.
9 dnl
10 dnl This program is distributed in the hope that it will be useful, but
11 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 dnl General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License along
16 dnl with this program; if not, write to the Free Software Foundation, Inc.,
17 dnl 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 AC_DEFUN([AC_SDB_PLUGIN_INIT],
20 [
21 dependency_error="no"
22 dependency_warning="no"
23 AC_ARG_ENABLE([all-plugins],
24 AS_HELP_STRING([--enable-all-plugins],
25 [enable all plugins (auto by default)]),
26 [
27 if test "x$enableval" = "xyes"; then
28 enable_all_plugins="yes"
29 else if test "x$enableval" = "xauto"; then
30 enable_all_plugins="auto"
31 else
32 enable_all_plugins="no"
33 fi; fi
34 ],
35 [enable_all_plugins="auto"]
36 )
37 ]
38 )
40 dnl AC_SDB_PLUGIN(name, default, info)
41 dnl
42 dnl Based on AC_PLUGIN of the collectd package.
43 AC_DEFUN([AC_SDB_PLUGIN],
44 [
45 enable_plugin="no"
46 force="no"
47 AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1], [$3]),
48 [
49 if test "x$enableval" = "xyes"; then
50 enable_plugin="yes"
51 else if test "x$enableval" = "xforce"; then
52 enable_plugin="yes"
53 force="yes"
54 else
55 enable_plugin="no (disabled on command line)"
56 fi; fi
57 ],
58 [
59 if test "x$enable_all_plugins" = "xauto"; then
60 if test "x$2" = "xyes"; then
61 enable_plugin="yes"
62 else
63 enable_plugin="$2"
64 fi
65 else
66 enable_plugin="$enable_all_plugins"
67 fi
68 ]
69 )
70 if test "x$enable_plugin" = "xyes"; then
71 if test "x$2" = "xyes" || test "x$force" = "xyes"; then
72 AC_DEFINE([HAVE_PLUGIN_]m4_translit(m4_toupper([$1]),[-],[_]), 1, [Define to 1 if the $1 plugin is enabled.])
73 if test "x$2" != "xyes"; then
74 dependency_warning="yes"
75 fi
76 else # User passed "yes" but dependency checking yielded "no" => Dependency problem.
77 dependency_error="yes"
78 enable_plugin="no (dependency error)"
79 fi
80 fi
81 AM_CONDITIONAL([BUILD_PLUGIN_]m4_translit(m4_toupper([$1]),[-][_]), test "x$enable_plugin" = "xyes")
82 m4_translit(enable_$1,[-],[_])="$enable_plugin"
83 ]
84 )