forked from zabbix/zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libgnutls.m4
140 lines (127 loc) · 4.47 KB
/
libgnutls.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# GnuTLS LIBGNUTLS_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
# Derived from libssh2.m4
#
# Checks for GnuTLS library libgnutls. DEFAULT-ACTION is the string
# yes or no to specify whether to default to --with-gnutls or
# --without-gnutls. If not supplied, DEFAULT-ACTION is no.
#
# This macro #defines HAVE_GNUTLS if a required header files are
# found, and sets @GNUTLS_LDFLAGS@, @GNUTLS_CFLAGS@ and @GNUTLS_LIBS@
# to the necessary values.
#
# Users may override the detected values by doing something like:
# GNUTLS_LIBS="-lgnutls" GNUTLS_CFLAGS="-I/usr/myinclude" ./configure
#
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([LIBGNUTLS_TRY_LINK],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <gnutls/gnutls.h>
]], [[
gnutls_global_init();
]])],[found_gnutls="yes"],[])
])dnl
AC_DEFUN([LIBGNUTLS_ACCEPT_VERSION],
[
# Zabbix minimal supported version of libgnutls:
minimal_gnutls_version_major=3
minimal_gnutls_version_minor=1
minimal_gnutls_version_patch=18
# get version
found_gnutls_version_major=`cat $1 | $EGREP \#define.*GNUTLS_VERSION_MAJOR | $AWK '{print @S|@3;}'`
found_gnutls_version_minor=`cat $1 | $EGREP \#define.*GNUTLS_VERSION_MINOR | $AWK '{print @S|@3;}'`
found_gnutls_version_patch=`cat $1 | $EGREP \#define.*GNUTLS_VERSION_PATCH | $AWK '{print @S|@3;}'`
if test $((found_gnutls_version_major)) -gt $((minimal_gnutls_version_major)); then
accept_gnutls_version="yes"
elif test $((found_gnutls_version_major)) -lt $((minimal_gnutls_version_major)); then
accept_gnutls_version="no"
elif test $((found_gnutls_version_minor)) -gt $((minimal_gnutls_version_minor)); then
accept_gnutls_version="yes"
elif test $((found_gnutls_version_minor)) -lt $((minimal_gnutls_version_minor)); then
accept_gnutls_version="no"
elif test $((found_gnutls_version_patch)) -ge $((minimal_gnutls_version_patch)); then
accept_gnutls_version="yes"
else
accept_gnutls_version="no"
fi;
])dnl
AC_DEFUN([LIBGNUTLS_CHECK_CONFIG],
[
AC_ARG_WITH(gnutls,[
If you want to use encryption provided by GnuTLS library:
AS_HELP_STRING([--with-gnutls@<:@=DIR@:>@],[use GnuTLS package @<:@default=no@:>@, DIR is the libgnutls install directory.])],
[
if test "$withval" = "no"; then
want_gnutls="no"
_libgnutls_dir="no"
elif test "$withval" = "yes"; then
want_gnutls="yes"
_libgnutls_dir="no"
else
want_gnutls="yes"
_libgnutls_dir=$withval
fi
accept_gnutls_version="no"
],[want_gnutls=ifelse([$1],,[no],[$1])]
)
if test "x$want_gnutls" = "xyes"; then
AC_MSG_CHECKING(for GnuTLS support)
if test "x$_libgnutls_dir" = "xno"; then
if test -f /usr/local/include/gnutls/gnutls.h; then
GNUTLS_CFLAGS=-I/usr/local/include
GNUTLS_LDFLAGS=-L/usr/local/lib
GNUTLS_LIBS="-lgnutls"
found_gnutls="yes"
LIBGNUTLS_ACCEPT_VERSION([/usr/local/include/gnutls/gnutls.h])
elif test -f /usr/include/gnutls/gnutls.h; then
GNUTLS_CFLAGS=-I/usr/include
GNUTLS_LDFLAGS=-L/usr/lib
GNUTLS_LIBS="-lgnutls"
found_gnutls="yes"
LIBGNUTLS_ACCEPT_VERSION([/usr/include/gnutls/gnutls.h])
else #libraries are not found in default directories
found_gnutls="no"
AC_MSG_RESULT(no)
fi
else
if test -f $_libgnutls_dir/include/gnutls/gnutls.h; then
GNUTLS_CFLAGS=-I$_libgnutls_dir/include
GNUTLS_LDFLAGS=-L$_libgnutls_dir/lib
GNUTLS_LIBS="-lgnutls"
found_gnutls="yes"
LIBGNUTLS_ACCEPT_VERSION([$_libgnutls_dir/include/gnutls/gnutls.h])
else
found_gnutls="no"
AC_MSG_RESULT(no)
fi
fi
fi
if test "x$found_gnutls" = "xyes"; then
am_save_cflags="$CFLAGS"
am_save_ldflags="$LDFLAGS"
am_save_libs="$LIBS"
CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
LDFLAGS="$LDFLAGS $GNUTLS_LDFLAGS"
LIBS="$LIBS $GNUTLS_LIBS"
found_gnutls="no"
LIBGNUTLS_TRY_LINK([no])
CFLAGS="$am_save_cflags"
LDFLAGS="$am_save_ldflags"
LIBS="$am_save_libs"
if test "x$found_gnutls" = "xyes"; then
AC_DEFINE([HAVE_GNUTLS], 1, [Define to 1 if you have the 'libgnutls' library (-lgnutls)])
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
GNUTLS_CFLAGS=""
GNUTLS_LDFLAGS=""
GNUTLS_LIBS=""
fi
fi
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LDFLAGS)
AC_SUBST(GNUTLS_LIBS)
])dnl