Look for OpenSSL Check whether --with-openssl or --without-openssl was

 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
# Look for OpenSSL
#
# Check whether --with-openssl or --without-openssl was given.
if test "${with_openssl+set}" = set; then
withval="$with_openssl"
LIBSSH2_OPENSSL_DIR=$withval
else
LIBSSH2_OPENSSL_DIR=yes
fi;
if test "$LIBSSH2_OPENSSL_DIR" = "no" || test "$LIBSSH2_OPENSSL_DIR" = "yes"; then
unset LIBSSH2_OPENSSL_DIR
fi
found_openssl=no
unset OPENSSL_INCDIR
unset OPENSSL_LIBDIR
echo "$as_me:$LINENO: checking for OpenSSL" >&5
echo $ECHO_N "checking for OpenSSL... $ECHO_C" >&6
# Explicit path given, use it rather than pkg-config
if test ! -z "$LIBSSH2_OPENSSL_DIR"; then
found_openssl=yes
OPENSSL_LIBDIR=$LIBSSH2_OPENSSL_DIR/lib
OPENSSL_INCDIR=$LIBSSH2_OPENSSL_DIR/include
echo "$as_me:$LINENO: result: Using explicit path $LIBSSH2_OPENSSL_DIR" >&5
echo "${ECHO_T}Using explicit path $LIBSSH2_OPENSSL_DIR" >&6
fi
# If pkg-config is found try using it
if test "$found_openssl" = "no" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
found_openssl=yes
OPENSSL_LIBDIR=`$PKG_CONFIG --libs openssl`
OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
echo "$as_me:$LINENO: result: Using paths from pkg-config" >&5
echo "${ECHO_T}Using paths from pkg-config" >&6
fi
# Elsewise, search for OpenSSL wherever it might be
if test "$found_openssl" = "no"; then
OPENSSL_SEARCH_PATH="/usr/local/ssl /usr/local /usr /usr/local/openssl"
for i in $OPENSSL_SEARCH_PATH; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/include/openssl/hmac.h; then
OPENSSL_INCDIR=$i/include
fi
if test -r $i/lib/libcrypto.a -o -r $i/lib/libcrypto.$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBDIR=$i/lib
fi
test -n "$OPENSSL_INCDIR" && test -n "$OPENSSL_LIBDIR" && break
done
if test -z "$OPENSSL_INCDIR"; then
{ { echo "$as_me:$LINENO: error: Cannot find OpenSSL's <evp.h> or <hmac.h>" >&5
echo "$as_me: error: Cannot find OpenSSL's <evp.h> or <hmac.h>" >&2;}
{ (exit 1); exit 1; }; }
fi
if test -z "$OPENSSL_LIBDIR"; then
{ { echo "$as_me:$LINENO: error: Cannot find OpenSSL's libcrypto" >&5
echo "$as_me: error: Cannot find OpenSSL's libcrypto" >&2;}
{ (exit 1); exit 1; }; }
fi
echo "$as_me:$LINENO: result: $OPENSSL_INCDIR $OPENSSL_LIBDIR" >&5
echo "${ECHO_T}$OPENSSL_INCDIR $OPENSSL_LIBDIR" >&6
fi
#
# Confirm required OpenSSL libs
#
if test ! -r $OPENSSL_INCDIR/openssl/bn.h || test ! -r $OPENSSL_INCDIR/openssl/evp.h || \
test ! -r $OPENSSL_INCDIR/openssl/hmac.h || test ! -r $OPENSSL_INCDIR/openssl/pem.h || \
test ! -r $OPENSSL_INCDIR/openssl/sha.h; then
{ { echo "$as_me:$LINENO: error: Missing one or more of <openssl/bn.h>, <openssl/evp.h>, <openssl/hmac.h>, <openssl/pem.h>, <openssl/sha.h>" >&5
echo "$as_me: error: Missing one or more of <openssl/bn.h>, <openssl/evp.h>, <openssl/hmac.h>, <openssl/pem.h>, <openssl/sha.h>" >&2;}
{ (exit 1); exit 1; }; }
fi
CFLAGS="$CFLAGS -I$OPENSSL_INCDIR"
LDFLAGS="$LDFLAGS -L$OPENSSL_LIBDIR -lcrypto"
#