Source
45
45
])dnl
46
46
47
47
AC_DEFUN([LIBOPENSSL_ACCEPT_VERSION],
48
48
[
49
49
# Zabbix minimal supported version of OpenSSL.
50
50
# Version numbering scheme is described in /usr/include/openssl/opensslv.h.
51
51
52
52
# Is it OpenSSL 3? Test OPENSSL_VERSION_MAJOR - it is defined only in OpenSSL 3.0.
53
53
found_openssl_version=`grep OPENSSL_VERSION_MAJOR "$1" | head -n 1`
54
54
found_openssl_version=`expr "$found_openssl_version" : '^#.*define.*OPENSSL_VERSION_MAJOR.*\(3\)$'`
55
+
mt_required="$2"
55
56
56
57
if test "$found_openssl_version" = "3"; then
57
58
# OpenSSL 3.x found
58
59
accept_openssl_version="yes"
59
60
else # Is it OpenSSL 1.0.1 - 1.1.1 or LibreSSL?
60
61
# These versions use similar version numbering scheme:
61
62
# specify version number without the last byte (status). E.g., version 1.0.1 is 0x1000100f, but without the
62
63
# last byte it is 0x1000100.
63
64
minimal_openssl_version=0x1000100
65
+
test "$mt_required" = "yes" && minimal_openssl_version=0x1010000
64
66
65
67
found_openssl_version=`grep OPENSSL_VERSION_NUMBER "$1"`
66
68
found_openssl_version=`expr "$found_openssl_version" : '.*\(0x[[0-f]][[0-f]][[0-f]][[0-f]][[0-f]][[0-f]][[0-f]]\).*'`
67
69
68
70
# compare versions lexicographically
69
71
openssl_version_check=`expr $found_openssl_version \>\= $minimal_openssl_version`
70
72
71
73
if test "$openssl_version_check" = "1"; then
72
74
accept_openssl_version="yes"
73
75
else
87
89
_libopenssl_dir="no"
88
90
elif test "$withval" = "yes"; then
89
91
want_openssl="yes"
90
92
_libopenssl_dir="no"
91
93
else
92
94
want_openssl="yes"
93
95
_libopenssl_dir=$withval
94
96
_libopenssl_dir_lib="$withval/lib"
95
97
fi
96
98
accept_openssl_version="no"
99
+
mt_required=$2
97
100
],[want_openssl=ifelse([$1],,[no],[$1])]
98
101
)
99
102
100
103
if test "x$want_openssl" = "xyes"; then
101
104
102
105
if test "x$enable_static_libs" = "xyes"; then
103
106
test "x$static_linking_support" = "xno" -a -z "$_libopenssl_dir_lib" && AC_MSG_ERROR(["OpenSSL: Compiler not support statically linked libs from default folders"])
104
107
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
105
108
m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
106
109
test -z "$PKG_CONFIG" -a -z "$_libopenssl_dir_lib" && AC_MSG_ERROR([Not found pkg-config library])
109
112
m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
110
113
fi
111
114
112
115
AC_MSG_CHECKING(for OpenSSL support)
113
116
if test "x$_libopenssl_dir" = "xno"; then # if OpenSSL directory is not specified
114
117
if test -f /usr/local/include/openssl/ssl.h -a -f /usr/local/include/openssl/crypto.h; then
115
118
OPENSSL_CFLAGS=-I/usr/local/include
116
119
OPENSSL_LDFLAGS=-L/usr/local/lib
117
120
OPENSSL_LIBS="-lssl -lcrypto"
118
121
found_openssl="yes"
119
-
LIBOPENSSL_ACCEPT_VERSION([/usr/local/include/openssl/opensslv.h])
122
+
LIBOPENSSL_ACCEPT_VERSION([/usr/local/include/openssl/opensslv.h], [$mt_required])
120
123
elif test -f /usr/include/openssl/ssl.h -a -f /usr/include/openssl/crypto.h; then
121
124
OPENSSL_CFLAGS=-I/usr/include
122
125
OPENSSL_LDFLAGS=-L/usr/lib
123
126
OPENSSL_LIBS="-lssl -lcrypto"
124
127
found_openssl="yes"
125
-
LIBOPENSSL_ACCEPT_VERSION([/usr/include/openssl/opensslv.h])
128
+
LIBOPENSSL_ACCEPT_VERSION([/usr/include/openssl/opensslv.h], [$mt_required])
126
129
else # libraries are not found in default directories
127
130
found_openssl="no"
128
131
AC_MSG_RESULT(no)
129
132
fi
130
133
else # search in the specified OpenSSL directory
131
134
if test -f $_libopenssl_dir/include/openssl/ssl.h -a -f $_libopenssl_dir/include/openssl/crypto.h; then
132
135
OPENSSL_CFLAGS=-I$_libopenssl_dir/include
133
136
134
137
if test -d $_libopenssl_dir/lib64; then
135
138
OPENSSL_LDFLAGS=-L$_libopenssl_dir/lib64
136
139
elif test -d $_libopenssl_dir/lib/64; then
137
140
OPENSSL_LDFLAGS=-L$_libopenssl_dir/lib/64
138
141
else
139
142
OPENSSL_LDFLAGS=-L$_libopenssl_dir/lib
140
143
fi
141
144
142
145
OPENSSL_LIBS="-lssl -lcrypto"
143
146
found_openssl="yes"
144
-
LIBOPENSSL_ACCEPT_VERSION([$_libopenssl_dir/include/openssl/opensslv.h])
147
+
LIBOPENSSL_ACCEPT_VERSION([$_libopenssl_dir/include/openssl/opensslv.h], [$mt_required])
145
148
else # libraries are not found in specified directories
146
149
found_openssl="no"
147
150
AC_MSG_RESULT(no)
148
151
fi
149
152
fi
150
153
fi
151
154
152
155
if test "x$found_openssl" = "xyes"; then
153
156
am_save_cflags="$CFLAGS"
154
157
am_save_ldflags="$LDFLAGS"