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
|
From 6a8b5ee14acee6c258bbaeb8b148ee0dd0d62d3d Mon Sep 17 00:00:00 2001
From: "Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be>
Date: Fri, 16 Feb 2018 15:36:59 +0100
Subject: [PATCH] configure.ac: use pkg-config for openssl
It is better to use pkg-config to detect openssl if that is possible.
pkg-config will add e.g. -lz and -ldl when needed. If pkg-config
fails, fall back to the old approach of detecting headers and libs.
Some of the additional openssl support (e.g. adding -ldl) is moved
inside the non-pkg-config path.
Since AC_CHECK_LIBS adds the library found to LIBS, do the same in
the pkg-config case. Normally the Makefile.am should instead use
OPENSSL_LIBS where needed, but this is not done consistently.
When --with-openssl=DIR is given, still perform the test (both with
pkg-config and by checking headers and libs). I.e., remove
$specialssldir.
While we're at it, simplify the headers checks by merging them into a
single AC_CHECK_HEADERS.
Note that it is (still) not an error when openssl is not found,
although the build will then fail.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
configure.ac | 67 ++++++++++++++++++++++--------------------------------------
1 file changed, 24 insertions(+), 43 deletions(-)
diff --git a/configure.ac b/configure.ac
index 4874c0b..ccab9f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,6 @@ AC_CANONICAL_HOST
use_openssl="yes"
use_libev="yes"
-specialssldir=""
AC_ARG_WITH(openssl,
[AS_HELP_STRING([--with-openssl=DIR],
[Use optional openssl libs and includes from [DIR]/lib/ and [DIR]/include/openssl/])],
@@ -27,7 +26,6 @@ AC_ARG_WITH(openssl,
use_openssl="no"
;;
*)
- specialssldir="$with_openssl"
LDFLAGS="$LDFLAGS -L$with_openssl/lib"
CPPFLAGS="-I$with_openssl/include $CPPFLAGS"
;;
@@ -139,59 +137,42 @@ AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_REALLOC
AC_CHECK_FUNCS([clock_gettime dup2 gethostbyname gettimeofday inet_ntoa malloc memmove memset select socket strcasecmp strchr strdup strerror strncasecmp strrchr uname sched_yield pthread_yield pthread_yield_np])
-# OpenSSL requires dlopen on some platforms
-AC_SEARCH_LIBS(dlopen, dl)
-
# If they didn't specify it, we try to find it
-if test "$use_openssl" = "yes" -a -z "$specialssldir" ; then
- AC_CHECK_HEADER(openssl/ssl.h,,
+if test "$use_openssl" = "yes" ; then
+ # First try pkg-config; fall back to headers/libs check
+ PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.0],
+ [LIBS="$OPENSSL_LIBS $LIBS"],
+ [AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h openssl/rand.h],,
[ use_openssl="no"
- AC_MSG_WARN([Failed to find openssl/ssl.h so OpenSSL will not be used.
- If it is installed you can try the --with-openssl=DIR argument]) ])
-
- if test "$use_openssl" = "yes"; then
- AC_CHECK_HEADER(openssl/err.h,,
- [ use_openssl="no"
- AC_MSG_WARN([Failed to find openssl/err.h so OpenSSL will not be used.
- If it is installed you can try the --with-openssl=DIR argument]) ])
- fi
-
- if test "$use_openssl" = "yes"; then
- AC_CHECK_HEADER(openssl/rand.h,,
- [ use_openssl="no"
- AC_MSG_WARN([Failed to find openssl/rand.h so OpenSSL will not be used.
- If it is installed you can try the --with-openssl=DIR argument]) ])
- fi
-
- if test "$use_openssl" = "yes"; then
- AC_CHECK_LIB(crypto, BIO_int_ctrl,
- [],
- [ use_openssl="no"
- AC_MSG_WARN([Failed to find libcrypto so OpenSSL will not be used.
- If it is installed you can try the --with-openssl=DIR argument]) ])
- fi
-
- if test "$use_openssl" = "yes"; then
- AC_CHECK_LIB(ssl, SSL_new,
- [],
- [ use_openssl="no"
- AC_MSG_WARN([Failed to find libssl so OpenSSL will not be used.
+ AC_MSG_WARN([Failed to find openssl headers so OpenSSL will not be used.
If it is installed you can try the --with-openssl=DIR argument]) ])
- fi
+ if test "$use_openssl" = "yes"; then
+ AC_CHECK_LIB(crypto, BIO_int_ctrl, [],
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find libcrypto so OpenSSL will not be used.
+If it is installed you can try the --with-openssl=DIR argument]) ])
+ fi
+ if test "$use_openssl" = "yes"; then
+ AC_CHECK_LIB(ssl, SSL_new, [],
+ [ use_openssl="no"
+ AC_MSG_WARN([Failed to find libssl so OpenSSL will not be used.
+If it is installed you can try the --with-openssl=DIR argument]) ])
+ fi
+ if test "$use_openssl" = "yes"; then
+ # OpenSSL requires dlopen on some platforms
+ AC_SEARCH_LIBS(dlopen, dl)
+ OPENSSL_LIBS="-lssl -lcrypto"
+ fi])
fi
-OPENSSL_CFLAGS=""
-OPENSSL_LIBS=""
if test "$use_openssl" = "yes"; then
AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if you have OpenSSL.])
- OPENSSL_LIBS="-lssl -lcrypto"
# Define in Makefile also.
HAVE_OPENSSL=yes
- AC_SUBST(HAVE_OPENSSL)
fi
AC_SUBST([OPENSSL_CFLAGS])
AC_SUBST([OPENSSL_LIBS])
-
+AC_SUBST([HAVE_OPENSSL])
LIBEV_CFLAGS=""
--
2.15.1
|