Always complain if too many arguments are given for tincctl commands.
[tinc] / m4 / openssl.m4
1 dnl Check to find the OpenSSL headers/libraries
2
3 AC_DEFUN([tinc_OPENSSL],
4 [
5   case $host_os in
6     *mingw*)
7     ;;
8     *)
9       AC_CHECK_FUNC(dlopen,
10         [],
11         [AC_CHECK_LIB(dl, dlopen,
12           [LIBS="$LIBS -ldl"],
13           [AC_MSG_ERROR([OpenSSL depends on libdl.]); break]
14         )]
15       )
16     ;;
17   esac
18
19   AC_ARG_WITH(openssl,
20     AS_HELP_STRING([--with-openssl=DIR], [OpenSSL base directory, or:]),
21     [openssl="$withval"
22      CPPFLAGS="$CPPFLAGS -I$withval/include"
23      LDFLAGS="$LDFLAGS -L$withval/lib"]
24   )
25
26   AC_ARG_WITH(openssl-include,
27     AS_HELP_STRING([--with-openssl-include=DIR], [OpenSSL headers directory (without trailing /openssl)]),
28     [openssl_include="$withval"
29      CPPFLAGS="$CPPFLAGS -I$withval"]
30   )
31
32   AC_ARG_WITH(openssl-lib,
33     AS_HELP_STRING([--with-openssl-lib=DIR], [OpenSSL library directory]),
34     [openssl_lib="$withval"
35      LDFLAGS="$LDFLAGS -L$withval"]
36   )
37
38   AC_CHECK_HEADERS([openssl/evp.h openssl/rsa.h openssl/rand.h openssl/err.h openssl/sha.h openssl/pem.h openssl/engine.h openssl/ecdh.h openssl/ec.h],
39     [],
40     [AC_MSG_ERROR([OpenSSL header files not found.]); break]
41   )
42
43   AC_CHECK_LIB(crypto, EVP_EncryptInit_ex,
44     [LIBS="-lcrypto $LIBS"],
45     [AC_MSG_ERROR([OpenSSL libraries not found.])]
46   )
47
48   AC_CHECK_FUNCS([RAND_pseudo_bytes EVP_EncryptInit_ex ECDH_compute_key ECDSA_verify], ,
49     [AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break],
50   )
51
52   AC_CHECK_DECL([OpenSSL_add_all_algorithms], ,
53     [AC_MSG_ERROR([Missing OpenSSL functionality, make sure you have installed the latest version.]); break],
54     [#include <openssl/evp.h>]
55   )
56 ])