xref: /freebsd/contrib/ntp/sntp/m4/ntp_crypto_rand.m4 (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
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], [
21
22dnl check for --disable-openssl-random
23dnl if that's not specified:
24dnl - Look for RAND_poll and RAND_bytes
25dnl - if they exist, define USE_OPENSSL_CRYPTO_RAND
26
27AC_MSG_CHECKING([if we want to use OpenSSL's crypto random (if available)])
28AC_ARG_ENABLE(
29    [openssl-random],
30    [AS_HELP_STRING(
31    	[--enable-openssl-random],
32	[Use OpenSSL's crypto random number functions, if available (default is yes)]
33    )],
34    [ntp_use_openssl_random=$enableval],
35    [ntp_use_openssl_random=yes]
36)
37AC_MSG_RESULT([$ntp_use_openssl_random])
38
39# The following might need extra libraries
40NTPO_SAVED_LIBS="$LIBS"
41LIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
42dnl AC_MSG_NOTICE([LIBS is <$LIBS>])
43AC_CHECK_FUNCS([RAND_bytes RAND_poll])
44LIBS="$NTPO_SAVED_LIBS"
45case "$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
46 yesyesyes)
47     AC_DEFINE([USE_OPENSSL_CRYPTO_RAND], [1], [Use OpenSSL's crypto random functions])
48     ;;
49 *) ntp_use_openssl_random=no ;;
50esac
51
52]) dnl NTP_CRYPTO_RAND
53
54