Source
1
+
#
2
+
# Zabbix
3
+
# Copyright (C) 2001-2023 Zabbix SIA
4
+
#
5
+
# This program is free software; you can redistribute it and/or modify
6
+
# it under the terms of the GNU General Public License as published by
7
+
# the Free Software Foundation; either version 2 of the License, or
8
+
# (at your option) any later version.
9
+
#
10
+
# This program is distributed in the hope that it will be useful,
11
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+
# GNU General Public License for more details.
14
+
#
15
+
# You should have received a copy of the GNU General Public License
16
+
# along with this program; if not, write to the Free Software
17
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
+
#
19
+
20
+
AC_DEFUN([YAML_TRY_LINK],
21
+
[
22
+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
23
+
#include <assert.h>
24
+
#include <yaml.h>
25
+
]],[[
26
+
yaml_parser_t parser;
27
+
28
+
assert(yaml_parser_initialize(&parser));
29
+
]])],[found_yaml="yes"],[AC_MSG_FAILURE([error])])
30
+
])dnl
31
+
32
+
AC_DEFUN([LIBYAML_CHECK_CONFIG],
33
+
[
34
+
AC_ARG_WITH([libyaml],[
35
+
If you want to specify YAML installation directories:
36
+
AS_HELP_STRING([--with-libyaml@<:@=DIR@:>@],[use specific YAML library @<:@default=yes@:>@, DIR is the YAML library install directory.])],
37
+
[
38
+
if test "$withval" = "no"; then
39
+
want_yaml="no"
40
+
_libyaml_dir="no"
41
+
elif test "$withval" = "yes"; then
42
+
want_yaml="yes"
43
+
_libyaml_dir="no"
44
+
else
45
+
want_yaml="yes"
46
+
_libyaml_dir=$withval
47
+
fi
48
+
],
49
+
[
50
+
want_yaml=ifelse([$1],,[yes],[$1])
51
+
_libyaml_dir="no"
52
+
]
53
+
)dnl
54
+
55
+
if test "x$want_yaml" = "xyes"; then
56
+
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
57
+
m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
58
+
59
+
AC_MSG_CHECKING(for yaml-0.1 support)
60
+
if test "x$_libyaml_dir" = "xno"; then
61
+
if test -x "$PKG_CONFIG" && `$PKG_CONFIG --exists yaml-0.1`; then
62
+
YAML_CFLAGS="`$PKG_CONFIG --cflags yaml-0.1`"
63
+
YAML_LDFLAGS="`$PKG_CONFIG --libs yaml-0.1`"
64
+
YAML_LIBRARY_PATH=""
65
+
YAML_LIBS="`$PKG_CONFIG --libs yaml-0.1`"
66
+
found_yaml="yes"
67
+
else
68
+
found_yaml="no"
69
+
AC_MSG_RESULT(no)
70
+
fi
71
+
else
72
+
if test -f $_libyaml_dir/include/yaml.h; then
73
+
YAML_CFLAGS=-I$_libyaml_dir/include
74
+
YAML_LDFLAGS=-L$_libyaml_dir/lib
75
+
YAML_LIBRARY_PATH="$_libyaml_dir/lib"
76
+
YAML_LIBS="-lyaml"
77
+
found_yaml="yes"
78
+
else
79
+
found_yaml="no"
80
+
AC_MSG_RESULT(no)
81
+
fi
82
+
fi
83
+
fi
84
+
85
+
if test "x$found_yaml" = "xyes"; then
86
+
am_save_cflags="$CFLAGS"
87
+
am_save_ldflags="$LDFLAGS"
88
+
am_save_libs="$LIBS"
89
+
90
+
CFLAGS="$CFLAGS $YAML_CFLAGS"
91
+
LDFLAGS="$LDFLAGS $YAML_LDFLAGS"
92
+
LIBS="$LIBS $YAML_LIBS"
93
+
94
+
found_yaml="no"
95
+
YAML_TRY_LINK([no])
96
+
97
+
CFLAGS="$am_save_cflags"
98
+
LDFLAGS="$am_save_ldflags"
99
+
LIBS="$am_save_libs"
100
+
101
+
if test "x$found_yaml" = "xyes"; then
102
+
AC_MSG_RESULT(yes)
103
+
else
104
+
AC_MSG_RESULT(no)
105
+
fi # if test "x$found_yaml" = "xyes"; then
106
+
else
107
+
YAML_CFLAGS=""
108
+
YAML_LDFLAGS=""
109
+
YAML_LIBRARY_PATH=""
110
+
YAML_LIBS=""
111
+
fi # if test "x$found_yaml" = "xyes"; then
112
+
113
+
AC_SUBST(YAML_CFLAGS)
114
+
AC_SUBST(YAML_LDFLAGS)
115
+
AC_SUBST(YAML_LIBRARY_PATH)
116
+
AC_SUBST(YAML_LIBS)
117
+
])dnl