blob: e90c78f8a24620fb4e9fe88bb19ff82113f9aa1f [file] [log] [blame]
NingSun0c89b3c2018-02-08 08:34:03 -08001AC_DEFUN([ACX_OPENSSL],[
2 AC_ARG_WITH(openssl,
3 AC_HELP_STRING([--with-openssl=PATH],[Specify prefix of path of OpenSSL]),
4 [
5 OPENSSL_PATH="$withval"
6 ],
7 [
8 OPENSSL_PATH="/usr/local"
9 ])
10
11 AC_MSG_CHECKING(what are the OpenSSL includes)
12 OPENSSL_INCLUDES="-I$OPENSSL_PATH/include"
13 AC_MSG_RESULT($OPENSSL_INCLUDES)
14
15 AC_MSG_CHECKING(what are the OpenSSL libs)
16 OPENSSL_LIBS="-L$OPENSSL_PATH/lib -lcrypto"
17 AC_MSG_RESULT($OPENSSL_LIBS)
18
19 tmp_CPPFLAGS=$CPPFLAGS
20 tmp_LIBS=$LIBS
21
22 CPPFLAGS="$CPPFLAGS $OPENSSL_INCLUDES"
23 LIBS="$OPENSSL_LIBS $LIBS"
24
25 AC_CHECK_HEADERS([openssl/ssl.h],,[AC_MSG_ERROR([Can't find OpenSSL headers])])
26 AC_CHECK_LIB(crypto, BN_new,,[AC_MSG_ERROR([Can't find OpenSSL library])])
27
28 AC_MSG_CHECKING([for OpenSSL version])
29 CHECK_OPENSSL_VERSION=m4_format(0x%02x%02x%02x000L, $1, $2, $3)
30 AC_LANG_PUSH([C])
31 AC_RUN_IFELSE([
32 AC_LANG_SOURCE([[
33 #include <openssl/ssl.h>
34 #include <openssl/opensslv.h>
35 int main()
36 {
37 #ifndef OPENSSL_VERSION_NUMBER
38 return -1;
39 #endif
40 #if OPENSSL_VERSION_NUMBER >= $CHECK_OPENSSL_VERSION
41 return 0;
42 #else
43 return 1;
44 #endif
45 }
46 ]])
47 ],[
48 AC_MSG_RESULT([>= $1.$2.$3])
49 ],[
50 AC_MSG_RESULT([< $1.$2.$3])
51 AC_MSG_ERROR([OpenSSL library too old ($1.$2.$3 or later required)])
52 ],[])
53 AC_LANG_POP([C])
54
55 CPPFLAGS=$tmp_CPPFLAGS
56 LIBS=$tmp_LIBS
57
58 AC_SUBST(OPENSSL_INCLUDES)
59 AC_SUBST(OPENSSL_LIBS)
60])