1 # Copyright (c) 2013 Holger Weiss <holger@weiss.in-berlin.de>
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
7 # 1. Redistributions of source code must retain the above copyright notice, this
8 # list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright notice,
11 # this list of conditions and the following disclaimer in the documentation
12 # and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 # Check the availability of libConfuse 2.6 or newer. As this is a required
28 # dependency, we bail out if the user specified "--without-confuse", if we fail
29 # to link against the library, or if the confuse version we found is too old.
30 # On success, we set the output variables CONFUSECPPFLAGS, CONFUSELDFLAGS, and
31 # CONFUSELIBS to appropriate values. (Why are there no underscores in these
32 # variable names? Because Automake treats names like "foo_CPPFLAGS" specially.)
33 AC_DEFUN([NSCA_LIB_CONFUSE],
35 nsca_save_CPPFLAGS=$CPPFLAGS
36 nsca_save_LDFLAGS=$LDFLAGS
37 AC_ARG_WITH([confuse],
38 [AS_HELP_STRING([--with-confuse=PATH],
39 [use the libConfuse library in PATH])],
40 [nsca_confuse_dir=$with_confuse],
41 [nsca_confuse_dir=yes])
42 AC_MSG_CHECKING([whether libConfuse is desired])
43 AS_CASE([$nsca_confuse_dir],
46 AC_MSG_ERROR([building without libConfuse is not supported])],
49 AC_MSG_CHECKING([for the location of libConfuse])
50 nsca_confuse_dir=unknown
51 for _nsca_confuse_dir in "$ac_pwd/lib/confuse" /usr /usr/local /usr/pkg
52 do dnl Solaris 10 doesn't have "test -e".
53 AS_IF([test -r "$_nsca_confuse_dir/include/confuse.h"],
54 [nsca_confuse_dir=$_nsca_confuse_dir
57 AS_IF([test "x$nsca_confuse_dir" != xunknown],
58 [AC_MSG_RESULT([$nsca_confuse_dir])],
59 [AC_MSG_RESULT([not found, continuing anyway])])],
60 [AC_MSG_RESULT([yes])])
61 AS_IF([test "x$nsca_confuse_dir" != xunknown &&
62 test "x$nsca_confuse_dir" != x/usr],
63 [CONFUSECPPFLAGS="-I$nsca_confuse_dir/include"
64 CONFUSELDFLAGS="-L$nsca_confuse_dir/lib"
65 CPPFLAGS="$CONFUSECPPFLAGS $CPPFLAGS"
66 LDFLAGS="$CONFUSELDFLAGS $LDFLAGS"])
67 AC_CHECK_HEADER([confuse.h], [],
68 [AC_MSG_ERROR([libConfuse header file not found])])
69 AC_CHECK_LIB([confuse], [cfg_init],
70 [CONFUSELIBS='-lconfuse'],
71 [AC_CHECK_LIB([intl], [cfg_init],
72 [CONFUSELIBS='-lconfuse -lintl'],
73 [AC_CHECK_LIB([iconv], [cfg_init],
74 [CONFUSELIBS='-lconfuse -lintl -liconv'],
75 [AC_MSG_FAILURE([cannot link with libConfuse])],
76 [-lconfuse -lintl -liconv])],
78 AC_CHECK_DECL([CFGF_NO_TITLE_DUPES], [],
79 [AC_MSG_ERROR([libConfuse too old, version 2.6 or newer is required])],
80 [[#include <confuse.h>]])
81 AC_SUBST([CONFUSECPPFLAGS])
82 AC_SUBST([CONFUSELDFLAGS])
83 AC_SUBST([CONFUSELIBS])
84 CPPFLAGS=$nsca_save_CPPFLAGS
85 LDFLAGS=$nsca_save_LDFLAGS
88 dnl vim:set joinspaces textwidth=80: