Implemented new authentication scheme from doc/SECURITY2.
[tinc] / m4 / openssl.m4
1 dnl Check to find the OpenSSL headers/libraries
2
3
4 AC_DEFUN(tinc_OPENSSL,
5 [
6   AC_ARG_WITH(openssl,
7     [  --with-openssl=DIR      OpenSSL library and headers prefix],
8     [openssl_lib="$withval/lib"
9      openssl_include="$withval/include"]
10   )
11   AC_CACHE_CHECK([for openssl headers], tinc_cv_openssl_include,
12   [
13     AC_ARG_WITH(openssl-include,
14       [  --with-openssl-include=DIR OpenSSL headers directory],
15       [tinc_cv_openssl_include="$withval"],
16       [if test "x$openssl_include" = "x" ; then
17          tinc_cv_openssl_include="none given"
18        else
19          tinc_cv_openssl_include=$openssl_include
20        fi]
21     )
22   ])
23   AC_CACHE_CHECK([for openssl libraries], tinc_cv_openssl_lib,
24   [
25     AC_ARG_WITH(openssl-lib,
26       [  --with-openssl-lib=DIR  OpenSSL library directory],
27       [tinc_cv_openssl_lib="$withval"],
28       [if test "x$openssl_lib" = "x" ; then
29          tinc_cv_openssl_lib="none given"
30        else
31          tinc_cv_openssl_lib=$openssl_lib
32        fi]
33     )
34   ])
35
36 if test "$tinc_cv_openssl_lib" != "none given" ; then
37   LIBS="$LIBS -L$tinc_cv_openssl_lib"
38 fi
39 if test "$tinc_cv_openssl_include" != "none given" ; then
40   CFLAGS="$CFLAGS -I$tinc_cv_openssl_include"
41 fi
42
43 osi=found
44 AC_CHECK_HEADERS(evp.h rsa.h rand.h err.h sha.h pem.h,
45 [], [osi=none; break])
46
47 if test "$osi" = "none" ; then
48   osi=found
49   AC_CHECK_HEADERS(openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h,
50   [], [osi=none; break])
51 fi
52
53
54 libcrypto=none
55
56 if test "$osi" = "found" ; then
57   AC_CHECK_LIB(crypto, SHA1_version, [
58     libcrypto=yes
59   ])
60 fi
61
62 if test $libcrypto = none; then
63 cat <<EOF
64
65 It seems like OpenSSL is not installed on this system.  But perhaps
66 you need to supply the exact location of the headers and libraries.
67 You can try running configure with the --with-openssl=/DIRECTORY
68 parameter.  If you installed the headers and libraries in a different
69 location you can use --with-openssl-include=/DIR and
70 --with-openssl-lib=/DIR.
71
72 EOF
73
74   AC_MSG_ERROR(OpenSSL not found.)
75
76 else
77   LIBS="$LIBS -lcrypto"
78 fi
79
80 ])