xref: /freebsd/contrib/ntp/sntp/m4/ntp_crypto_rand.m4 (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1# SYNOPSIS						-*- Autoconf -*-
2#
3#  NTP_CRYPTO_RAND
4#
5# DESCRIPTION
6#
7# AUTHOR
8#
9#  Harlan Stenn
10#
11# LICENSE
12#
13#  This file is Copyright (c) 2014 Network Time Foundation
14#
15#  Copying and distribution of this file, with or without modification, are
16#  permitted in any medium without royalty provided the copyright notice,
17#  author attribution and this notice are preserved.  This file is offered
18#  as-is, without any warranty.
19
20AC_DEFUN([NTP_CRYPTO_RAND], [
21AC_REQUIRE([NTP_OPENSSL])dnl
22
23dnl check for --disable-openssl-random
24dnl if that's not specified:
25dnl - Look for RAND_poll and RAND_bytes
26dnl - if they exist, define USE_OPENSSL_CRYPTO_RAND
27
28AC_MSG_CHECKING([if we want to use OpenSSL's crypto random (if available)])
29AC_ARG_ENABLE(
30    [openssl-random],
31    [AS_HELP_STRING(
32    	[--enable-openssl-random],
33	[Use OpenSSL's crypto random number functions, if available (default is yes)]
34    )],
35    [ntp_use_openssl_random=$enableval],
36    [ntp_use_openssl_random=yes]
37)
38AC_MSG_RESULT([$ntp_use_openssl_random])
39
40# The following might need extra libraries
41NTPO_SAVED_LIBS="$LIBS"
42LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
43dnl AC_MSG_NOTICE([LIBS is <$LIBS>])
44AC_CHECK_FUNCS([RAND_bytes RAND_poll])
45LIBS="$NTPO_SAVED_LIBS"
46case "$ntp_openssl$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
47 yesyesyesyes)
48     AC_DEFINE([USE_OPENSSL_CRYPTO_RAND], [1], [Use OpenSSL's crypto random functions])
49     ;;
50 *) ntp_use_openssl_random=no ;;
51esac
52
53]) dnl NTP_CRYPTO_RAND
54
55